Browse Source

Fixed relative id when retrieving >100 channel message requests.

pull/121/head
RogueException 9 years ago
parent
commit
ee04e1ddcc
1 changed files with 22 additions and 6 deletions
  1. +22
    -6
      src/Discord.Net/API/DiscordAPIClient.cs

+ 22
- 6
src/Discord.Net/API/DiscordAPIClient.cs View File

@@ -918,8 +918,19 @@ namespace Discord.API
//Was this an empty batch?
if (models.Length == 0) break;

result[i] = models;
relativeId = args.RelativeDirection == Direction.Before ? models[0].Id : models[models.Length - 1].Id;
switch (args.RelativeDirection)
{
case Direction.Before:
case Direction.Around:
default:
result[i] = models;
relativeId = models[models.Length - 1].Id;
break;
case Direction.After:
result[runs - i - 1] = models;
relativeId = models[0].Id;
break;
}

//Was this an incomplete (the last) batch?
if (models.Length != DiscordConfig.MaxMessagesPerBatch) { i++; break; }
@@ -927,10 +938,15 @@ namespace Discord.API

if (i > 1)
{
if (args.RelativeDirection == Direction.Before)
return result.Take(i).SelectMany(x => x).ToImmutableArray();
else
return result.Take(i).Reverse().SelectMany(x => x).ToImmutableArray();
switch (args.RelativeDirection)
{
case Direction.Before:
case Direction.Around:
default:
return result.Take(i).SelectMany(x => x).ToImmutableArray();
case Direction.After:
return result.Skip(runs - i).Take(i).SelectMany(x => x).ToImmutableArray();
}
}
else if (i == 1)
return result[0];


Loading…
Cancel
Save