Reorganized classes into Rpc/Rest/WebSocket namespaces
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
internal static class CDN
|
||||
{
|
||||
public static string GetApplicationIconUrl(ulong appId, string iconId)
|
||||
=> iconId != null ? $"{DiscordRestConfig.CDNUrl}app-icons/{appId}/{iconId}.jpg" : null;
|
||||
=> iconId != null ? $"{DiscordConfig.CDNUrl}app-icons/{appId}/{iconId}.jpg" : null;
|
||||
public static string GetUserAvatarUrl(ulong userId, string avatarId)
|
||||
=> avatarId != null ? $"{DiscordRestConfig.CDNUrl}avatars/{userId}/{avatarId}.jpg" : null;
|
||||
=> avatarId != null ? $"{DiscordConfig.CDNUrl}avatars/{userId}/{avatarId}.jpg" : null;
|
||||
public static string GetGuildIconUrl(ulong guildId, string iconId)
|
||||
=> iconId != null ? $"{DiscordRestConfig.CDNUrl}icons/{guildId}/{iconId}.jpg" : null;
|
||||
=> iconId != null ? $"{DiscordConfig.CDNUrl}icons/{guildId}/{iconId}.jpg" : null;
|
||||
public static string GetGuildSplashUrl(ulong guildId, string splashId)
|
||||
=> splashId != null ? $"{DiscordRestConfig.CDNUrl}splashes/{guildId}/{splashId}.jpg" : null;
|
||||
=> splashId != null ? $"{DiscordConfig.CDNUrl}splashes/{guildId}/{splashId}.jpg" : null;
|
||||
public static string GetChannelIconUrl(ulong channelId, string iconId)
|
||||
=> iconId != null ? $"{DiscordRestConfig.CDNUrl}channel-icons/{channelId}/{iconId}.jpg" : null;
|
||||
=> iconId != null ? $"{DiscordConfig.CDNUrl}channel-icons/{channelId}/{iconId}.jpg" : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Discord.Net.Converters;
|
||||
using Discord.Net.Queue;
|
||||
using Discord.Net.Rest;
|
||||
using Discord.Net.WebSockets;
|
||||
using Discord.Rest;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -594,13 +595,13 @@ namespace Discord.API
|
||||
|
||||
List<GuildMember[]> result;
|
||||
if (args._limit.IsSpecified)
|
||||
result = new List<GuildMember[]>((limit + DiscordRestConfig.MaxUsersPerBatch - 1) / DiscordRestConfig.MaxUsersPerBatch);
|
||||
result = new List<GuildMember[]>((limit + DiscordConfig.MaxUsersPerBatch - 1) / DiscordConfig.MaxUsersPerBatch);
|
||||
else
|
||||
result = new List<GuildMember[]>();
|
||||
|
||||
while (true)
|
||||
{
|
||||
int runLimit = (limit >= DiscordRestConfig.MaxUsersPerBatch) ? DiscordRestConfig.MaxUsersPerBatch : limit;
|
||||
int runLimit = (limit >= DiscordConfig.MaxUsersPerBatch) ? DiscordConfig.MaxUsersPerBatch : limit;
|
||||
string endpoint = $"guilds/{guildId}/members?limit={runLimit}&after={afterUserId}";
|
||||
var models = await SendAsync<GuildMember[]>("GET", endpoint, options: options).ConfigureAwait(false);
|
||||
|
||||
@@ -609,11 +610,11 @@ namespace Discord.API
|
||||
|
||||
result.Add(models);
|
||||
|
||||
limit -= DiscordRestConfig.MaxUsersPerBatch;
|
||||
limit -= DiscordConfig.MaxUsersPerBatch;
|
||||
afterUserId = models[models.Length - 1].User.Id;
|
||||
|
||||
//Was this an incomplete (the last) batch?
|
||||
if (models.Length != DiscordRestConfig.MaxUsersPerBatch) break;
|
||||
if (models.Length != DiscordConfig.MaxUsersPerBatch) break;
|
||||
}
|
||||
|
||||
if (result.Count > 1)
|
||||
@@ -723,14 +724,14 @@ namespace Discord.API
|
||||
break;
|
||||
}
|
||||
|
||||
int runs = (limit + DiscordRestConfig.MaxMessagesPerBatch - 1) / DiscordRestConfig.MaxMessagesPerBatch;
|
||||
int lastRunCount = limit - (runs - 1) * DiscordRestConfig.MaxMessagesPerBatch;
|
||||
int runs = (limit + DiscordConfig.MaxMessagesPerBatch - 1) / DiscordConfig.MaxMessagesPerBatch;
|
||||
int lastRunCount = limit - (runs - 1) * DiscordConfig.MaxMessagesPerBatch;
|
||||
var result = new API.Message[runs][];
|
||||
|
||||
int i = 0;
|
||||
for (; i < runs; i++)
|
||||
{
|
||||
int runCount = i == (runs - 1) ? lastRunCount : DiscordRestConfig.MaxMessagesPerBatch;
|
||||
int runCount = i == (runs - 1) ? lastRunCount : DiscordConfig.MaxMessagesPerBatch;
|
||||
string endpoint;
|
||||
if (relativeId != null)
|
||||
endpoint = $"channels/{channelId}/messages?limit={runCount}&{relativeDir}={relativeId}";
|
||||
@@ -769,7 +770,7 @@ namespace Discord.API
|
||||
}
|
||||
|
||||
//Was this an incomplete (the last) batch?
|
||||
if (models.Length != DiscordRestConfig.MaxMessagesPerBatch) { i++; break; }
|
||||
if (models.Length != DiscordConfig.MaxMessagesPerBatch) { i++; break; }
|
||||
}
|
||||
|
||||
if (i > 1)
|
||||
@@ -814,8 +815,8 @@ namespace Discord.API
|
||||
Preconditions.NotEqual(channelId, 0, nameof(channelId));
|
||||
Preconditions.NotNull(args, nameof(args));
|
||||
Preconditions.NotNullOrEmpty(args._content, nameof(args.Content));
|
||||
if (args._content.Length > DiscordRestConfig.MaxMessageSize)
|
||||
throw new ArgumentException($"Message content is too long, length must be less or equal to {DiscordRestConfig.MaxMessageSize}.", nameof(args.Content));
|
||||
if (args._content.Length > DiscordConfig.MaxMessageSize)
|
||||
throw new ArgumentException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content));
|
||||
|
||||
if (guildId != 0)
|
||||
return await SendAsync<Message>("POST", $"channels/{channelId}/messages", args, GuildBucket.SendEditMessage, guildId, options: options).ConfigureAwait(false);
|
||||
@@ -843,8 +844,8 @@ namespace Discord.API
|
||||
{
|
||||
if (args._content.Value == null)
|
||||
args._content = "";
|
||||
if (args._content.Value?.Length > DiscordRestConfig.MaxMessageSize)
|
||||
throw new ArgumentOutOfRangeException($"Message content is too long, length must be less or equal to {DiscordRestConfig.MaxMessageSize}.", nameof(args.Content));
|
||||
if (args._content.Value?.Length > DiscordConfig.MaxMessageSize)
|
||||
throw new ArgumentOutOfRangeException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content));
|
||||
}
|
||||
|
||||
if (guildId != 0)
|
||||
@@ -924,8 +925,8 @@ namespace Discord.API
|
||||
if (args._content.IsSpecified)
|
||||
{
|
||||
Preconditions.NotNullOrEmpty(args._content, nameof(args.Content));
|
||||
if (args._content.Value.Length > DiscordRestConfig.MaxMessageSize)
|
||||
throw new ArgumentOutOfRangeException($"Message content is too long, length must be less or equal to {DiscordRestConfig.MaxMessageSize}.", nameof(args.Content));
|
||||
if (args._content.Value.Length > DiscordConfig.MaxMessageSize)
|
||||
throw new ArgumentOutOfRangeException($"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", nameof(args.Content));
|
||||
}
|
||||
|
||||
if (guildId != 0)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Discord.Net.Queue;
|
||||
using Discord.Net.Rest;
|
||||
using Discord.Net.WebSockets;
|
||||
using Discord.Rpc;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
namespace Discord.API.Rest
|
||||
using Discord.Rest;
|
||||
|
||||
namespace Discord.API.Rest
|
||||
{
|
||||
public class GetChannelMessagesParams
|
||||
{
|
||||
public int Limit { internal get; set; } = DiscordRestConfig.MaxMessagesPerBatch;
|
||||
public int Limit { internal get; set; } = DiscordConfig.MaxMessagesPerBatch;
|
||||
|
||||
public Direction RelativeDirection { internal get; set; } = Direction.Before;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Discord.API.Voice;
|
||||
using Discord.Logging;
|
||||
using Discord.Net.Converters;
|
||||
using Discord.WebSocket;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Discord.Extensions;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -14,6 +14,10 @@ namespace Discord
|
||||
public const string CDNUrl = "https://cdn.discordapp.com/";
|
||||
public const string InviteUrl = "https://discord.gg/";
|
||||
|
||||
public const int MaxMessageSize = 2000;
|
||||
public const int MaxMessagesPerBatch = 100;
|
||||
public const int MaxUsersPerBatch = 1000;
|
||||
|
||||
/// <summary> Gets or sets the minimum log level severity that will be sent to the LogMessage event. </summary>
|
||||
public LogSeverity LogLevel { get; set; } = LogSeverity.Info;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Application;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Extensions;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace Discord
|
||||
/// <summary> Gets the message from this channel's cache with the given id, or null if not found. </summary>
|
||||
IMessage GetCachedMessage(ulong id);
|
||||
/// <summary> Gets the last N messages from this message channel. </summary>
|
||||
Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordRestConfig.MaxMessagesPerBatch);
|
||||
Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch);
|
||||
/// <summary> Gets a collection of messages in this channel. </summary>
|
||||
Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordRestConfig.MaxMessagesPerBatch);
|
||||
Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch);
|
||||
/// <summary> Bulk deletes multiple messages. </summary>
|
||||
Task DeleteMessagesAsync(IEnumerable<IMessage> messages);
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Discord
|
||||
using Discord.Rest;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
internal abstract class Entity<T> : IEntity<T>
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Audio;
|
||||
using Discord.Extensions;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using Discord.Rest;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.UserGuild;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using Discord.Rest;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Invite;
|
||||
|
||||
@@ -16,8 +17,8 @@ namespace Discord
|
||||
public override DiscordRestClient Discord { get; }
|
||||
|
||||
public string Code => Id;
|
||||
public string Url => $"{DiscordRestConfig.InviteUrl}/{XkcdCode ?? Code}";
|
||||
public string XkcdUrl => XkcdCode != null ? $"{DiscordRestConfig.InviteUrl}/{XkcdCode}" : null;
|
||||
public string Url => $"{DiscordConfig.InviteUrl}/{XkcdCode ?? Code}";
|
||||
public string XkcdUrl => XkcdCode != null ? $"{DiscordConfig.InviteUrl}/{XkcdCode}" : null;
|
||||
|
||||
public Invite(DiscordRestClient discord, Model model)
|
||||
: base(model.Code)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using Model = Discord.API.InviteMetadata;
|
||||
|
||||
namespace Discord
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.Role;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using Model = Discord.API.Rpc.RpcUserGuild;
|
||||
|
||||
namespace Discord.Entities.Rpc
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.User;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Discord.Rest;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Model = Discord.API.User;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.Extensions;
|
||||
using Discord.Rest;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -51,7 +52,7 @@ namespace Discord
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
public override IImmutableList<SocketMessage> GetMany(ulong? fromMessageId, Direction dir, int limit = DiscordRestConfig.MaxMessagesPerBatch)
|
||||
public override IImmutableList<SocketMessage> GetMany(ulong? fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
|
||||
{
|
||||
if (limit < 0) throw new ArgumentOutOfRangeException(nameof(limit));
|
||||
if (limit == 0) return ImmutableArray<SocketMessage>.Empty;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.Rest;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
@@ -25,7 +27,7 @@ namespace Discord
|
||||
public virtual SocketMessage Remove(ulong id) => null;
|
||||
public virtual SocketMessage Get(ulong id) => null;
|
||||
|
||||
public virtual IImmutableList<SocketMessage> GetMany(ulong? fromMessageId, Direction dir, int limit = DiscordRestConfig.MaxMessagesPerBatch)
|
||||
public virtual IImmutableList<SocketMessage> GetMany(ulong? fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
|
||||
=> ImmutableArray.Create<SocketMessage>();
|
||||
|
||||
public virtual async Task<SocketMessage> DownloadAsync(ulong id)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Discord.WebSocket;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading.Tasks;
|
||||
using MessageModel = Discord.API.Message;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Discord.Extensions;
|
||||
using Discord.WebSocket;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Discord.Rest;
|
||||
using Discord.WebSocket;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -48,11 +50,11 @@ namespace Discord
|
||||
{
|
||||
return await _messages.DownloadAsync(id).ConfigureAwait(false);
|
||||
}
|
||||
public override async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordRestConfig.MaxMessagesPerBatch)
|
||||
public override async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(int limit = DiscordConfig.MaxMessagesPerBatch)
|
||||
{
|
||||
return await _messages.DownloadAsync(null, Direction.Before, limit).ConfigureAwait(false);
|
||||
}
|
||||
public override async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordRestConfig.MaxMessagesPerBatch)
|
||||
public override async Task<IReadOnlyCollection<IMessage>> GetMessagesAsync(ulong fromMessageId, Direction dir, int limit = DiscordConfig.MaxMessagesPerBatch)
|
||||
{
|
||||
return await _messages.DownloadAsync(fromMessageId, dir, limit).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.Audio;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Discord.Audio;
|
||||
using Discord.Extensions;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Model = Discord.API.Message;
|
||||
using Discord.WebSocket;
|
||||
using Model = Discord.API.Message;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using PresenceModel = Discord.API.Presence;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using Model = Discord.API.User;
|
||||
using PresenceModel = Discord.API.Presence;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using Discord.WebSocket;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Model = Discord.API.GuildMember;
|
||||
using Discord.WebSocket;
|
||||
using Model = Discord.API.GuildMember;
|
||||
using PresenceModel = Discord.API.Presence;
|
||||
|
||||
namespace Discord
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Discord.API.Rest;
|
||||
using Discord.WebSocket;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Model = Discord.API.User;
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace Discord.Extensions
|
||||
namespace Discord
|
||||
{
|
||||
internal static class CollectionExtensions
|
||||
{
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System.Linq;
|
||||
using Discord.Rest;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.Extensions
|
||||
namespace Discord
|
||||
{
|
||||
public static class DiscordClientExtensions
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.Extensions
|
||||
namespace Discord
|
||||
{
|
||||
public static class GuildExtensions
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.Extensions
|
||||
namespace Discord
|
||||
{
|
||||
public static class GuildUserExtensions
|
||||
{
|
||||
|
||||
@@ -10,8 +10,10 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using Discord.Rpc;
|
||||
using Discord.WebSocket;
|
||||
|
||||
namespace Discord
|
||||
namespace Discord.Rest
|
||||
{
|
||||
public class DiscordRestClient : IDiscordClient
|
||||
{
|
||||
@@ -1,15 +1,11 @@
|
||||
using Discord.Net.Rest;
|
||||
|
||||
namespace Discord
|
||||
namespace Discord.Rest
|
||||
{
|
||||
public class DiscordRestConfig : DiscordConfig
|
||||
{
|
||||
public static string UserAgent { get; } = $"DiscordBot (https://github.com/RogueException/Discord.Net, v{Version})";
|
||||
|
||||
public const int MaxMessageSize = 2000;
|
||||
public const int MaxMessagesPerBatch = 100;
|
||||
public const int MaxUsersPerBatch = 1000;
|
||||
|
||||
|
||||
internal const int RestTimeout = 10000;
|
||||
internal const int MessageQueueInterval = 100;
|
||||
internal const int WebSocketQueueInterval = 100;
|
||||
@@ -2,6 +2,7 @@
|
||||
using Discord.Logging;
|
||||
using Discord.Net.Converters;
|
||||
using Discord.Net.Queue;
|
||||
using Discord.Rest;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
@@ -9,18 +10,10 @@ using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord
|
||||
namespace Discord.Rpc
|
||||
{
|
||||
public class DiscordRpcClient : DiscordRestClient
|
||||
public partial class DiscordRpcClient : DiscordRestClient
|
||||
{
|
||||
public event Func<Task> Connected { add { _connectedEvent.Add(value); } remove { _connectedEvent.Remove(value); } }
|
||||
private readonly AsyncEvent<Func<Task>> _connectedEvent = new AsyncEvent<Func<Task>>();
|
||||
public event Func<Exception, Task> Disconnected { add { _disconnectedEvent.Add(value); } remove { _disconnectedEvent.Remove(value); } }
|
||||
private readonly AsyncEvent<Func<Exception, Task>> _disconnectedEvent = new AsyncEvent<Func<Exception, Task>>();
|
||||
|
||||
public event Func<Task> Ready { add { _readyEvent.Add(value); } remove { _readyEvent.Remove(value); } }
|
||||
private readonly AsyncEvent<Func<Task>> _readyEvent = new AsyncEvent<Func<Task>>();
|
||||
|
||||
private readonly ILogger _rpcLogger;
|
||||
private readonly JsonSerializer _serializer;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Discord.Net.WebSockets;
|
||||
using Discord.Rest;
|
||||
|
||||
namespace Discord
|
||||
namespace Discord.Rpc
|
||||
{
|
||||
public class DiscordRpcConfig : DiscordRestConfig
|
||||
{
|
||||
6
src/Discord.Net/Rpc/RpcEvents.cs
Normal file
6
src/Discord.Net/Rpc/RpcEvents.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Discord.Rpc
|
||||
{
|
||||
public enum RpcEvent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
//TODO: Add event docstrings
|
||||
public partial class DiscordSocketClient
|
||||
@@ -1,10 +1,10 @@
|
||||
using Discord.API.Gateway;
|
||||
using Discord.Audio;
|
||||
using Discord.Extensions;
|
||||
using Discord.Logging;
|
||||
using Discord.Net.Converters;
|
||||
using Discord.Net.Queue;
|
||||
using Discord.Net.WebSockets;
|
||||
using Discord.Rest;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
@@ -15,7 +15,7 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord
|
||||
namespace Discord.WebSocket
|
||||
{
|
||||
public partial class DiscordSocketClient : DiscordRestClient, IDiscordClient
|
||||
{
|
||||
@@ -1,5 +1,6 @@
|
||||
using Discord.Audio;
|
||||
using Discord.Net.WebSockets;
|
||||
using Discord.Rest;
|
||||
|
||||
namespace Discord
|
||||
{
|
||||
Reference in New Issue
Block a user