| @@ -11,9 +11,15 @@ namespace Discord | |||
| /// <summary> Provides a connection to the DiscordApp service. </summary> | |||
| public class DiscordClient : IDisposable | |||
| { | |||
| public event EventHandler<LogMessageEventArgs> Log = delegate { }; | |||
| public event EventHandler LoggedIn = delegate { }; | |||
| public event EventHandler LoggedOut = delegate { }; | |||
| public event EventHandler<LogMessageEventArgs> Log = delegate { }; | |||
| public event EventHandler Connected = delegate { }; | |||
| public event EventHandler Disconnected = delegate { }; | |||
| public event EventHandler<ServerEventArgs> VoiceConnected = delegate { }; | |||
| public event EventHandler<ServerEventArgs> VoiceDisconnected = delegate { }; | |||
| public event EventHandler<ChannelEventArgs> ChannelCreated = delegate { }; | |||
| public event EventHandler<ChannelUpdatedEventArgs> ChannelUpdated = delegate { }; | |||
| public event EventHandler<ChannelEventArgs> ChannelDestroyed = delegate { }; | |||
| @@ -38,47 +44,30 @@ namespace Discord | |||
| public event EventHandler<UserUpdatedEventArgs> UserUpdated = delegate { }; | |||
| public event EventHandler<UserEventArgs> 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<Server> Servers { get; } | |||
| public IEnumerable<PrivateChannel> PrivateChannels { get; } | |||
| public IEnumerable<Region> Regions { get; } | |||
| public IRestClient RestClient { get; } | |||
| public GatewaySocket GatewaySocket { get; } | |||
| public Profile CurrentUser { get; } | |||
| public DiscordClient() { } | |||
| public DiscordClient(DiscordConfig config) { } | |||
| public DiscordClient(Action<DiscordConfig> configFunc) { } | |||
| public Task<string> 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<string> 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<PrivateChannel> CreatePrivateChannel(ulong userId) => null; | |||
| public Task Connect() => null; | |||
| public Task Connect(int connectionId, int totalConnections) => null; | |||
| public Task Disconnect() => null; | |||
| public Task<IEnumerable<PrivateChannel>> GetPrivateChannels() => null; | |||
| public Task<PrivateChannel> GetPrivateChannel(ulong userId) => null; | |||
| public Task<Invite> GetInvite(string inviteIdOrXkcd) => null; | |||
| public Task<IReadOnlyList<Region>> GetRegions() => null; | |||
| public Task<Region> GetRegion(string id) => null; | |||
| public Task<IEnumerable<Server>> GetServers() => null; | |||
| public Task<Server> GetServer(ulong id) => null; | |||
| public Region GetRegion(string id) => null; | |||
| public Server GetServer(ulong id) => null; | |||
| public IEnumerable<Server> FindServers(string name) => null; | |||
| public Task<PrivateChannel> CreatePrivateChannel(ulong userId) => null; | |||
| public Task<Server> CreateServer(string name, Region region, ImageType iconType = ImageType.None, Stream icon = null) => null; | |||
| public void Dispose() { } | |||
| @@ -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/"; | |||
| /// <summary> Gets or sets name of your application, used in the user agent. </summary> | |||
| public string AppName { get; set; } = null; | |||
| /// <summary> Gets or sets url to your application, used in the user agent. </summary> | |||
| public string AppUrl { get; set; } = null; | |||
| /// <summary> Gets or sets the version of your application, used in the user agent. </summary> | |||
| public string AppVersion { get; set; } = null; | |||
| /// <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; | |||
| /// <summary> Gets or sets the time (in milliseconds) to wait for the websocket to connect and initialize. </summary> | |||
| 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; | |||
| /// <summary> Gets or sets the time (in milliseconds) to wait after an unexpected disconnect before reconnecting. </summary> | |||
| public int ReconnectDelay { get; set; } = 1000; | |||
| /// <summary> Gets or sets the time (in milliseconds) to wait after an reconnect fails before retrying. </summary> | |||
| public int FailedReconnectDelay { get; set; } = 15000; | |||
| //Performance | |||
| /// <summary> Gets or sets the number of messages per channel that should be kept in cache. Setting this to zero disables the message cache entirely. </summary> | |||
| public int MessageCacheSize { get; set; } = 100; | |||
| /// <summary> | |||
| /// 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. | |||
| /// </summary> | |||
| public bool UsePermissionsCache { get; set; } = true; | |||
| /// <summary> Gets or sets whether the a copy of a model is generated on an update event to allow you to check which properties changed. </summary> | |||
| public bool EnablePreUpdateEvents { get; set; } = true; | |||
| /// <summary> | |||
| /// 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. | |||
| /// </summary> | |||
| public int LargeThreshold { get; set; } = 250; | |||
| public EventHandler<LogMessageEventArgs> LogHandler { get; set; } | |||
| public string UserAgent { get; } | |||
| //Engines | |||
| /// <summary> Gets or sets the REST engine to use.. Defaults to DefaultRestClientProvider, which uses .Net's HttpClient class. </summary> | |||
| public IRestClientProvider RestClientProvider { get; set; } = null; | |||
| /// <summary> | |||
| /// 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. | |||
| /// </summary> | |||
| public IWebSocketProvider WebSocketProvider { get; set; } = null; | |||
| } | |||
| } | |||
| @@ -7,16 +7,12 @@ namespace Discord | |||
| { | |||
| /// <summary> Gets the type flags for this channel. </summary> | |||
| ChannelType Type { get; } | |||
| /// <summary> Gets whether this is a text channel. </summary> | |||
| bool IsText { get; } | |||
| /// <summary> Gets whether this is a voice channel. </summary> | |||
| bool IsVoice { get; } | |||
| /// <summary> Gets whether this is a private channel. </summary> | |||
| bool IsPrivate { get; } | |||
| /// <summary> Gets whether this is a public channel. </summary> | |||
| bool IsPublic { get; } | |||
| /// <summary> Gets the name of this channel. </summary> | |||
| string Name { get; } | |||
| /// <summary> Gets a user in this channel with the given id. </summary> | |||
| Task<IUser> GetUser(ulong id); | |||
| /// <summary> Gets a collection of all users in this channel. </summary> | |||
| Task<IEnumerable<User>> GetUsers(); | |||
| Task<IEnumerable<IUser>> GetUsers(); | |||
| } | |||
| } | |||
| @@ -1,8 +0,0 @@ | |||
| namespace Discord | |||
| { | |||
| public interface IPrivateChannel : IChannel | |||
| { | |||
| /// <summary> Gets the recipient of the messages in this private channel. </summary> | |||
| User Recipient { get; } | |||
| } | |||
| } | |||
| @@ -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 | |||
| { | |||
| /// <summary> Gets the server this channel is a member of. </summary> | |||
| Server Server { get; } | |||
| /// <summary> Gets a collection of permission overwrites for this channel. </summary> | |||
| IEnumerable<PermissionOverwriteEntry> PermissionOverwrites { get; } | |||
| /// <summary> Gets the name of this public channel. </summary> | |||
| string Name { get; } | |||
| /// <summary> Gets the position of this public channel relative to others of the same type. </summary> | |||
| int Position { get; } | |||
| /// <summary> Gets a user in this channel with the given id. </summary> | |||
| new Task<ServerUser> GetUser(ulong id); | |||
| /// <summary> Gets a collection of all users in this channel. </summary> | |||
| new Task<IEnumerable<ServerUser>> GetUsers(); | |||
| /// <summary> Gets the permission overwrite for a specific user, or null if one does not exist. </summary> | |||
| OverwritePermissions? GetPermissionOverwrite(User user); | |||
| OverwritePermissions? GetPermissionOverwrite(ServerUser user); | |||
| /// <summary> Gets the permission overwrite for a specific role, or null if one does not exist. </summary> | |||
| OverwritePermissions? GetPermissionOverwrite(Role role); | |||
| /// <summary> Downloads a collection of all invites to this server. </summary> | |||
| Task<IEnumerable<Invite>> GetInvites(); | |||
| /// <summary> Adds or updates the permission overwrite for the given user. </summary> | |||
| Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions); | |||
| Task UpdatePermissionOverwrite(ServerUser user, OverwritePermissions permissions); | |||
| /// <summary> Adds or updates the permission overwrite for the given role. </summary> | |||
| Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions); | |||
| /// <summary> Removes the permission overwrite for the given user, if one exists. </summary> | |||
| Task RemovePermissionOverwrite(User user); | |||
| Task RemovePermissionOverwrite(ServerUser user); | |||
| /// <summary> Removes the permission overwrite for the given role, if one exists. </summary> | |||
| Task RemovePermissionOverwrite(Role role); | |||
| @@ -10,12 +10,12 @@ namespace Discord | |||
| Task<Message> GetMessage(ulong id); | |||
| /// <summary> Gets the last N messages from this text channel. </summary> | |||
| /// <param name="limit"> The maximum number of messages to retrieve. </param> | |||
| Task<IEnumerable<Message>> GetMessages(int limit = 100); | |||
| Task<IEnumerable<Message>> GetMessages(int limit = DiscordConfig.MaxMessagesPerBatch); | |||
| /// <summary> Gets a collection of messages in this channel. </summary> | |||
| /// <param name="limit"> The maximum number of messages to retrieve. </param> | |||
| /// <param name="relativeMessageId"> The message to start downloading relative to. </param> | |||
| /// <param name="relativeDir"> The direction, from relativeMessageId, to download messages in. </param> | |||
| Task<IEnumerable<Message>> GetMessages(int limit = 100, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before); | |||
| Task<IEnumerable<Message>> GetMessages(int limit = DiscordConfig.MaxMessagesPerBatch, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before); | |||
| /// <summary> Sends a message to this text channel. </summary> | |||
| Task<Message> SendMessage(string text, bool isTTS = false); | |||
| @@ -1,8 +0,0 @@ | |||
| namespace Discord | |||
| { | |||
| public interface IVoiceChannel : IChannel | |||
| { | |||
| /// <summary> Gets the requested bitrate, in bits per second, of this voice channel. </summary> | |||
| int Bitrate { get; } | |||
| } | |||
| } | |||
| @@ -4,30 +4,32 @@ using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class PrivateChannel : ITextChannel, IPrivateChannel | |||
| public class PrivateChannel : ITextChannel, IChannel | |||
| { | |||
| /// <inheritdoc /> | |||
| public ulong Id { get; } | |||
| /// <inheritdoc /> | |||
| public DiscordClient Discord { get; } | |||
| /// <inheritdoc /> | |||
| public EntityState State { get; } | |||
| /// <inheritdoc /> | |||
| public ChannelType Type { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsPrivate => true; | |||
| public ulong Id { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsPublic => false; | |||
| public PrivateUser Recipient { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsText => true; | |||
| public PrivateUser CurrentUser { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsVoice => false; | |||
| ChannelType IChannel.Type => ChannelType.Private | ChannelType.Text; | |||
| /// <inheritdoc /> | |||
| public User Recipient { get; } | |||
| public string Name { get; } | |||
| /// <inheritdoc /> | |||
| public Task<IEnumerable<User>> GetUsers() => null; | |||
| public Task<PrivateUser> GetUser(ulong id) => null; | |||
| /// <inheritdoc /> | |||
| Task<IUser> IChannel.GetUser(ulong id) => null; | |||
| /// <inheritdoc /> | |||
| public Task<IEnumerable<PrivateUser>> GetUsers() => null; | |||
| /// <inheritdoc /> | |||
| Task<IEnumerable<IUser>> IChannel.GetUsers() => null; | |||
| /// <inheritdoc /> | |||
| public Task<Message> GetMessage(ulong id) => null; | |||
| /// <inheritdoc /> | |||
| @@ -5,7 +5,7 @@ using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class TextChannel : ITextChannel, IPublicChannel, IMentionable, IModifiable<TextChannel.Properties> | |||
| public class TextChannel : ITextChannel, IMentionable, IModifiable<TextChannel.Properties> | |||
| { | |||
| public sealed class Properties | |||
| { | |||
| @@ -14,22 +14,17 @@ namespace Discord | |||
| public int Position { get; } | |||
| } | |||
| /// <inheritdoc /> | |||
| public ulong Id { get; } | |||
| /// <inheritdoc /> | |||
| public DiscordClient Discord { get; } | |||
| /// <inheritdoc /> | |||
| public EntityState State { get; } | |||
| /// <inheritdoc /> | |||
| public ChannelType Type => ChannelType.Public | ChannelType.Text; | |||
| /// <inheritdoc /> | |||
| public bool IsPrivate => false; | |||
| public ulong Id { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsPublic => true; | |||
| public Server Server { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsText => true; | |||
| public DiscordClient Discord { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsVoice => false; | |||
| public ChannelType Type => ChannelType.Public | ChannelType.Text; | |||
| /// <inheritdoc /> | |||
| public string Name { get; } | |||
| @@ -37,21 +32,24 @@ namespace Discord | |||
| public string Topic { get; } | |||
| /// <inheritdoc /> | |||
| public int Position { get; } | |||
| /// <inheritdoc /> | |||
| public string Mention { get; } | |||
| /// <inheritdoc /> | |||
| public Server Server { get; } | |||
| /// <inheritdoc /> | |||
| public IEnumerable<PermissionOverwriteEntry> PermissionOverwrites { get; } | |||
| /// <inheritdoc /> | |||
| public IEnumerable<User> Users { get; } | |||
| /// <inheritdoc /> | |||
| public OverwritePermissions? GetPermissionOverwrite(User user) => null; | |||
| public OverwritePermissions? GetPermissionOverwrite(ServerUser user) => null; | |||
| /// <inheritdoc /> | |||
| public OverwritePermissions? GetPermissionOverwrite(Role role) => null; | |||
| /// <inheritdoc /> | |||
| public Task<IEnumerable<User>> GetUsers() => null; | |||
| public Task<ServerUser> GetUser(ulong id) => null; | |||
| /// <inheritdoc /> | |||
| Task<IUser> IChannel.GetUser(ulong id) => null; | |||
| /// <inheritdoc /> | |||
| public Task<IEnumerable<ServerUser>> GetUsers() => null; | |||
| /// <inheritdoc /> | |||
| Task<IEnumerable<IUser>> IChannel.GetUsers() => null; | |||
| /// <inheritdoc /> | |||
| public Task<Message> GetMessage(ulong id) => null; | |||
| /// <inheritdoc /> | |||
| @@ -62,11 +60,11 @@ namespace Discord | |||
| public Task<IEnumerable<Invite>> GetInvites() => null; | |||
| /// <inheritdoc /> | |||
| public Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions) => null; | |||
| public Task UpdatePermissionOverwrite(ServerUser user, OverwritePermissions permissions) => null; | |||
| /// <inheritdoc /> | |||
| public Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions) => null; | |||
| /// <inheritdoc /> | |||
| public Task RemovePermissionOverwrite(User user) => null; | |||
| public Task RemovePermissionOverwrite(ServerUser user) => null; | |||
| /// <inheritdoc /> | |||
| public Task RemovePermissionOverwrite(Role role) => null; | |||
| @@ -4,7 +4,7 @@ using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class VoiceChannel : IPublicChannel, IVoiceChannel, IModifiable<VoiceChannel.Properties> | |||
| public class VoiceChannel : IPublicChannel, IModifiable<VoiceChannel.Properties> | |||
| { | |||
| public sealed class Properties | |||
| { | |||
| @@ -16,19 +16,14 @@ namespace Discord | |||
| /// <inheritdoc /> | |||
| public ulong Id { get; } | |||
| /// <inheritdoc /> | |||
| public DiscordClient Discord { get; } | |||
| /// <inheritdoc /> | |||
| public EntityState State { get; } | |||
| /// <inheritdoc /> | |||
| public ChannelType Type { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsPrivate => false; | |||
| /// <inheritdoc /> | |||
| public bool IsPublic => true; | |||
| public Server Server { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsText => false; | |||
| public DiscordClient Discord { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsVoice => true; | |||
| ChannelType IChannel.Type => ChannelType.Public | ChannelType.Voice; | |||
| /// <inheritdoc /> | |||
| public string Name { get; } | |||
| @@ -36,26 +31,33 @@ namespace Discord | |||
| public int Position { get; } | |||
| /// <inheritdoc /> | |||
| public int Bitrate { get; } | |||
| /// <inheritdoc /> | |||
| public Server Server { get; } | |||
| public string Mention { get; } | |||
| /// <inheritdoc /> | |||
| public IEnumerable<PermissionOverwriteEntry> PermissionOverwrites { get; } | |||
| /// <inheritdoc /> | |||
| public OverwritePermissions? GetPermissionOverwrite(User user) => null; | |||
| public OverwritePermissions? GetPermissionOverwrite(ServerUser user) => null; | |||
| /// <inheritdoc /> | |||
| public OverwritePermissions? GetPermissionOverwrite(Role role) => null; | |||
| /// <inheritdoc /> | |||
| public Task<IEnumerable<User>> GetUsers() => null; | |||
| public Task<ServerUser> GetUser(ulong id) => null; | |||
| /// <inheritdoc /> | |||
| Task<IUser> IChannel.GetUser(ulong id) => null; | |||
| /// <inheritdoc /> | |||
| public Task<IEnumerable<ServerUser>> GetUsers() => null; | |||
| /// <inheritdoc /> | |||
| Task<IEnumerable<IUser>> IChannel.GetUsers() => null; | |||
| /// <inheritdoc /> | |||
| public Task<IEnumerable<Invite>> GetInvites() => null; | |||
| /// <inheritdoc /> | |||
| public Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions) => null; | |||
| public Task UpdatePermissionOverwrite(ServerUser user, OverwritePermissions permissions) => null; | |||
| /// <inheritdoc /> | |||
| public Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions) => null; | |||
| /// <inheritdoc /> | |||
| public Task RemovePermissionOverwrite(User user) => null; | |||
| public Task RemovePermissionOverwrite(ServerUser user) => null; | |||
| /// <inheritdoc /> | |||
| public Task RemovePermissionOverwrite(Role role) => null; | |||
| @@ -1,5 +1,4 @@ | |||
| using System; | |||
| using System.Threading.Tasks; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| @@ -1,49 +0,0 @@ | |||
| using System; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class Invite : IEntity<string> | |||
| { | |||
| 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<string>.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; | |||
| } | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class BasicInvite : IEntity<string> | |||
| { | |||
| 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<string>.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; | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -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<User> MentionedUsers { get; } | |||
| public IEnumerable<IPublicChannel> MentionedChannels { get; } | |||
| public IEnumerable<Role> MentionedRoles { get; } | |||
| public IReadOnlyList<ServerUser> MentionedUsers { get; } | |||
| public IReadOnlyList<IPublicChannel> MentionedChannels { get; } | |||
| public IReadOnlyList<Role> MentionedRoles { get; } | |||
| public Server Server => null; | |||
| public bool IsAuthor => false; | |||
| @@ -0,0 +1,9 @@ | |||
| namespace Discord | |||
| { | |||
| public struct PermissionOverwriteEntry | |||
| { | |||
| public PermissionTarget TargetType { get; } | |||
| public ulong TargetId { get; } | |||
| public OverwritePermissions Permissions { get; } | |||
| } | |||
| } | |||
| @@ -19,7 +19,7 @@ namespace Discord | |||
| public Color Color { get; } | |||
| public bool IsEveryone { get; } | |||
| public IEnumerable<User> Members { get; } | |||
| public IEnumerable<ServerUser> Members { get; } | |||
| public string Mention { get; } | |||
| @@ -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<IChannel> Channels { get; } | |||
| public IEnumerable<TextChannel> TextChannels { get; } | |||
| public IEnumerable<VoiceChannel> VoiceChannels { get; } | |||
| public IEnumerable<User> Users { get; } | |||
| public IEnumerable<ServerUser> Users { get; } | |||
| public IEnumerable<Role> 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<IEnumerable<User>> DownloadBans() => null; | |||
| public Task<IEnumerable<Invite>> DownloadInvites() => null; | |||
| public Task<IPublicChannel> GetChannel(ulong id) => null; | |||
| public Task<IPublicChannel> GetChannel(string mention) => null; | |||
| public Task<Role> GetRole(ulong id) => null; | |||
| public Task<ServerUser> GetUser(ulong id) => null; | |||
| public Task<ServerUser> GetUser(string name, ushort discriminator) => null; | |||
| public Task<ServerUser> GetUser(string mention) => null; | |||
| public Task<IEnumerable<ServerUser>> GetBans() => null; | |||
| public Task<IEnumerable<Invite>> GetInvites() => null; | |||
| public Task<TextChannel> CreateTextChannel(string name) => null; | |||
| public Task<VoiceChannel> CreateVoiceChannel(string name) => null; | |||
| @@ -1,55 +0,0 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class User : IEntity<ulong> | |||
| { | |||
| 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<Role> Roles => null; | |||
| public IEnumerable<IPublicChannel> Channels => null; | |||
| public ServerPermissions ServerPermissions => default(ServerPermissions); | |||
| public ChannelPermissions GetPermissions(IPublicChannel channel) => default(ChannelPermissions); | |||
| public Task<PrivateChannel> GetPrivateChannel() => null; | |||
| public Task<Message> SendMessage(string text) => null; | |||
| public Task<Message> SendFile(string filePath) => null; | |||
| public Task<Message> 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; | |||
| } | |||
| } | |||
| @@ -0,0 +1,19 @@ | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public interface IUser : IEntity<ulong>, 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<PrivateChannel> GetPrivateChannel(); | |||
| } | |||
| } | |||
| @@ -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 | |||
| { | |||
| /// <inheritdoc /> | |||
| public EntityState State { get; internal set; } | |||
| /// <inheritdoc /> | |||
| public ulong Id { get; } | |||
| /// <summary> Returns the private channel for this user. </summary> | |||
| public PrivateChannel Channel { get; } | |||
| /// <inheritdoc /> | |||
| bool IUser.IsPrivate => true; | |||
| /// <inheritdoc /> | |||
| public string Name { get; } | |||
| /// <inheritdoc /> | |||
| public ushort Discriminator { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsBot { get; } | |||
| /// <inheritdoc /> | |||
| public string AvatarId { get; } | |||
| /// <inheritdoc /> | |||
| public string CurrentGame { get; } | |||
| /// <inheritdoc /> | |||
| public UserStatus Status { get; } | |||
| /// <inheritdoc /> | |||
| public DiscordClient Discord => Channel.Discord; | |||
| /// <inheritdoc /> | |||
| public string AvatarUrl { get; } | |||
| /// <inheritdoc /> | |||
| public string Mention { get; } | |||
| /// <inheritdoc /> | |||
| Task<PrivateChannel> IUser.GetPrivateChannel() => Task.FromResult(Channel); | |||
| public Task Update() => null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,73 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Threading.Tasks; | |||
| namespace Discord | |||
| { | |||
| public class ServerUser : IUser | |||
| { | |||
| /// <inheritdoc /> | |||
| public EntityState State { get; } | |||
| /// <inheritdoc /> | |||
| public ulong Id { get; } | |||
| /// <summary> Returns the private channel for this user. </summary> | |||
| public Server Server { get; } | |||
| /// <inheritdoc /> | |||
| bool IUser.IsPrivate => false; | |||
| /// <inheritdoc /> | |||
| public string Name { get; } | |||
| /// <inheritdoc /> | |||
| public ushort Discriminator { get; } | |||
| /// <inheritdoc /> | |||
| public bool IsBot { get; } | |||
| /// <inheritdoc /> | |||
| public string AvatarId { get; } | |||
| /// <inheritdoc /> | |||
| public string CurrentGame { get; } | |||
| /// <inheritdoc /> | |||
| public UserStatus Status { get; } | |||
| /// <inheritdoc /> | |||
| public DateTime JoinedAt { get; } | |||
| /// <inheritdoc /> | |||
| public IReadOnlyList<Role> Roles { get; } | |||
| /// <summary> Returns true if this user has marked themselves as muted. </summary> | |||
| public bool IsSelfMuted { get; } | |||
| /// <summary> Returns true if this user has marked themselves as deafened. </summary> | |||
| public bool IsSelfDeafened { get; } | |||
| /// <summary> Returns true if the server is blocking audio from this user. </summary> | |||
| public bool IsServerMuted { get; } | |||
| /// <summary> Returns true if the server is blocking audio to this user. </summary> | |||
| public bool IsServerDeafened { get; } | |||
| /// <summary> Returns true if the server is temporarily blocking audio to/from this user. </summary> | |||
| public bool IsServerSuppressed { get; } | |||
| /// <summary> Gets this user's current voice channel. </summary> | |||
| public VoiceChannel VoiceChannel { get; } | |||
| /// <inheritdoc /> | |||
| public DiscordClient Discord { get; } | |||
| /// <inheritdoc /> | |||
| public string AvatarUrl { get; } | |||
| /// <inheritdoc /> | |||
| public string Mention { get; } | |||
| public ServerPermissions ServerPermissions { get; } | |||
| public ChannelPermissions GetPermissions(IPublicChannel channel) => default(ChannelPermissions); | |||
| /// <inheritdoc /> | |||
| public Task<PrivateChannel> GetPrivateChannel() => null; | |||
| public Task<IEnumerable<IPublicChannel>> 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; | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -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; | |||
| @@ -3,6 +3,6 @@ namespace Discord | |||
| { | |||
| public class UserEventArgs : EventArgs | |||
| { | |||
| public User User => null; | |||
| public IUser User => null; | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| using System.Collections.Generic; | |||
| using System.Threading; | |||
| namespace Discord.Net.Rest | |||
| { | |||
| public interface IRestClientProvider | |||
| { | |||
| IRestClient Create(string baseUrl, CancellationToken cancelToken); | |||
| } | |||
| } | |||
| @@ -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<DisconnectedEventArgs> Disconnected; | |||
| } | |||
| } | |||
| @@ -0,0 +1,9 @@ | |||
| using System.Threading; | |||
| namespace Discord.Net.WebSockets | |||
| { | |||
| public interface IWebSocketProvider | |||
| { | |||
| IWebSocket Create(CancellationToken cancelToken); | |||
| } | |||
| } | |||
| @@ -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<DisconnectedEventArgs> Disconnected = delegate { }; | |||
| public WebSocket(DiscordConfig config, ILogger logger) { } | |||
| public abstract void SendHeartbeat(); | |||
| public virtual void WaitForConnection(CancellationToken cancelToken) { } | |||
| } | |||
| } | |||