diff --git a/Maki/BaseManager.cs b/Maki/BaseManager.cs index 3d76617..b18cce9 100644 --- a/Maki/BaseManager.cs +++ b/Maki/BaseManager.cs @@ -21,10 +21,7 @@ namespace Maki => Dispose(false); public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + => Dispose(true); protected void Dispose(bool disposing) { @@ -34,6 +31,9 @@ namespace Maki IsDisposed = true; Collection.ToList().ForEach(x => Remove(x)); Collection.Clear(); + + if (disposing) + GC.SuppressFinalize(this); } public virtual void Add(T item) diff --git a/Maki/Discord.cs b/Maki/Discord.cs index 4c4d5a6..9e09c46 100644 --- a/Maki/Discord.cs +++ b/Maki/Discord.cs @@ -896,7 +896,7 @@ namespace Maki UserManager.Dispose(); if (disposing) - GC.SuppressFinalize(true); + GC.SuppressFinalize(this); } ~Discord() diff --git a/Maki/DiscordPermission.cs b/Maki/DiscordPermission.cs index c9065e4..3bb154e 100644 --- a/Maki/DiscordPermission.cs +++ b/Maki/DiscordPermission.cs @@ -6,171 +6,151 @@ namespace Maki /// Discord Permission Flags /// [Flags] - public enum DiscordPermission + public enum DiscordPermission : long { /// /// Allows creation of instant invites /// - CreateInstantInvite = 1, + CreateInstantInvite = 0x1, /// /// Allows kicking members /// - KickMembers = 1 << 1, + KickMembers = 0x2, /// /// Allows banning members /// - BanMembers = 1 << 2, + BanMembers = 0x4, /// /// Allows all permissions and bypasses channel permission overwrites /// - Administrator = 1 << 3, + Administrator = 0x8, /// /// Allows management and editing of channels /// - ManageChannels = 1 << 4, + ManageChannels = 0x10, /// /// Allows management and editing of the guild /// - ManageGuild = 1 << 5, + ManageGuild = 0x20, /// /// Allows for the addition of reactions to messages /// - AddReactions = 1 << 6, + AddReactions = 0x40, /// /// Allows viewing the audit log /// - ViewAuditLog = 1 << 7, + ViewAuditLog = 0x80, /// /// Allows reading messages in a channel. The channel will not appear for users without this permission /// - ReadMessages = 1 << 10, + ReadMessages = 0x400, /// /// Allows for sending messages in a channel. /// - SendMessages = 1 << 11, + SendMessages = 0x800, /// /// Allows for sending of /tts messages /// - SendTTSMessages = 1 << 12, + SendTTSMessages = 0x1000, /// /// Allows for deletion of other users messages /// - ManageMessages = 1 << 13, + ManageMessages = 0x2000, /// /// Links sent by this user will be auto-embedded /// - EmbedLinks = 1 << 14, + EmbedLinks = 0x4000, /// /// Allows for uploading images and files /// - AttachFiles = 1 << 15, + AttachFiles = 0x8000, /// /// Allows for reading of message history /// - ReadMessageHistory = 1 << 16, + ReadMessageHistory = 0x10000, /// /// Allows for using the @everyone tag to notify all users in a channel, and the @here tag to notify all online users in a channel /// - MentionEveryone = 1 << 17, + MentionEveryone = 0x20000, /// /// Allows the usage of custom emojis from other servers /// - ExternalEmojis = 1 << 18, + ExternalEmojis = 0x40000, /// /// Allows for joining of a voice channel /// - VoiceConnect = 1 << 20, + VoiceConnect = 0x100000, /// /// Allows for speaking in a voice channel /// - VoiceSpeak = 1 << 21, + VoiceSpeak = 0x200000, /// /// Allows for muting members in a voice channel /// - VoiceMuteMembers = 1 << 22, + VoiceMuteMembers = 0x400000, /// /// Allows for deafening of members in a voice channel /// - VoiceDeafenMembers = 1 << 23, + VoiceDeafenMembers = 0x800000, /// /// Allows for moving of members between voice channels /// - VoiceMoveMembers = 1 << 24, + VoiceMoveMembers = 0x1000000, /// /// Allows for using voice-activity-detection in a voice channel /// - VoiceUseVAD = 1 << 25, + VoiceUseVAD = 0x2000000, /// /// Allows for modification of own nickname /// - ChangeNickname = 1 << 26, + ChangeNickname = 0x4000000, /// /// Allows for modification of other users nicknames /// - ManageNicknames = 1 << 27, + ManageNicknames = 0x8000000, /// /// Allows management and editing of roles /// - ManageRoles = 1 << 28, + ManageRoles = 0x10000000, /// /// Allows management and editing of webhooks /// - ManageWebhooks = 1 << 29, + ManageWebhooks = 0x20000000, /// /// Allows management and editing of emojis /// - ManageEmojis = 1 << 30, + ManageEmojis = 0x40000000, /// /// Blank permissions /// None = 0, - - /// - /// All Guild related permissions - /// - AllGuild = CreateInstantInvite | KickMembers | BanMembers | Administrator | ManageChannels | ManageGuild | AddReactions | ViewAuditLog | ChangeNickname | ManageNicknames | ManageRoles | ManageWebhooks | ManageEmojis, - - /// - /// All text channel permissions - /// - AllText = CreateInstantInvite | ManageChannels | ViewAuditLog | ReadMessages | SendMessages | SendTTSMessages | ManageMessages | EmbedLinks | AttachFiles | ReadMessageHistory | MentionEveryone | ExternalEmojis | ManageRoles | ManageWebhooks | ManageEmojis, - - /// - /// All voice channel permissions - /// - AllVoice = CreateInstantInvite | ManageChannels | ViewAuditLog | VoiceConnect | VoiceSpeak | VoiceMuteMembers | VoiceDeafenMembers | VoiceMoveMembers | VoiceUseVAD | ManageRoles, - - /// - /// All permissions - /// - All = CreateInstantInvite | KickMembers | BanMembers | Administrator | ManageChannels | ManageGuild | AddReactions | ViewAuditLog | ReadMessages | SendMessages | SendTTSMessages | ManageMessages | EmbedLinks | AttachFiles | ReadMessageHistory | MentionEveryone | ExternalEmojis | VoiceConnect | VoiceSpeak | VoiceMuteMembers | VoiceDeafenMembers | VoiceMoveMembers | VoiceUseVAD | ChangeNickname | ManageNicknames | ManageRoles | ManageWebhooks | ManageEmojis, } } diff --git a/Maki/Gateway/GatewayHeartbeatManager.cs b/Maki/Gateway/GatewayHeartbeatManager.cs index 21d5f5f..7b3b01d 100644 --- a/Maki/Gateway/GatewayHeartbeatManager.cs +++ b/Maki/Gateway/GatewayHeartbeatManager.cs @@ -11,20 +11,20 @@ namespace Maki.Gateway /// /// Subject shard /// - private readonly GatewayShard shard; + private readonly GatewayShard Shard; /// /// Interval timer for repeating the request /// - private Timer timer = null; + private Timer Timer = null; /// /// Constructor /// - /// Parent GatewayShard instance - public GatewayHeartbeatManager(GatewayShard s) + /// Parent GatewayShard instance + public GatewayHeartbeatManager(GatewayShard shard) { - shard = s; + Shard = shard; } /// @@ -32,10 +32,10 @@ namespace Maki.Gateway /// public void Start() { - if (timer != null) + if (Timer != null) Stop(); - timer = new Timer(Handler, null, TimeSpan.Zero, shard.HeartbeatInterval); + Timer = new Timer(Handler, null, TimeSpan.Zero, Shard.HeartbeatInterval); } /// @@ -44,7 +44,7 @@ namespace Maki.Gateway /// private void Handler(object state) { - shard.Send(GatewayOPCode.Heartbeat, shard.LastSequence); + Shard.Send(GatewayOPCode.Heartbeat, Shard.LastSequence); } /// @@ -52,11 +52,11 @@ namespace Maki.Gateway /// public void Stop() { - if (timer == null) + if (Timer == null) return; - timer.Dispose(); - timer = null; + Timer.Dispose(); + Timer = null; } } } diff --git a/Maki/Gateway/GatewayShard.cs b/Maki/Gateway/GatewayShard.cs index 5106c99..ef32729 100644 --- a/Maki/Gateway/GatewayShard.cs +++ b/Maki/Gateway/GatewayShard.cs @@ -418,23 +418,21 @@ namespace Maki.Gateway private void Dispose(bool disposing) { - if (!IsDisposed) - { - IsDisposed = true; - Disconnect(); - } + if (IsDisposed) + return; + + IsDisposed = true; + Disconnect(); + + if (disposing) + GC.SuppressFinalize(this); } ~GatewayShard() - { - Dispose(false); - } + => Dispose(false); public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(true); - } + => Dispose(true); #endregion diff --git a/Maki/Gateway/GatewayShardClient.cs b/Maki/Gateway/GatewayShardClient.cs index 8f2f8e5..53a11aa 100644 --- a/Maki/Gateway/GatewayShardClient.cs +++ b/Maki/Gateway/GatewayShardClient.cs @@ -286,7 +286,7 @@ namespace Maki.Gateway Disconnect(); if (disposing) - GC.SuppressFinalize(true); + GC.SuppressFinalize(this); } ~GatewayShardClient() diff --git a/Maki/Rest/WebRequest.cs b/Maki/Rest/WebRequest.cs index 12feb59..00a1ceb 100644 --- a/Maki/Rest/WebRequest.cs +++ b/Maki/Rest/WebRequest.cs @@ -53,7 +53,6 @@ namespace Maki.Rest get { if (RawResponseValue == null) - { using (MemoryStream ms = new MemoryStream()) { byte[] bytes = new byte[4096]; @@ -66,7 +65,6 @@ namespace Maki.Rest RawResponseValue = new byte[ms.Length]; ms.Read(RawResponseValue, 0, RawResponseValue.Length); } - } return RawResponseValue; } @@ -261,7 +259,7 @@ namespace Maki.Rest HttpWebResponse?.Close(); if (disposing) - GC.SuppressFinalize(true); + GC.SuppressFinalize(this); } ~WebRequest()