diff --git a/ref/DiscordClient.cs b/ref/DiscordClient.cs
index a1708309f..aa777e04f 100644
--- a/ref/DiscordClient.cs
+++ b/ref/DiscordClient.cs
@@ -11,9 +11,15 @@ namespace Discord
/// Provides a connection to the DiscordApp service.
public class DiscordClient : IDisposable
{
+ public event EventHandler Log = delegate { };
+
public event EventHandler LoggedIn = delegate { };
public event EventHandler LoggedOut = delegate { };
- public event EventHandler Log = delegate { };
+ public event EventHandler Connected = delegate { };
+ public event EventHandler Disconnected = delegate { };
+ public event EventHandler VoiceConnected = delegate { };
+ public event EventHandler VoiceDisconnected = delegate { };
+
public event EventHandler ChannelCreated = delegate { };
public event EventHandler ChannelUpdated = delegate { };
public event EventHandler ChannelDestroyed = delegate { };
@@ -38,47 +44,30 @@ namespace Discord
public event EventHandler UserUpdated = delegate { };
public event EventHandler UserUnbanned = delegate { };
- public DiscordConfig Config { get; }
- public IRestClient ClientAPI { get; }
- public IRestClient StatusAPI { get; }
- public GatewaySocket GatewaySocket { get; }
public MessageQueue MessageQueue { get; }
-
- public ConnectionState State { get; }
- public CancellationToken CancelToken { get; }
- public Profile CurrentUser { get; }
- public string SessionId { get; }
- public UserStatus Status { get; }
- public string CurrentGame { get; }
-
- public IEnumerable Servers { get; }
- public IEnumerable PrivateChannels { get; }
- public IEnumerable Regions { get; }
+ public IRestClient RestClient { get; }
+ public GatewaySocket GatewaySocket { get; }
+ public Profile CurrentUser { get; }
public DiscordClient() { }
public DiscordClient(DiscordConfig config) { }
- public DiscordClient(Action configFunc) { }
- public Task Login(string email, string password, string token = null) => null;
- public Task Login(string token, bool validate = true) => null;
+ public Task Login(string token) => null;
public Task Logout() => null;
- /*public Task Connect(string email, string password, string token = null) => null;
- public Task Connect(string token) => null;
- public Task Disconnect() => null;*/
-
- public void SetStatus(UserStatus status) { }
- public void SetGame(string game) { }
-
- public PrivateChannel GetPrivateChannel(ulong id) => null;
- public Task CreatePrivateChannel(ulong userId) => null;
+ public Task Connect() => null;
+ public Task Connect(int connectionId, int totalConnections) => null;
+ public Task Disconnect() => null;
+ public Task> GetPrivateChannels() => null;
+ public Task GetPrivateChannel(ulong userId) => null;
public Task GetInvite(string inviteIdOrXkcd) => null;
+ public Task> GetRegions() => null;
+ public Task GetRegion(string id) => null;
+ public Task> GetServers() => null;
+ public Task GetServer(ulong id) => null;
- public Region GetRegion(string id) => null;
-
- public Server GetServer(ulong id) => null;
- public IEnumerable FindServers(string name) => null;
+ public Task CreatePrivateChannel(ulong userId) => null;
public Task CreateServer(string name, Region region, ImageType iconType = ImageType.None, Stream icon = null) => null;
public void Dispose() { }
diff --git a/ref/DiscordConfig.cs b/ref/DiscordConfig.cs
index 657a58437..e6b1a5568 100644
--- a/ref/DiscordConfig.cs
+++ b/ref/DiscordConfig.cs
@@ -1,36 +1,65 @@
-using System;
+using Discord.Net.Rest;
+using Discord.Net.WebSockets;
+using System.Reflection;
namespace Discord
-{
- public class DiscordConfig
+{
+ public class DiscordConfig
{
public const int MaxMessageSize = 2000;
+ public const int MaxMessagesPerBatch = 100;
+
public const string LibName = "Discord.Net";
- public static readonly string LibVersion = null;
+ public static string LibVersion => typeof(DiscordConfig).GetTypeInfo().Assembly?.GetName().Version.ToString(3) ?? "Unknown";
public const string LibUrl = "https://github.com/RogueException/Discord.Net";
public const string ClientAPIUrl = "https://discordapp.com/api/";
- public const string StatusAPIUrl = "https://srhpyqt94yxb.statuspage.io/api/v2/"; //"https://status.discordapp.com/api/v2/";
public const string CDNUrl = "https://cdn.discordapp.com/";
public const string InviteUrl = "https://discord.gg/";
+ /// Gets or sets name of your application, used in the user agent.
public string AppName { get; set; } = null;
+ /// Gets or sets url to your application, used in the user agent.
public string AppUrl { get; set; } = null;
+ /// Gets or sets the version of your application, used in the user agent.
public string AppVersion { get; set; } = null;
+
+ /// Gets or sets the minimum log level severity that will be sent to the LogMessage event.
public LogSeverity LogLevel { get; set; } = LogSeverity.Info;
-
+
+ /// Gets or sets the time (in milliseconds) to wait for the websocket to connect and initialize.
public int ConnectionTimeout { get; set; } = 30000;
- public int ReconnectDelay { get; set; } = 1000;
- public int FailedReconnectDelay { get; set; } = 15000;
-
- public bool CacheToken { get; set; } = true;
- public int MessageCacheSize { get; set; } = 100;
+ /// Gets or sets the time (in milliseconds) to wait after an unexpected disconnect before reconnecting.
+ public int ReconnectDelay { get; set; } = 1000;
+ /// Gets or sets the time (in milliseconds) to wait after an reconnect fails before retrying.
+ public int FailedReconnectDelay { get; set; } = 15000;
+
+ //Performance
+ /// Gets or sets the number of messages per channel that should be kept in cache. Setting this to zero disables the message cache entirely.
+ public int MessageCacheSize { get; set; } = 100;
+ ///
+ /// Gets or sets whether the permissions cache should be used.
+ /// This makes operations such as User.GetPermissions(Channel), User.ServerPermissions, Channel.GetUser, and Channel.Members much faster while increasing memory usage.
+ ///
public bool UsePermissionsCache { get; set; } = true;
+ /// Gets or sets whether the a copy of a model is generated on an update event to allow you to check which properties changed.
public bool EnablePreUpdateEvents { get; set; } = true;
+ ///
+ /// Gets or sets the max number of users a server may have for offline users to be included in the READY packet. Max is 250.
+ /// Decreasing this may reduce CPU usage while increasing login time and network usage.
+ ///
public int LargeThreshold { get; set; } = 250;
-
- public EventHandler LogHandler { get; set; }
- public string UserAgent { get; }
+
+ //Engines
+
+ /// Gets or sets the REST engine to use.. Defaults to DefaultRestClientProvider, which uses .Net's HttpClient class.
+ public IRestClientProvider RestClientProvider { get; set; } = null;
+ ///
+ /// Gets or sets the WebSocket engine to use. Defaults to DefaultWebSocketProvider, which uses .Net's WebSocketClient class.
+ /// WebSockets are only used if DiscordClient.Connect() is called.
+ ///
+ public IWebSocketProvider WebSocketProvider { get; set; } = null;
}
}
+
diff --git a/ref/Entities/Channels/IChannel.cs b/ref/Entities/Channels/IChannel.cs
index 55e723303..fb82fb30d 100644
--- a/ref/Entities/Channels/IChannel.cs
+++ b/ref/Entities/Channels/IChannel.cs
@@ -7,16 +7,12 @@ namespace Discord
{
/// Gets the type flags for this channel.
ChannelType Type { get; }
- /// Gets whether this is a text channel.
- bool IsText { get; }
- /// Gets whether this is a voice channel.
- bool IsVoice { get; }
- /// Gets whether this is a private channel.
- bool IsPrivate { get; }
- /// Gets whether this is a public channel.
- bool IsPublic { get; }
+ /// Gets the name of this channel.
+ string Name { get; }
+ /// Gets a user in this channel with the given id.
+ Task GetUser(ulong id);
/// Gets a collection of all users in this channel.
- Task> GetUsers();
+ Task> GetUsers();
}
}
diff --git a/ref/Entities/Channels/IPrivateChannel.cs b/ref/Entities/Channels/IPrivateChannel.cs
deleted file mode 100644
index 0ac5ec3aa..000000000
--- a/ref/Entities/Channels/IPrivateChannel.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Discord
-{
- public interface IPrivateChannel : IChannel
- {
- /// Gets the recipient of the messages in this private channel.
- User Recipient { get; }
- }
-}
diff --git a/ref/Entities/Channels/IPublicChannel.cs b/ref/Entities/Channels/IPublicChannel.cs
index 91a05d861..bd005a288 100644
--- a/ref/Entities/Channels/IPublicChannel.cs
+++ b/ref/Entities/Channels/IPublicChannel.cs
@@ -3,36 +3,33 @@ using System.Threading.Tasks;
namespace Discord
{
- public struct PermissionOverwriteEntry
- {
- public PermissionTarget TargetType { get; }
- public ulong TargetId { get; }
- public OverwritePermissions Permissions { get; }
- }
public interface IPublicChannel : IChannel
{
/// Gets the server this channel is a member of.
Server Server { get; }
/// Gets a collection of permission overwrites for this channel.
IEnumerable PermissionOverwrites { get; }
- /// Gets the name of this public channel.
- string Name { get; }
/// Gets the position of this public channel relative to others of the same type.
int Position { get; }
+ /// Gets a user in this channel with the given id.
+ new Task GetUser(ulong id);
+ /// Gets a collection of all users in this channel.
+ new Task> GetUsers();
+
/// Gets the permission overwrite for a specific user, or null if one does not exist.
- OverwritePermissions? GetPermissionOverwrite(User user);
+ OverwritePermissions? GetPermissionOverwrite(ServerUser user);
/// Gets the permission overwrite for a specific role, or null if one does not exist.
OverwritePermissions? GetPermissionOverwrite(Role role);
/// Downloads a collection of all invites to this server.
Task> GetInvites();
-
+
/// Adds or updates the permission overwrite for the given user.
- Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions);
+ Task UpdatePermissionOverwrite(ServerUser user, OverwritePermissions permissions);
/// Adds or updates the permission overwrite for the given role.
Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions);
/// Removes the permission overwrite for the given user, if one exists.
- Task RemovePermissionOverwrite(User user);
+ Task RemovePermissionOverwrite(ServerUser user);
/// Removes the permission overwrite for the given role, if one exists.
Task RemovePermissionOverwrite(Role role);
diff --git a/ref/Entities/Channels/ITextChannel.cs b/ref/Entities/Channels/ITextChannel.cs
index b1449fac9..f3701abbf 100644
--- a/ref/Entities/Channels/ITextChannel.cs
+++ b/ref/Entities/Channels/ITextChannel.cs
@@ -10,12 +10,12 @@ namespace Discord
Task GetMessage(ulong id);
/// Gets the last N messages from this text channel.
/// The maximum number of messages to retrieve.
- Task> GetMessages(int limit = 100);
+ Task> GetMessages(int limit = DiscordConfig.MaxMessagesPerBatch);
/// Gets a collection of messages in this channel.
/// The maximum number of messages to retrieve.
/// The message to start downloading relative to.
/// The direction, from relativeMessageId, to download messages in.
- Task> GetMessages(int limit = 100, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before);
+ Task> GetMessages(int limit = DiscordConfig.MaxMessagesPerBatch, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before);
/// Sends a message to this text channel.
Task SendMessage(string text, bool isTTS = false);
diff --git a/ref/Entities/Channels/IVoiceChannel.cs b/ref/Entities/Channels/IVoiceChannel.cs
deleted file mode 100644
index f8c3be999..000000000
--- a/ref/Entities/Channels/IVoiceChannel.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace Discord
-{
- public interface IVoiceChannel : IChannel
- {
- /// Gets the requested bitrate, in bits per second, of this voice channel.
- int Bitrate { get; }
- }
-}
diff --git a/ref/Entities/Channels/PrivateChannel.cs b/ref/Entities/Channels/PrivateChannel.cs
index 6364bf884..ee72c0828 100644
--- a/ref/Entities/Channels/PrivateChannel.cs
+++ b/ref/Entities/Channels/PrivateChannel.cs
@@ -4,30 +4,32 @@ using System.Threading.Tasks;
namespace Discord
{
- public class PrivateChannel : ITextChannel, IPrivateChannel
+ public class PrivateChannel : ITextChannel, IChannel
{
- ///
- public ulong Id { get; }
///
public DiscordClient Discord { get; }
///
public EntityState State { get; }
///
- public ChannelType Type { get; }
- ///
- public bool IsPrivate => true;
+ public ulong Id { get; }
///
- public bool IsPublic => false;
+ public PrivateUser Recipient { get; }
///
- public bool IsText => true;
+ public PrivateUser CurrentUser { get; }
+
///
- public bool IsVoice => false;
-
+ ChannelType IChannel.Type => ChannelType.Private | ChannelType.Text;
///
- public User Recipient { get; }
+ public string Name { get; }
///
- public Task> GetUsers() => null;
+ public Task GetUser(ulong id) => null;
+ ///
+ Task IChannel.GetUser(ulong id) => null;
+ ///
+ public Task> GetUsers() => null;
+ ///
+ Task> IChannel.GetUsers() => null;
///
public Task GetMessage(ulong id) => null;
///
diff --git a/ref/Entities/Channels/TextChannel.cs b/ref/Entities/Channels/TextChannel.cs
index 2d977111c..0b1b81c77 100644
--- a/ref/Entities/Channels/TextChannel.cs
+++ b/ref/Entities/Channels/TextChannel.cs
@@ -5,7 +5,7 @@ using System.Threading.Tasks;
namespace Discord
{
- public class TextChannel : ITextChannel, IPublicChannel, IMentionable, IModifiable
+ public class TextChannel : ITextChannel, IMentionable, IModifiable
{
public sealed class Properties
{
@@ -14,22 +14,17 @@ namespace Discord
public int Position { get; }
}
- ///
- public ulong Id { get; }
- ///
- public DiscordClient Discord { get; }
///
public EntityState State { get; }
///
- public ChannelType Type => ChannelType.Public | ChannelType.Text;
- ///
- public bool IsPrivate => false;
+ public ulong Id { get; }
///
- public bool IsPublic => true;
+ public Server Server { get; }
+
///
- public bool IsText => true;
+ public DiscordClient Discord { get; }
///
- public bool IsVoice => false;
+ public ChannelType Type => ChannelType.Public | ChannelType.Text;
///
public string Name { get; }
@@ -37,21 +32,24 @@ namespace Discord
public string Topic { get; }
///
public int Position { get; }
+
///
public string Mention { get; }
///
- public Server Server { get; }
- ///
public IEnumerable PermissionOverwrites { get; }
- ///
- public IEnumerable Users { get; }
///
- public OverwritePermissions? GetPermissionOverwrite(User user) => null;
+ public OverwritePermissions? GetPermissionOverwrite(ServerUser user) => null;
///
public OverwritePermissions? GetPermissionOverwrite(Role role) => null;
///
- public Task> GetUsers() => null;
+ public Task GetUser(ulong id) => null;
+ ///
+ Task IChannel.GetUser(ulong id) => null;
+ ///
+ public Task> GetUsers() => null;
+ ///
+ Task> IChannel.GetUsers() => null;
///
public Task GetMessage(ulong id) => null;
///
@@ -62,11 +60,11 @@ namespace Discord
public Task> GetInvites() => null;
///
- public Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions) => null;
+ public Task UpdatePermissionOverwrite(ServerUser user, OverwritePermissions permissions) => null;
///
public Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions) => null;
///
- public Task RemovePermissionOverwrite(User user) => null;
+ public Task RemovePermissionOverwrite(ServerUser user) => null;
///
public Task RemovePermissionOverwrite(Role role) => null;
diff --git a/ref/Entities/Channels/VoiceChannel.cs b/ref/Entities/Channels/VoiceChannel.cs
index 100569c71..6552fadd7 100644
--- a/ref/Entities/Channels/VoiceChannel.cs
+++ b/ref/Entities/Channels/VoiceChannel.cs
@@ -4,7 +4,7 @@ using System.Threading.Tasks;
namespace Discord
{
- public class VoiceChannel : IPublicChannel, IVoiceChannel, IModifiable
+ public class VoiceChannel : IPublicChannel, IModifiable
{
public sealed class Properties
{
@@ -16,19 +16,14 @@ namespace Discord
///
public ulong Id { get; }
///
- public DiscordClient Discord { get; }
- ///
public EntityState State { get; }
///
- public ChannelType Type { get; }
- ///
- public bool IsPrivate => false;
- ///
- public bool IsPublic => true;
+ public Server Server { get; }
+
///
- public bool IsText => false;
+ public DiscordClient Discord { get; }
///
- public bool IsVoice => true;
+ ChannelType IChannel.Type => ChannelType.Public | ChannelType.Voice;
///
public string Name { get; }
@@ -36,26 +31,33 @@ namespace Discord
public int Position { get; }
///
public int Bitrate { get; }
+
///
- public Server Server { get; }
+ public string Mention { get; }
///
public IEnumerable PermissionOverwrites { get; }
///
- public OverwritePermissions? GetPermissionOverwrite(User user) => null;
+ public OverwritePermissions? GetPermissionOverwrite(ServerUser user) => null;
///
public OverwritePermissions? GetPermissionOverwrite(Role role) => null;
///
- public Task> GetUsers() => null;
+ public Task GetUser(ulong id) => null;
+ ///
+ Task IChannel.GetUser(ulong id) => null;
+ ///
+ public Task> GetUsers() => null;
+ ///
+ Task> IChannel.GetUsers() => null;
///
public Task> GetInvites() => null;
///
- public Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions) => null;
+ public Task UpdatePermissionOverwrite(ServerUser user, OverwritePermissions permissions) => null;
///
public Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions) => null;
///
- public Task RemovePermissionOverwrite(User user) => null;
+ public Task RemovePermissionOverwrite(ServerUser user) => null;
///
public Task RemovePermissionOverwrite(Role role) => null;
diff --git a/ref/Entities/IEntity.cs b/ref/Entities/IEntity.cs
index ddd791d74..ac707a69e 100644
--- a/ref/Entities/IEntity.cs
+++ b/ref/Entities/IEntity.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
namespace Discord
{
diff --git a/ref/Entities/Invite.cs b/ref/Entities/Invite.cs
deleted file mode 100644
index 1e6da77dc..000000000
--- a/ref/Entities/Invite.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.Threading.Tasks;
-
-namespace Discord
-{
- public class Invite : IEntity
- {
- public class ServerInfo
- {
- public ulong Id { get; }
- public string Name { get; }
- }
- public class ChannelInfo
- {
- public ulong Id { get; }
- public string Name { get; }
- }
- public class InviterInfo
- {
- public ulong Id { get; }
- public string Name { get; }
- public ushort Discriminator { get; }
- public string AvatarId { get; }
- public string AvatarUrl { get; }
- }
-
- string IEntity.Id => Code;
- public DiscordClient Discord { get; }
- public EntityState State { get; }
-
- public string Code { get; }
- public string XkcdCode { get; }
-
- public ServerInfo Server { get; }
- public ChannelInfo Channel { get; }
- public int? MaxAge { get; }
- public int Uses { get; }
- public int? MaxUses { get; }
- public bool IsRevoked { get; }
- public bool IsTemporary { get; }
- public DateTime CreatedAt { get; }
- public string Url { get; }
-
- public Task Accept() => null;
-
- public Task Update() => null;
- public Task Delete() => null;
- }
-}
diff --git a/ref/Entities/Invite/BasicInvite.cs b/ref/Entities/Invite/BasicInvite.cs
new file mode 100644
index 000000000..37cd1704d
--- /dev/null
+++ b/ref/Entities/Invite/BasicInvite.cs
@@ -0,0 +1,37 @@
+using System.Threading.Tasks;
+
+namespace Discord
+{
+ public class BasicInvite : IEntity
+ {
+ public class TargetInfo
+ {
+ public ulong Id { get; }
+ public string Name { get; }
+ }
+ public class InviterInfo
+ {
+ public ulong Id { get; }
+ public string Name { get; }
+ public ushort Discriminator { get; }
+ public string AvatarId { get; }
+ public string AvatarUrl { get; }
+ }
+
+ string IEntity.Id => Code;
+ public DiscordClient Discord { get; }
+ public EntityState State { get; }
+
+ public string Code { get; }
+ public string XkcdCode { get; }
+
+ public TargetInfo Server { get; }
+ public TargetInfo Channel { get; }
+
+ public string Url { get; }
+
+ public Task Accept() => null;
+
+ public virtual Task Update() => null;
+ }
+}
diff --git a/ref/Entities/Invite/Invite.cs b/ref/Entities/Invite/Invite.cs
new file mode 100644
index 000000000..11fead2af
--- /dev/null
+++ b/ref/Entities/Invite/Invite.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Threading.Tasks;
+
+namespace Discord
+{
+ public class Invite : BasicInvite
+ {
+ public int? MaxAge { get; }
+ public int Uses { get; }
+ public int? MaxUses { get; }
+ public bool IsRevoked { get; }
+ public bool IsTemporary { get; }
+ public DateTime CreatedAt { get; }
+
+ public override Task Update() => null;
+ public Task Delete() => null;
+ }
+}
diff --git a/ref/Entities/Message.cs b/ref/Entities/Message.cs
index 617446dad..78c4e41bd 100644
--- a/ref/Entities/Message.cs
+++ b/ref/Entities/Message.cs
@@ -44,7 +44,7 @@ namespace Discord
public EntityState State { get; }
public ITextChannel Channel { get; }
- public User User { get; }
+ public IUser User { get; }
public bool IsTTS { get; }
public string RawText { get; }
public string Text { get; }
@@ -53,9 +53,9 @@ namespace Discord
public Attachment[] Attachments { get; }
public Embed[] Embeds { get; }
- public IEnumerable MentionedUsers { get; }
- public IEnumerable MentionedChannels { get; }
- public IEnumerable MentionedRoles { get; }
+ public IReadOnlyList MentionedUsers { get; }
+ public IReadOnlyList MentionedChannels { get; }
+ public IReadOnlyList MentionedRoles { get; }
public Server Server => null;
public bool IsAuthor => false;
diff --git a/ref/Entities/Permissions/PermissionOverwriteEntry.cs b/ref/Entities/Permissions/PermissionOverwriteEntry.cs
new file mode 100644
index 000000000..bbc11fba8
--- /dev/null
+++ b/ref/Entities/Permissions/PermissionOverwriteEntry.cs
@@ -0,0 +1,9 @@
+namespace Discord
+{
+ public struct PermissionOverwriteEntry
+ {
+ public PermissionTarget TargetType { get; }
+ public ulong TargetId { get; }
+ public OverwritePermissions Permissions { get; }
+ }
+}
diff --git a/ref/Entities/Role.cs b/ref/Entities/Role.cs
index 92edb7bd2..f5155db2e 100644
--- a/ref/Entities/Role.cs
+++ b/ref/Entities/Role.cs
@@ -19,7 +19,7 @@ namespace Discord
public Color Color { get; }
public bool IsEveryone { get; }
- public IEnumerable Members { get; }
+ public IEnumerable Members { get; }
public string Mention { get; }
diff --git a/ref/Entities/Server.cs b/ref/Entities/Server.cs
index 3b3b2b283..a9078cb4b 100644
--- a/ref/Entities/Server.cs
+++ b/ref/Entities/Server.cs
@@ -19,7 +19,7 @@ namespace Discord
public DiscordClient Discord { get; }
public EntityState State { get; }
- public User CurrentUser { get; }
+ public ServerUser CurrentUser { get; }
public string IconId { get; }
public string SplashId { get; }
public string IconUrl { get; }
@@ -34,24 +34,24 @@ namespace Discord
public IEnumerable Channels { get; }
public IEnumerable TextChannels { get; }
public IEnumerable VoiceChannels { get; }
- public IEnumerable Users { get; }
+ public IEnumerable Users { get; }
public IEnumerable Roles { get; }
public string Name { get; set; }
public Region Region { get; set; }
public int AFKTimeout { get; set; }
public DateTime JoinedAt { get; set; }
- public User Owner { get; set; }
+ public ServerUser Owner { get; set; }
public VoiceChannel AFKChannel { get; set; }
- public IPublicChannel GetChannel(ulong id) => null;
- public IPublicChannel GetChannel(string mention) => null;
- public Role GetRole(ulong id) => null;
- public User GetUser(ulong id) => null;
- public User GetUser(string name, ushort discriminator) => null;
- public User GetUser(string mention) => null;
- public Task> DownloadBans() => null;
- public Task> DownloadInvites() => null;
+ public Task GetChannel(ulong id) => null;
+ public Task GetChannel(string mention) => null;
+ public Task GetRole(ulong id) => null;
+ public Task GetUser(ulong id) => null;
+ public Task GetUser(string name, ushort discriminator) => null;
+ public Task GetUser(string mention) => null;
+ public Task> GetBans() => null;
+ public Task> GetInvites() => null;
public Task CreateTextChannel(string name) => null;
public Task CreateVoiceChannel(string name) => null;
diff --git a/ref/Entities/User.cs b/ref/Entities/User.cs
deleted file mode 100644
index d4eacaef4..000000000
--- a/ref/Entities/User.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Threading.Tasks;
-
-namespace Discord
-{
- public class User : IEntity
- {
- public ulong Id { get; }
- public DiscordClient Discord { get; }
- public EntityState State { get; }
-
- public Server Server { get; }
-
- public string Name { get; }
- public ushort Discriminator { get; }
- public string AvatarId { get; }
- public string CurrentGame { get; }
- public UserStatus Status { get; }
- public DateTime JoinedAt { get; }
- public DateTime? LastActivityAt { get; }
-
- public string Mention => null;
- public bool IsSelfMuted => false;
- public bool IsSelfDeafened => false;
- public bool IsServerMuted => false;
- public bool IsServerDeafened => false;
- public bool IsServerSuppressed => false;
- public DateTime? LastOnlineAt => null;
- public VoiceChannel VoiceChannel => null;
- public string AvatarUrl => null;
- public IEnumerable Roles => null;
- public IEnumerable Channels => null;
- public ServerPermissions ServerPermissions => default(ServerPermissions);
-
- public ChannelPermissions GetPermissions(IPublicChannel channel) => default(ChannelPermissions);
- public Task GetPrivateChannel() => null;
-
- public Task SendMessage(string text) => null;
- public Task SendFile(string filePath) => null;
- public Task SendFile(string filename, Stream stream) => null;
-
- public bool HasRole(Role role) => false;
-
- public Task AddRoles(params Role[] roles) => null;
- public Task RemoveRoles(params Role[] roles) => null;
-
- public Task Update() => null;
- public Task Kick() => null;
- public Task Ban(User user, int pruneDays = 0) => null;
- public Task Unban(User user) => null;
- public Task Unban(ulong userId) => null;
- }
-}
\ No newline at end of file
diff --git a/ref/Entities/Users/IUser.cs b/ref/Entities/Users/IUser.cs
new file mode 100644
index 000000000..02dd2d85b
--- /dev/null
+++ b/ref/Entities/Users/IUser.cs
@@ -0,0 +1,19 @@
+using System.Threading.Tasks;
+
+namespace Discord
+{
+ public interface IUser : IEntity, IMentionable
+ {
+ bool IsPrivate { get; }
+
+ string Name { get; }
+ ushort Discriminator { get; }
+ bool IsBot { get; }
+ string AvatarId { get; }
+ string AvatarUrl { get; }
+ string CurrentGame { get; }
+ UserStatus Status { get; }
+
+ Task GetPrivateChannel();
+ }
+}
diff --git a/ref/Entities/Users/PrivateUser.cs b/ref/Entities/Users/PrivateUser.cs
new file mode 100644
index 000000000..a6cc9d6e7
--- /dev/null
+++ b/ref/Entities/Users/PrivateUser.cs
@@ -0,0 +1,43 @@
+using System.Threading.Tasks;
+
+namespace Discord
+{
+ //TODO: Should this be linked directly to the Profile when it represents us, instead of maintaining a cache of values?
+ public class PrivateUser : IUser
+ {
+ ///
+ public EntityState State { get; internal set; }
+ ///
+ public ulong Id { get; }
+ /// Returns the private channel for this user.
+ public PrivateChannel Channel { get; }
+
+ ///
+ bool IUser.IsPrivate => true;
+
+ ///
+ public string Name { get; }
+ ///
+ public ushort Discriminator { get; }
+ ///
+ public bool IsBot { get; }
+ ///
+ public string AvatarId { get; }
+ ///
+ public string CurrentGame { get; }
+ ///
+ public UserStatus Status { get; }
+
+ ///
+ public DiscordClient Discord => Channel.Discord;
+ ///
+ public string AvatarUrl { get; }
+ ///
+ public string Mention { get; }
+
+ ///
+ Task IUser.GetPrivateChannel() => Task.FromResult(Channel);
+
+ public Task Update() => null;
+ }
+}
diff --git a/ref/Entities/Users/ServerUser.cs b/ref/Entities/Users/ServerUser.cs
new file mode 100644
index 000000000..4ff86f67a
--- /dev/null
+++ b/ref/Entities/Users/ServerUser.cs
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Discord
+{
+ public class ServerUser : IUser
+ {
+ ///
+ public EntityState State { get; }
+ ///
+ public ulong Id { get; }
+ /// Returns the private channel for this user.
+ public Server Server { get; }
+
+ ///
+ bool IUser.IsPrivate => false;
+
+ ///
+ public string Name { get; }
+ ///
+ public ushort Discriminator { get; }
+ ///
+ public bool IsBot { get; }
+ ///
+ public string AvatarId { get; }
+ ///
+ public string CurrentGame { get; }
+ ///
+ public UserStatus Status { get; }
+ ///
+ public DateTime JoinedAt { get; }
+ ///
+ public IReadOnlyList Roles { get; }
+
+ /// Returns true if this user has marked themselves as muted.
+ public bool IsSelfMuted { get; }
+ /// Returns true if this user has marked themselves as deafened.
+ public bool IsSelfDeafened { get; }
+ /// Returns true if the server is blocking audio from this user.
+ public bool IsServerMuted { get; }
+ /// Returns true if the server is blocking audio to this user.
+ public bool IsServerDeafened { get; }
+ /// Returns true if the server is temporarily blocking audio to/from this user.
+ public bool IsServerSuppressed { get; }
+ /// Gets this user's current voice channel.
+ public VoiceChannel VoiceChannel { get; }
+
+ ///
+ public DiscordClient Discord { get; }
+ ///
+ public string AvatarUrl { get; }
+ ///
+ public string Mention { get; }
+
+ public ServerPermissions ServerPermissions { get; }
+
+ public ChannelPermissions GetPermissions(IPublicChannel channel) => default(ChannelPermissions);
+ ///
+ public Task GetPrivateChannel() => null;
+ public Task> GetChannels() => null;
+
+ public bool HasRole(Role role) => false;
+
+ public Task AddRoles(params Role[] roles) => null;
+ public Task RemoveRoles(params Role[] roles) => null;
+
+ public Task Update() => null;
+ public Task Kick() => null;
+ public Task Ban(int pruneDays = 0) => null;
+ public Task Unban() => null;
+ }
+}
\ No newline at end of file
diff --git a/ref/Events/MessageEventArgs.cs b/ref/Events/MessageEventArgs.cs
index 5b251fa9d..f75c7f1a8 100644
--- a/ref/Events/MessageEventArgs.cs
+++ b/ref/Events/MessageEventArgs.cs
@@ -5,7 +5,7 @@ namespace Discord
public class MessageEventArgs : EventArgs
{
public Message Message => null;
- public User User => null;
+ public IUser User => null;
public ITextChannel Channel => null;
}
}
diff --git a/ref/Events/MessageUpdatedEventArgs.cs b/ref/Events/MessageUpdatedEventArgs.cs
index 3205721f3..d323bf809 100644
--- a/ref/Events/MessageUpdatedEventArgs.cs
+++ b/ref/Events/MessageUpdatedEventArgs.cs
@@ -6,7 +6,7 @@ namespace Discord
{
public Message Before => null;
public Message After => null;
- public User User => null;
+ public IUser User => null;
public ITextChannel Channel => null;
}
}
diff --git a/ref/Events/TypingEventArgs.cs b/ref/Events/TypingEventArgs.cs
index 73d47f688..f45313687 100644
--- a/ref/Events/TypingEventArgs.cs
+++ b/ref/Events/TypingEventArgs.cs
@@ -3,9 +3,9 @@
public class TypingEventArgs
{
public ITextChannel Channel { get; }
- public User User { get; }
+ public IUser User { get; }
- public TypingEventArgs(ITextChannel channel, User user)
+ public TypingEventArgs(ITextChannel channel, IUser user)
{
Channel = channel;
User = user;
diff --git a/ref/Events/UserEventArgs.cs b/ref/Events/UserEventArgs.cs
index 6f638c915..f1cce29fc 100644
--- a/ref/Events/UserEventArgs.cs
+++ b/ref/Events/UserEventArgs.cs
@@ -3,6 +3,6 @@ namespace Discord
{
public class UserEventArgs : EventArgs
{
- public User User => null;
+ public IUser User => null;
}
}
diff --git a/ref/Events/UserUpdatedEventArgs.cs b/ref/Events/UserUpdatedEventArgs.cs
index 6fb5fa2c3..c45c60701 100644
--- a/ref/Events/UserUpdatedEventArgs.cs
+++ b/ref/Events/UserUpdatedEventArgs.cs
@@ -3,7 +3,7 @@ namespace Discord
{
public class UserUpdatedEventArgs : EventArgs
{
- public User Before => null;
- public User After => null;
+ public IUser Before => null;
+ public IUser After => null;
}
}
diff --git a/ref/Net/Rest/IRestClientProvider.cs b/ref/Net/Rest/IRestClientProvider.cs
new file mode 100644
index 000000000..cb22a7474
--- /dev/null
+++ b/ref/Net/Rest/IRestClientProvider.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+using System.Threading;
+
+namespace Discord.Net.Rest
+{
+ public interface IRestClientProvider
+ {
+ IRestClient Create(string baseUrl, CancellationToken cancelToken);
+ }
+}
diff --git a/ref/Net/WebSockets/IWebSocket.cs b/ref/Net/WebSockets/IWebSocket.cs
new file mode 100644
index 000000000..06a274305
--- /dev/null
+++ b/ref/Net/WebSockets/IWebSocket.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Threading;
+
+namespace Discord.Net.WebSockets
+{
+ public interface IWebSocket
+ {
+ CancellationToken CancelToken { get; }
+ ConnectionState State { get; }
+ string Host { get; set; }
+
+ event EventHandler Connected;
+ event EventHandler Disconnected;
+ }
+}
diff --git a/ref/Net/WebSockets/IWebSocketProvider.cs b/ref/Net/WebSockets/IWebSocketProvider.cs
new file mode 100644
index 000000000..20f7559be
--- /dev/null
+++ b/ref/Net/WebSockets/IWebSocketProvider.cs
@@ -0,0 +1,9 @@
+using System.Threading;
+
+namespace Discord.Net.WebSockets
+{
+ public interface IWebSocketProvider
+ {
+ IWebSocket Create(CancellationToken cancelToken);
+ }
+}
diff --git a/ref/Net/WebSockets/WebSocket.cs b/ref/Net/WebSockets/WebSocket.cs
deleted file mode 100644
index 1257f2474..000000000
--- a/ref/Net/WebSockets/WebSocket.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Discord.Logging;
-using System;
-using System.Threading;
-
-namespace Discord.Net.WebSockets
-{
- public abstract partial class WebSocket
- {
- public CancellationToken CancelToken { get; }
- public ConnectionState State { get; }
- public string Host { get; }
-
- public event EventHandler Connected = delegate { };
- public event EventHandler Disconnected = delegate { };
-
- public WebSocket(DiscordConfig config, ILogger logger) { }
-
- public abstract void SendHeartbeat();
-
- public virtual void WaitForConnection(CancellationToken cancelToken) { }
- }
-}