Merge pull request #204 from Kwoth/issues/201
Proper implementation of GetMessagesAsync, fixes #201 ?
This commit is contained in:
@@ -99,7 +99,7 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
public virtual async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit)
|
public virtual async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit)
|
||||||
{
|
{
|
||||||
var args = new GetChannelMessagesParams { Limit = limit };
|
var args = new GetChannelMessagesParams { Limit = limit, RelativeMessageId = fromMessageId, RelativeDirection = dir };
|
||||||
var models = await Discord.ApiClient.GetChannelMessagesAsync(Id, args).ConfigureAwait(false);
|
var models = await Discord.ApiClient.GetChannelMessagesAsync(Id, args).ConfigureAwait(false);
|
||||||
return models.Select(x => new Message(this, new User(x.Author.Value), x)).ToImmutableArray();
|
return models.Select(x => new Message(this, new User(x.Author.Value), x)).ToImmutableArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
public virtual async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit)
|
public virtual async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit)
|
||||||
{
|
{
|
||||||
var args = new GetChannelMessagesParams { Limit = limit };
|
var args = new GetChannelMessagesParams { Limit = limit, RelativeMessageId = fromMessageId, RelativeDirection = dir };
|
||||||
var models = await Discord.ApiClient.GetChannelMessagesAsync(Id, args).ConfigureAwait(false);
|
var models = await Discord.ApiClient.GetChannelMessagesAsync(Id, args).ConfigureAwait(false);
|
||||||
return models.Select(x => new Message(this, new User(x.Author.Value), x)).ToImmutableArray();
|
return models.Select(x => new Message(this, new User(x.Author.Value), x)).ToImmutableArray();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace Discord.Rest
|
|||||||
}
|
}
|
||||||
public virtual async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit)
|
public virtual async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit)
|
||||||
{
|
{
|
||||||
var args = new GetChannelMessagesParams { Limit = limit };
|
var args = new GetChannelMessagesParams { Limit = limit, RelativeMessageId = fromMessageId, RelativeDirection = dir };
|
||||||
var models = await Discord.ApiClient.GetChannelMessagesAsync(Id, args).ConfigureAwait(false);
|
var models = await Discord.ApiClient.GetChannelMessagesAsync(Id, args).ConfigureAwait(false);
|
||||||
return models.Select(x => new Message(this, new User(x.Author.Value), x)).ToImmutableArray();
|
return models.Select(x => new Message(this, new User(x.Author.Value), x)).ToImmutableArray();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user