Browse Source

Actually use GetMessages(beforeMessageId)

tags/docs-0.9
RogueException 9 years ago
parent
commit
2ba268e892
3 changed files with 7 additions and 3 deletions
  1. +1
    -0
      src/Discord.Net/API/Endpoints.cs
  2. +5
    -2
      src/Discord.Net/DiscordAPIClient.cs
  3. +1
    -1
      src/Discord.Net/DiscordClient.Messages.cs

+ 1
- 0
src/Discord.Net/API/Endpoints.cs View File

@@ -16,6 +16,7 @@
public static string ChannelTyping(string channelId) => $"channels/{channelId}/typing"; public static string ChannelTyping(string channelId) => $"channels/{channelId}/typing";
public static string ChannelMessages(string channelId) => $"channels/{channelId}/messages"; public static string ChannelMessages(string channelId) => $"channels/{channelId}/messages";
public static string ChannelMessages(string channelId, int limit) => $"channels/{channelId}/messages?limit={limit}"; public static string ChannelMessages(string channelId, int limit) => $"channels/{channelId}/messages?limit={limit}";
public static string ChannelMessages(string channelId, int limit, string beforeId) => $"channels/{channelId}/messages?limit={limit}&before={beforeId}";
public static string ChannelMessage(string channelId, string msgId) => $"channels/{channelId}/messages/{msgId}"; public static string ChannelMessage(string channelId, string msgId) => $"channels/{channelId}/messages/{msgId}";
public static string ChannelMessageAck(string channelId, string msgId) => $"channels/{channelId}/messages/{msgId}/ack"; public static string ChannelMessageAck(string channelId, string msgId) => $"channels/{channelId}/messages/{msgId}/ack";
public static string ChannelInvites(string channelId) => $"channels/{channelId}/invites"; public static string ChannelInvites(string channelId) => $"channels/{channelId}/invites";


+ 5
- 2
src/Discord.Net/DiscordAPIClient.cs View File

@@ -92,11 +92,14 @@ namespace Discord
var request = new ReorderChannelsRequest(channels); var request = new ReorderChannelsRequest(channels);
return _rest.Patch(Endpoints.ServerChannels(serverId), request); return _rest.Patch(Endpoints.ServerChannels(serverId), request);
} }
public Task<GetMessagesResponse> GetMessages(string channelId, int count)
public Task<GetMessagesResponse> GetMessages(string channelId, int count, string beforeMessageId = null)
{ {
if (channelId == null) throw new ArgumentNullException(nameof(channelId)); if (channelId == null) throw new ArgumentNullException(nameof(channelId));


return _rest.Get<GetMessagesResponse>(Endpoints.ChannelMessages(channelId, count));
if (beforeMessageId != null)
return _rest.Get<GetMessagesResponse>(Endpoints.ChannelMessages(channelId, count, beforeMessageId));
else
return _rest.Get<GetMessagesResponse>(Endpoints.ChannelMessages(channelId, count));
} }


//Incidents //Incidents


+ 1
- 1
src/Discord.Net/DiscordClient.Messages.cs View File

@@ -210,7 +210,7 @@ namespace Discord
{ {
try try
{ {
var msgs = await _api.GetMessages(channel.Id, count).ConfigureAwait(false);
var msgs = await _api.GetMessages(channel.Id, count, beforeMessageId).ConfigureAwait(false);
return msgs.Select(x => return msgs.Select(x =>
{ {
Message msg = null; Message msg = null;


Loading…
Cancel
Save