mirror of
https://onedev.fprog.nl/DiscordClient
synced 2025-12-29 17:48:36 +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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (searchResponse.Response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
|
||||
if (
|
||||
searchResponse.HttpResponse.StatusCode
|
||||
== System.Net.HttpStatusCode.TooManyRequests
|
||||
)
|
||||
{
|
||||
await TooManyRequestsDelay();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (searchResponse.JsonData is null)
|
||||
if (searchResponse.DeserializedData is null)
|
||||
return 2;
|
||||
|
||||
totalMessages = searchResponse.JsonData.TotalMessages;
|
||||
totalMessages = searchResponse.DeserializedData.TotalMessages;
|
||||
|
||||
IEnumerable<Message> newMessages = searchResponse.JsonData.Messages.SelectMany(
|
||||
message =>
|
||||
IEnumerable<Message> newMessages =
|
||||
searchResponse.DeserializedData.Messages.SelectMany(message =>
|
||||
message.Select(messagePart => new Message
|
||||
{
|
||||
ChannelId = messagePart.ChannelId,
|
||||
MessageId = messagePart.Id,
|
||||
Content = messagePart.Content
|
||||
})
|
||||
);
|
||||
);
|
||||
|
||||
foreach (var newMessage in newMessages)
|
||||
{
|
||||
|
|
@ -125,10 +128,10 @@ int finalCode = await CommandLine
|
|||
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
offset += searchResponse.JsonData.Messages.Length;
|
||||
offset += searchResponse.DeserializedData.Messages.Length;
|
||||
|
||||
Console.WriteLine(
|
||||
$"Written {searchResponse.JsonData.Messages.Length} messages. {offset} / {totalMessages}"
|
||||
$"Written {searchResponse.DeserializedData.Messages.Length} messages. {offset} / {totalMessages}"
|
||||
);
|
||||
await Task.Delay(TimeSpan.FromSeconds(2));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue