Browse Source

Move REST requests to appropiate class

pull/962/head
Darnell Williams 7 years ago
parent
commit
70d7ebba16
2 changed files with 16 additions and 12 deletions
  1. +14
    -0
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  2. +2
    -12
      src/Discord.Net.WebSocket/DiscordSocketApiClient.cs

+ 14
- 0
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -277,6 +277,18 @@ namespace Discord.API
await SendAsync("GET", () => "auth/login", new BucketIds(), options: options).ConfigureAwait(false); await SendAsync("GET", () => "auth/login", new BucketIds(), options: options).ConfigureAwait(false);
} }


//Gateway
public async Task<GetGatewayResponse> GetGatewayAsync(RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
return await SendAsync<GetGatewayResponse>("GET", () => "gateway", new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<GetBotGatewayResponse> GetBotGatewayAsync(RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
return await SendAsync<GetBotGatewayResponse>("GET", () => "gateway/bot", new BucketIds(), options: options).ConfigureAwait(false);
}

//Channels //Channels
public async Task<Channel> GetChannelAsync(ulong channelId, RequestOptions options = null) public async Task<Channel> GetChannelAsync(ulong channelId, RequestOptions options = null)
{ {
@@ -459,6 +471,8 @@ namespace Discord.API
endpoint = () => $"channels/{channelId}/messages?limit={limit}"; endpoint = () => $"channels/{channelId}/messages?limit={limit}";
return await SendAsync<IReadOnlyCollection<Message>>("GET", endpoint, ids, options: options).ConfigureAwait(false); return await SendAsync<IReadOnlyCollection<Message>>("GET", endpoint, ids, options: options).ConfigureAwait(false);
} }


public async Task<Message> CreateMessageAsync(ulong channelId, CreateMessageParams args, RequestOptions options = null) public async Task<Message> CreateMessageAsync(ulong channelId, CreateMessageParams args, RequestOptions options = null)
{ {
Preconditions.NotNull(args, nameof(args)); Preconditions.NotNull(args, nameof(args));


+ 2
- 12
src/Discord.Net.WebSocket/DiscordSocketApiClient.cs View File

@@ -1,4 +1,4 @@
#pragma warning disable CS1591
#pragma warning disable CS1591
using Discord.API.Gateway; using Discord.API.Gateway;
using Discord.API.Rest; using Discord.API.Rest;
using Discord.Net.Queue; using Discord.Net.Queue;
@@ -208,17 +208,7 @@ namespace Discord.API
await _sentGatewayMessageEvent.InvokeAsync(opCode).ConfigureAwait(false); await _sentGatewayMessageEvent.InvokeAsync(opCode).ConfigureAwait(false);
} }


//Gateway
public async Task<GetGatewayResponse> GetGatewayAsync(RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
return await SendAsync<GetGatewayResponse>("GET", () => "gateway", new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task<GetBotGatewayResponse> GetBotGatewayAsync(RequestOptions options = null)
{
options = RequestOptions.CreateOrClone(options);
return await SendAsync<GetBotGatewayResponse>("GET", () => "gateway/bot", new BucketIds(), options: options).ConfigureAwait(false);
}
public async Task SendIdentifyAsync(int largeThreshold = 100, int shardID = 0, int totalShards = 1, RequestOptions options = null) public async Task SendIdentifyAsync(int largeThreshold = 100, int shardID = 0, int totalShards = 1, RequestOptions options = null)
{ {
options = RequestOptions.CreateOrClone(options); options = RequestOptions.CreateOrClone(options);


Loading…
Cancel
Save