mirror of
https://onedev.fprog.nl/DiscordClient
synced 2026-02-27 11:13:42 +01:00
Calling appropriate properties of HttpData.
This commit is contained in:
parent
3c462012e2
commit
29b2f0a71b
|
|
@ -88,34 +88,37 @@ int finalCode = await CommandLine
|
||||||
: await client.SearchGuildMessages(opt.GuildId, offset, opt.Author);
|
: await client.SearchGuildMessages(opt.GuildId, offset, opt.Author);
|
||||||
|
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
$"Scan code at offset {offset}: {searchResponse.Response.StatusCode}."
|
$"Scan code at offset {offset}: {searchResponse.HttpResponse.StatusCode}."
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!searchResponse.Response.IsSuccessStatusCode)
|
if (!searchResponse.HttpResponse.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchResponse.Response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
|
if (
|
||||||
|
searchResponse.HttpResponse.StatusCode
|
||||||
|
== System.Net.HttpStatusCode.TooManyRequests
|
||||||
|
)
|
||||||
{
|
{
|
||||||
await TooManyRequestsDelay();
|
await TooManyRequestsDelay();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchResponse.JsonData is null)
|
if (searchResponse.DeserializedData is null)
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
totalMessages = searchResponse.JsonData.TotalMessages;
|
totalMessages = searchResponse.DeserializedData.TotalMessages;
|
||||||
|
|
||||||
IEnumerable<Message> newMessages = searchResponse.JsonData.Messages.SelectMany(
|
IEnumerable<Message> newMessages =
|
||||||
message =>
|
searchResponse.DeserializedData.Messages.SelectMany(message =>
|
||||||
message.Select(messagePart => new Message
|
message.Select(messagePart => new Message
|
||||||
{
|
{
|
||||||
ChannelId = messagePart.ChannelId,
|
ChannelId = messagePart.ChannelId,
|
||||||
MessageId = messagePart.Id,
|
MessageId = messagePart.Id,
|
||||||
Content = messagePart.Content
|
Content = messagePart.Content
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach (var newMessage in newMessages)
|
foreach (var newMessage in newMessages)
|
||||||
{
|
{
|
||||||
|
|
@ -125,10 +128,10 @@ int finalCode = await CommandLine
|
||||||
|
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
|
|
||||||
offset += searchResponse.JsonData.Messages.Length;
|
offset += searchResponse.DeserializedData.Messages.Length;
|
||||||
|
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
$"Written {searchResponse.JsonData.Messages.Length} messages. {offset} / {totalMessages}"
|
$"Written {searchResponse.DeserializedData.Messages.Length} messages. {offset} / {totalMessages}"
|
||||||
);
|
);
|
||||||
await Task.Delay(TimeSpan.FromSeconds(2));
|
await Task.Delay(TimeSpan.FromSeconds(2));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue