From 19e02e923df48a55bab0627447b7a6aa160dc521 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sun, 28 Feb 2016 04:48:32 -0400 Subject: [PATCH] Fixed several issues in ref entities --- ref/DiscordClient.Events.cs | 32 ------------------- ref/DiscordClient.cs | 28 ++++++++++++++-- ref/Entities/Channels/IPublicChannel.cs | 22 +++++++------ ref/Entities/Channels/PrivateChannel.cs | 14 ++++---- ref/Entities/Channels/TextChannel.cs | 22 ++++++------- ref/Entities/Channels/VoiceChannel.cs | 20 +++++------- ref/Entities/IEntity.cs | 6 ++-- ref/Entities/Invite.cs | 15 +++++---- ref/Entities/Message.cs | 14 ++++---- .../Permissions/ChannelPermissions.cs | 7 ++-- ...Permissions.cs => OverwritePermissions.cs} | 12 +++---- .../Permissions/PermissionOverwrite.cs | 9 ------ ref/Entities/Permissions/ServerPermissions.cs | 2 +- ref/Entities/Profile.cs | 12 ++++--- ref/Entities/Region.cs | 9 ------ ref/Entities/Role.cs | 10 +++--- ref/Entities/Server.cs | 19 +++++------ ref/Entities/User.cs | 32 ++++++++----------- ref/Enums/EntityState.cs | 18 +++++++++++ ref/Enums/LogSeverity.cs | 1 + ref/Enums/ModelState.cs | 18 ----------- ref/Enums/PermissionBits.cs | 31 ------------------ ref/Events/ChannelEventArgs.cs | 3 +- ref/Events/ChannelUpdatedEventArgs.cs | 1 - ref/Events/MessageEventArgs.cs | 3 +- ref/Events/MessageUpdatedEventArgs.cs | 3 +- ref/Events/UserEventArgs.cs | 1 - ref/Events/UserUpdatedEventArgs.cs | 1 - ref/Net/WebSockets/WebSocketEventEventArgs.cs | 6 ---- 29 files changed, 146 insertions(+), 225 deletions(-) delete mode 100644 ref/DiscordClient.Events.cs rename ref/Entities/Permissions/{TriStateChannelPermissions.cs => OverwritePermissions.cs} (81%) delete mode 100644 ref/Entities/Permissions/PermissionOverwrite.cs create mode 100644 ref/Enums/EntityState.cs delete mode 100644 ref/Enums/ModelState.cs delete mode 100644 ref/Enums/PermissionBits.cs diff --git a/ref/DiscordClient.Events.cs b/ref/DiscordClient.Events.cs deleted file mode 100644 index 888ba5c99..000000000 --- a/ref/DiscordClient.Events.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; - -namespace Discord -{ - public partial class DiscordClient - { - public event EventHandler Ready = delegate { }; - public event EventHandler ChannelCreated = delegate { }; - public event EventHandler ChannelDestroyed = delegate { }; - public event EventHandler ChannelUpdated = delegate { }; - public event EventHandler MessageAcknowledged = delegate { }; - public event EventHandler MessageDeleted = delegate { }; - public event EventHandler MessageReceived = delegate { }; - public event EventHandler MessageSent = delegate { }; - public event EventHandler MessageUpdated = delegate { }; - public event EventHandler ProfileUpdated = delegate { }; - public event EventHandler RoleCreated = delegate { }; - public event EventHandler RoleUpdated = delegate { }; - public event EventHandler RoleDeleted = delegate { }; - public event EventHandler JoinedServer = delegate { }; - public event EventHandler LeftServer = delegate { }; - public event EventHandler ServerAvailable = delegate { }; - public event EventHandler ServerUpdated = delegate { }; - public event EventHandler ServerUnavailable = delegate { }; - public event EventHandler UserBanned = delegate { }; - public event EventHandler UserIsTyping = delegate { }; - public event EventHandler UserJoined = delegate { }; - public event EventHandler UserLeft = delegate { }; - public event EventHandler UserUpdated = delegate { }; - public event EventHandler UserUnbanned = delegate { }; - } -} diff --git a/ref/DiscordClient.cs b/ref/DiscordClient.cs index 166f17268..027383ae7 100644 --- a/ref/DiscordClient.cs +++ b/ref/DiscordClient.cs @@ -5,15 +5,39 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; -using System.Net; using System.Threading; using System.Threading.Tasks; namespace Discord { /// Provides a connection to the DiscordApp service. - public partial class DiscordClient : IDisposable + public class DiscordClient : IDisposable { + public event EventHandler Ready = delegate { }; + public event EventHandler ChannelCreated = delegate { }; + public event EventHandler ChannelUpdated = delegate { }; + public event EventHandler ChannelDestroyed = delegate { }; + public event EventHandler MessageAcknowledged = delegate { }; + public event EventHandler MessageDeleted = delegate { }; + public event EventHandler MessageReceived = delegate { }; + public event EventHandler MessageSent = delegate { }; + public event EventHandler MessageUpdated = delegate { }; + public event EventHandler ProfileUpdated = delegate { }; + public event EventHandler RoleCreated = delegate { }; + public event EventHandler RoleUpdated = delegate { }; + public event EventHandler RoleDeleted = delegate { }; + public event EventHandler JoinedServer = delegate { }; + public event EventHandler LeftServer = delegate { }; + public event EventHandler ServerAvailable = delegate { }; + public event EventHandler ServerUpdated = delegate { }; + public event EventHandler ServerUnavailable = delegate { }; + public event EventHandler UserBanned = delegate { }; + public event EventHandler UserIsTyping = delegate { }; + public event EventHandler UserJoined = delegate { }; + public event EventHandler UserLeft = delegate { }; + public event EventHandler UserUpdated = delegate { }; + public event EventHandler UserUnbanned = delegate { }; + public DiscordConfig Config { get; } public RestClient ClientAPI { get; } public RestClient StatusAPI { get; } diff --git a/ref/Entities/Channels/IPublicChannel.cs b/ref/Entities/Channels/IPublicChannel.cs index f0e868bc7..91a05d861 100644 --- a/ref/Entities/Channels/IPublicChannel.cs +++ b/ref/Entities/Channels/IPublicChannel.cs @@ -3,32 +3,34 @@ 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; } + 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; } + int Position { get; } /// Gets the permission overwrite for a specific user, or null if one does not exist. - PermissionOverwrite? GetPermissionOverwrite(User user); + OverwritePermissions? GetPermissionOverwrite(User user); /// Gets the permission overwrite for a specific role, or null if one does not exist. - PermissionOverwrite? GetPermissionOverwrite(Role role); + 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, ChannelPermissions allow, ChannelPermissions deny); - /// Adds or updates the permission overwrite for the given user. - Task UpdatePermissionOverwrite(User user, TriStateChannelPermissions permissions); - /// Adds or updates the permission overwrite for the given role. - Task UpdatePermissionOverwrite(Role role, ChannelPermissions allow, ChannelPermissions deny); + Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions); /// Adds or updates the permission overwrite for the given role. - Task UpdatePermissionOverwrite(Role role, TriStateChannelPermissions permissions); + Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions); /// Removes the permission overwrite for the given user, if one exists. Task RemovePermissionOverwrite(User user); /// Removes the permission overwrite for the given role, if one exists. diff --git a/ref/Entities/Channels/PrivateChannel.cs b/ref/Entities/Channels/PrivateChannel.cs index 4d21f3902..6364bf884 100644 --- a/ref/Entities/Channels/PrivateChannel.cs +++ b/ref/Entities/Channels/PrivateChannel.cs @@ -11,7 +11,7 @@ namespace Discord /// public DiscordClient Discord { get; } /// - public ModelState State { get; } + public EntityState State { get; } /// public ChannelType Type { get; } /// @@ -22,14 +22,12 @@ namespace Discord public bool IsText => true; /// public bool IsVoice => false; - - /// - public Server Server { get; } + /// public User Recipient { get; } /// - public Task> GetUsers(); + public Task> GetUsers() => null; /// public Task GetMessage(ulong id) => null; /// @@ -46,10 +44,10 @@ namespace Discord /// public Task SendIsTyping() => null; - - /// - public Task Delete() => null; + /// public Task Update() => null; + /// + public Task Delete() => null; } } diff --git a/ref/Entities/Channels/TextChannel.cs b/ref/Entities/Channels/TextChannel.cs index 8596d73f8..2d977111c 100644 --- a/ref/Entities/Channels/TextChannel.cs +++ b/ref/Entities/Channels/TextChannel.cs @@ -19,7 +19,7 @@ namespace Discord /// public DiscordClient Discord { get; } /// - public ModelState State { get; } + public EntityState State { get; } /// public ChannelType Type => ChannelType.Public | ChannelType.Text; /// @@ -42,14 +42,14 @@ namespace Discord /// public Server Server { get; } /// - public IEnumerable PermissionOverwrites { get; } + public IEnumerable PermissionOverwrites { get; } /// public IEnumerable Users { get; } /// - public PermissionOverwrite? GetPermissionOverwrite(User user) => null; + public OverwritePermissions? GetPermissionOverwrite(User user) => null; /// - public PermissionOverwrite? GetPermissionOverwrite(Role role) => null; + public OverwritePermissions? GetPermissionOverwrite(Role role) => null; /// public Task> GetUsers() => null; /// @@ -60,15 +60,11 @@ namespace Discord public Task> GetMessages(int limit = 100, ulong? relativeMessageId = null, Relative relativeDir = Relative.Before) => null; /// public Task> GetInvites() => null; - - /// - public Task UpdatePermissionOverwrite(User user, ChannelPermissions allow, ChannelPermissions deny) => null; + /// - public Task UpdatePermissionOverwrite(User user, TriStateChannelPermissions permissions) => null; + public Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions) => null; /// - public Task UpdatePermissionOverwrite(Role role, ChannelPermissions allow, ChannelPermissions deny) => null; - /// - public Task UpdatePermissionOverwrite(Role role, TriStateChannelPermissions permissions) => null; + public Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions) => null; /// public Task RemovePermissionOverwrite(User user) => null; /// @@ -87,11 +83,11 @@ namespace Discord /// public Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool tempMembership = false, bool withXkcd = false) => null; - /// - public Task Delete() => null; /// public Task Update() => null; /// public Task Modify(Action func) => null; + /// + public Task Delete() => null; } } diff --git a/ref/Entities/Channels/VoiceChannel.cs b/ref/Entities/Channels/VoiceChannel.cs index 6a6232a9d..100569c71 100644 --- a/ref/Entities/Channels/VoiceChannel.cs +++ b/ref/Entities/Channels/VoiceChannel.cs @@ -18,7 +18,7 @@ namespace Discord /// public DiscordClient Discord { get; } /// - public ModelState State { get; } + public EntityState State { get; } /// public ChannelType Type { get; } /// @@ -39,25 +39,21 @@ namespace Discord /// public Server Server { get; } /// - public IEnumerable PermissionOverwrites { get; } + public IEnumerable PermissionOverwrites { get; } /// - public PermissionOverwrite? GetPermissionOverwrite(User user) => null; + public OverwritePermissions? GetPermissionOverwrite(User user) => null; /// - public PermissionOverwrite? GetPermissionOverwrite(Role role) => null; + public OverwritePermissions? GetPermissionOverwrite(Role role) => null; /// public Task> GetUsers() => null; /// public Task> GetInvites() => null; /// - public Task UpdatePermissionOverwrite(User user, ChannelPermissions allow, ChannelPermissions deny) => null; + public Task UpdatePermissionOverwrite(User user, OverwritePermissions permissions) => null; /// - public Task UpdatePermissionOverwrite(User user, TriStateChannelPermissions permissions) => null; - /// - public Task UpdatePermissionOverwrite(Role role, ChannelPermissions allow, ChannelPermissions deny) => null; - /// - public Task UpdatePermissionOverwrite(Role role, TriStateChannelPermissions permissions) => null; + public Task UpdatePermissionOverwrite(Role role, OverwritePermissions permissions) => null; /// public Task RemovePermissionOverwrite(User user) => null; /// @@ -66,11 +62,11 @@ namespace Discord /// public Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool tempMembership = false, bool withXkcd = false) => null; - /// - public Task Delete() => null; /// public Task Update() => null; /// public Task Modify(Action func) => null; + /// + public Task Delete() => null; } } diff --git a/ref/Entities/IEntity.cs b/ref/Entities/IEntity.cs index eb30ddd55..ddd791d74 100644 --- a/ref/Entities/IEntity.cs +++ b/ref/Entities/IEntity.cs @@ -13,10 +13,8 @@ namespace Discord /// Gets the DiscordClient that manages this object. DiscordClient Discord { get; } /// Gets the state of this object. - ModelState State { get; } - - /// Deletes this object. - Task Delete(); + EntityState State { get; } + /// Downloads the latest values and updates this object. Task Update(); } diff --git a/ref/Entities/Invite.cs b/ref/Entities/Invite.cs index 041ef2e97..1e6da77dc 100644 --- a/ref/Entities/Invite.cs +++ b/ref/Entities/Invite.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; namespace Discord { - public class Invite : IModel + public class Invite : IEntity { public class ServerInfo { @@ -23,10 +23,11 @@ namespace Discord public string AvatarId { get; } public string AvatarUrl { get; } } - - public DiscordClient Client { get; } - string IModel.Id => Code; + string IEntity.Id => Code; + public DiscordClient Discord { get; } + public EntityState State { get; } + public string Code { get; } public string XkcdCode { get; } @@ -40,9 +41,9 @@ namespace Discord public DateTime CreatedAt { get; } public string Url { get; } - public Task Delete() => null; public Task Accept() => null; - public Task Save() => null; - } + public Task Update() => null; + public Task Delete() => null; + } } diff --git a/ref/Entities/Message.cs b/ref/Entities/Message.cs index ca019da3f..617446dad 100644 --- a/ref/Entities/Message.cs +++ b/ref/Entities/Message.cs @@ -38,13 +38,14 @@ namespace Discord public int? Width { get; } public int? Height { get; } } - - public DiscordClient Client { get; } + public ulong Id { get; } + public DiscordClient Discord { get; } + public EntityState State { get; } + public ITextChannel Channel { get; } public User User { get; } public bool IsTTS { get; } - public MessageState State { get; } public string RawText { get; } public string Text { get; } public DateTime Timestamp { get; } @@ -59,10 +60,9 @@ namespace Discord public Server Server => null; public bool IsAuthor => false; - public Task Delete() => null; - - public Task Save() => null; - public bool IsMentioningMe(bool includeRoles = false) => false; + + public Task Update() => null; + public Task Delete() => null; } } diff --git a/ref/Entities/Permissions/ChannelPermissions.cs b/ref/Entities/Permissions/ChannelPermissions.cs index 9a4248923..d01f0430e 100644 --- a/ref/Entities/Permissions/ChannelPermissions.cs +++ b/ref/Entities/Permissions/ChannelPermissions.cs @@ -6,12 +6,11 @@ public static ChannelPermissions TextOnly { get; } public static ChannelPermissions PrivateOnly { get; } public static ChannelPermissions VoiceOnly { get; } - public static ChannelPermissions All(Channel channel) => default(ChannelPermissions); - public static ChannelPermissions All(ChannelType channelType, bool isPrivate) => default(ChannelPermissions); + public static ChannelPermissions All(ChannelType channelType) => default(ChannelPermissions); public uint RawValue { get; } - public bool CreateInstantInvit { get; } + public bool CreateInstantInvite { get; } public bool ManagePermission { get; } public bool ManageChannel { get; } @@ -44,7 +43,7 @@ { } - public ChannelPermissions Modify(ChannelPermissions basePerms, bool? createInstantInvite = null, bool? managePermissions = null, + public ChannelPermissions Modify(bool? createInstantInvite = null, bool? managePermissions = null, bool? manageChannel = null, bool? readMessages = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, diff --git a/ref/Entities/Permissions/TriStateChannelPermissions.cs b/ref/Entities/Permissions/OverwritePermissions.cs similarity index 81% rename from ref/Entities/Permissions/TriStateChannelPermissions.cs rename to ref/Entities/Permissions/OverwritePermissions.cs index 7a26bd185..1cda173ec 100644 --- a/ref/Entities/Permissions/TriStateChannelPermissions.cs +++ b/ref/Entities/Permissions/OverwritePermissions.cs @@ -1,8 +1,8 @@ namespace Discord { - public struct TriStateChannelPermissions + public struct OverwritePermissions { - public static TriStateChannelPermissions InheritAll { get; } + public static OverwritePermissions InheritAll { get; } public uint AllowValue { get; } public uint DenyValue { get; } @@ -26,7 +26,7 @@ public PermValue MoveMembers { get; } public PermValue UseVoiceActivation { get; } - public TriStateChannelPermissions(PermValue? createInstantInvite = null, PermValue? managePermissions = null, + public OverwritePermissions(PermValue? createInstantInvite = null, PermValue? managePermissions = null, PermValue? manageChannel = null, PermValue? readMessages = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, PermValue? manageMessages = null, PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, PermValue? mentionEveryone = null, PermValue? connect = null, PermValue? speak = null, PermValue? muteMembers = null, PermValue? deafenMembers = null, @@ -35,16 +35,16 @@ { } - public TriStateChannelPermissions(uint allow = 0, uint deny = 0) + public OverwritePermissions(uint allow = 0, uint deny = 0) : this() { } - public TriStateChannelPermissions Modify(PermValue? createInstantInvite = null, PermValue? managePermissions = null, + public OverwritePermissions Modify(PermValue? createInstantInvite = null, PermValue? managePermissions = null, PermValue? manageChannel = null, PermValue? readMessages = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, PermValue? manageMessages = null, PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, PermValue? mentionEveryone = null, PermValue? connect = null, PermValue? speak = null, PermValue? muteMembers = null, PermValue? deafenMembers = null, PermValue? moveMembers = null, PermValue? useVoiceActivation = null) - => default(TriStateChannelPermissions); + => default(OverwritePermissions); } } diff --git a/ref/Entities/Permissions/PermissionOverwrite.cs b/ref/Entities/Permissions/PermissionOverwrite.cs deleted file mode 100644 index 94658160a..000000000 --- a/ref/Entities/Permissions/PermissionOverwrite.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Discord -{ - public struct PermissionOverwrite - { - public PermissionTarget TargetType { get; } - public ulong TargetId { get; } - public TriStateChannelPermissions Permissions { get; } - } -} diff --git a/ref/Entities/Permissions/ServerPermissions.cs b/ref/Entities/Permissions/ServerPermissions.cs index 67f208b97..fe85c07dd 100644 --- a/ref/Entities/Permissions/ServerPermissions.cs +++ b/ref/Entities/Permissions/ServerPermissions.cs @@ -44,7 +44,7 @@ { } - public ServerPermissions Modify(ServerPermissions basePerms, bool? createInstantInvite = null, bool? manageRoles = null, + public ServerPermissions Modify(bool? createInstantInvite = null, bool? manageRoles = null, bool? kickMembers = null, bool? banMembers = null, bool? manageChannel = null, bool? manageServer = null, bool? readMessages = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, diff --git a/ref/Entities/Profile.cs b/ref/Entities/Profile.cs index 73965de65..aa61e51b2 100644 --- a/ref/Entities/Profile.cs +++ b/ref/Entities/Profile.cs @@ -3,10 +3,11 @@ namespace Discord { public class Profile : IEntity - { - public DiscordClient Client { get; } - + { public ulong Id { get; } + public DiscordClient Discord { get; } + public EntityState State { get; } + public string AvatarId { get; } public string AvatarUrl { get; } public ushort Discriminator { get; } @@ -16,8 +17,9 @@ namespace Discord public string Email { get; } public bool? IsVerified { get; } - public string Name { get; set; } + public string Name { get; set; } - public Task Save() => null; + public Task Update() => null; + public Task Delete() => null; } } diff --git a/ref/Entities/Region.cs b/ref/Entities/Region.cs index 5b0354048..fbb801eaa 100644 --- a/ref/Entities/Region.cs +++ b/ref/Entities/Region.cs @@ -7,14 +7,5 @@ public string Hostname { get; } public int Port { get; } public bool Vip { get; } - - internal Region(string id, string name, string hostname, int port, bool vip) - { - Id = id; - Name = name; - Hostname = hostname; - Port = port; - Vip = vip; - } } } diff --git a/ref/Entities/Role.cs b/ref/Entities/Role.cs index b9e35dc46..92edb7bd2 100644 --- a/ref/Entities/Role.cs +++ b/ref/Entities/Role.cs @@ -5,9 +5,10 @@ namespace Discord { public class Role : IEntity, IMentionable { - public DiscordClient Client { get; } - public ulong Id { get; } + public DiscordClient Discord { get; } + public EntityState State { get; } + public Server Server { get; } public string Name { get; } @@ -21,9 +22,8 @@ namespace Discord public IEnumerable Members { get; } public string Mention { get; } - - public Task Delete() => null; - public Task Save() => null; + public Task Update() => null; + public Task Delete() => null; } } diff --git a/ref/Entities/Server.cs b/ref/Entities/Server.cs index 0a81d8737..04838b6d5 100644 --- a/ref/Entities/Server.cs +++ b/ref/Entities/Server.cs @@ -16,6 +16,9 @@ namespace Discord } public ulong Id { get; } + public DiscordClient Discord { get; } + public EntityState State { get; } + public User CurrentUser { get; } public string IconId { get; } public string SplashId { get; } @@ -50,11 +53,8 @@ namespace Discord public Task> DownloadBans() => null; public Task> DownloadInvites() => null; - public Task Leave() => null; - public Task Delete() => null; - public Task Save() => null; - - public Task CreateChannel(string name, ChannelType type) => null; + public Task CreateTextChannel(string name) => null; + public Task CreateVoiceChannel(string name) => null; public Task CreateInvite(int? maxAge = 1800, int? maxUses = null, bool tempMembership = false, bool withXkcd = false) => null; public Task CreateRole(string name, ServerPermissions? permissions = null, Color color = null, bool isHoisted = false) => null; @@ -62,9 +62,10 @@ namespace Discord public Task Unban(User user) => null; public Task Unban(ulong userId) => null; - public Task ReorderChannels(IEnumerable channels) => null; - public Task ReorderRoles(IEnumerable roles, Role after = null) => null; - public Task PruneUsers(int days = 30, bool simulate = false) => null; - } + + public Task Update() => null; + public Task Leave() => null; + public Task Delete() => null; + } } diff --git a/ref/Entities/User.cs b/ref/Entities/User.cs index 4bef43605..94ae357fd 100644 --- a/ref/Entities/User.cs +++ b/ref/Entities/User.cs @@ -5,13 +5,13 @@ using System.Threading.Tasks; namespace Discord { - public class User : IModel - { - public DiscordClient Client { get; } - + public class User : IEntity + { public ulong Id { get; } - public Server Server { 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; } @@ -20,7 +20,6 @@ namespace Discord public DateTime JoinedAt { get; } public DateTime? LastActivityAt { get; } - public Channel PrivateChannel => null; public string Mention => null; public bool IsSelfMuted => false; public bool IsSelfDeafened => false; @@ -28,18 +27,14 @@ namespace Discord public bool IsServerDeafened => false; public bool IsServerSuppressed => false; public DateTime? LastOnlineAt => null; - public Channel VoiceChannel => null; + public VoiceChannel VoiceChannel => null; public string AvatarUrl => null; - public IEnumerable Roles => null; - - public IEnumerable Channels => null; - - public Task Kick() => null; - + public IEnumerable Roles => null; + public IEnumerable Channels => null; public ServerPermissions ServerPermissions => default(ServerPermissions); - public ChannelPermissions GetPermissions(Channel channel) => default(ChannelPermissions); - - public Task CreatePMChannel() => null; + + public ChannelPermissions GetPermissions(IPublicChannel channel) => default(ChannelPermissions); + public Task GetPrivateChannel() => null; public Task SendMessage(string text) => null; public Task SendFile(string filePath) => null; @@ -50,6 +45,7 @@ namespace Discord public Task AddRoles(params Role[] roles) => null; public Task RemoveRoles(params Role[] roles) => null; - public Task Save() => null; + public Task Update() => null; + public Task Kick() => null; } } \ No newline at end of file diff --git a/ref/Enums/EntityState.cs b/ref/Enums/EntityState.cs new file mode 100644 index 000000000..6ae71e4a3 --- /dev/null +++ b/ref/Enums/EntityState.cs @@ -0,0 +1,18 @@ +namespace Discord +{ + public enum EntityState : byte + { + /// Object is not attached to a cache manager nor receiving live updates. + Detached = 0, + /// Object is attached to a cache manager and receiving live updates. + Attached, + /// Object was deleted. + Deleted, + /// Object is currently waiting to be created. + Queued, + /// Object's creation was aborted. + Aborted, + /// Object's creation failed. + Failed + } +} diff --git a/ref/Enums/LogSeverity.cs b/ref/Enums/LogSeverity.cs index 879aecd09..785b0ef46 100644 --- a/ref/Enums/LogSeverity.cs +++ b/ref/Enums/LogSeverity.cs @@ -2,6 +2,7 @@ { public enum LogSeverity { + Critical = 0, Error = 1, Warning = 2, Info = 3, diff --git a/ref/Enums/ModelState.cs b/ref/Enums/ModelState.cs deleted file mode 100644 index a4477e94d..000000000 --- a/ref/Enums/ModelState.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Discord -{ - public enum ModelState : byte - { - /// Message did not originate from this session, or was successfully sent. - Normal = 0, - /// Message is current queued. - Queued, - /// Message was deleted. - Deleted, - /// Message was deleted before it was sent. - Aborted, - /// Message failed to be sent. - Failed, - /// Message has been removed from cache and will no longer receive updates. - Detached - } -} diff --git a/ref/Enums/PermissionBits.cs b/ref/Enums/PermissionBits.cs deleted file mode 100644 index b5acab73f..000000000 --- a/ref/Enums/PermissionBits.cs +++ /dev/null @@ -1,31 +0,0 @@ -namespace Discord -{ - internal enum PermissionBits - { - //General - CreateInstantInvite = 0, - KickMembers = 1, - BanMembers = 2, - ManageRolesOrPermissions = 3, - ManageChannel = 4, - ManageServer = 5, - - //Text - ReadMessages = 10, - SendMessages = 11, - SendTTSMessages = 12, - ManageMessages = 13, - EmbedLinks = 14, - AttachFiles = 15, - ReadMessageHistory = 16, - MentionEveryone = 17, - - //Voice - Connect = 20, - Speak = 21, - MuteMembers = 22, - DeafenMembers = 23, - MoveMembers = 24, - UseVoiceActivation = 25 - } -} diff --git a/ref/Events/ChannelEventArgs.cs b/ref/Events/ChannelEventArgs.cs index cafdf2fa7..583075e08 100644 --- a/ref/Events/ChannelEventArgs.cs +++ b/ref/Events/ChannelEventArgs.cs @@ -4,7 +4,6 @@ namespace Discord { public class ChannelEventArgs : EventArgs { - public Channel Channel => null; - public Server Server => null; + public IChannel Channel => null; } } diff --git a/ref/Events/ChannelUpdatedEventArgs.cs b/ref/Events/ChannelUpdatedEventArgs.cs index eee390f37..bcd809521 100644 --- a/ref/Events/ChannelUpdatedEventArgs.cs +++ b/ref/Events/ChannelUpdatedEventArgs.cs @@ -6,6 +6,5 @@ namespace Discord { public IChannel Before => null; public IChannel After => null; - public Server Server => null; } } diff --git a/ref/Events/MessageEventArgs.cs b/ref/Events/MessageEventArgs.cs index 98eeb4f9d..5b251fa9d 100644 --- a/ref/Events/MessageEventArgs.cs +++ b/ref/Events/MessageEventArgs.cs @@ -6,7 +6,6 @@ namespace Discord { public Message Message => null; public User User => null; - public Channel Channel => null; - public Server Server => null; + public ITextChannel Channel => null; } } diff --git a/ref/Events/MessageUpdatedEventArgs.cs b/ref/Events/MessageUpdatedEventArgs.cs index d529907a4..3205721f3 100644 --- a/ref/Events/MessageUpdatedEventArgs.cs +++ b/ref/Events/MessageUpdatedEventArgs.cs @@ -7,7 +7,6 @@ namespace Discord public Message Before => null; public Message After => null; public User User => null; - public Channel Channel => null; - public Server Server => null; + public ITextChannel Channel => null; } } diff --git a/ref/Events/UserEventArgs.cs b/ref/Events/UserEventArgs.cs index 4ff745307..6f638c915 100644 --- a/ref/Events/UserEventArgs.cs +++ b/ref/Events/UserEventArgs.cs @@ -4,6 +4,5 @@ namespace Discord public class UserEventArgs : EventArgs { public User User => null; - public Server Server => null; } } diff --git a/ref/Events/UserUpdatedEventArgs.cs b/ref/Events/UserUpdatedEventArgs.cs index c5b2b0acd..6fb5fa2c3 100644 --- a/ref/Events/UserUpdatedEventArgs.cs +++ b/ref/Events/UserUpdatedEventArgs.cs @@ -5,6 +5,5 @@ namespace Discord { public User Before => null; public User After => null; - public Server Server => null; } } diff --git a/ref/Net/WebSockets/WebSocketEventEventArgs.cs b/ref/Net/WebSockets/WebSocketEventEventArgs.cs index a0c60edcf..676c0ba6e 100644 --- a/ref/Net/WebSockets/WebSocketEventEventArgs.cs +++ b/ref/Net/WebSockets/WebSocketEventEventArgs.cs @@ -7,11 +7,5 @@ namespace Discord.Net.WebSockets { public string Type { get; } public JToken Payload { get; } - - internal WebSocketEventEventArgs(string type, JToken data) - { - Type = type; - Payload = data; - } } }