From 0136decceb287182d4b229e6a2e833c17d4a5b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 14:51:17 +0200 Subject: [PATCH] Removed-this. (#191) --- src/Discord.Net.Core/Discord.Net.Core.xml | 23 ++- .../Interactions/AutocompleteOption.cs | 8 +- .../Interactions/AutocompleteResult.cs | 4 +- .../Context Menus/MessageCommandBuilder.cs | 8 +- .../Context Menus/UserCommandBuilder.cs | 8 +- .../Message Components/ActionRowComponent.cs | 2 +- .../Message Components/ButtonComponent.cs | 14 +- .../Message Components/ComponentBuilder.cs | 150 +++++++++--------- .../Message Components/MessageComponent.cs | 2 +- .../Message Components/SelectMenuComponent.cs | 24 +-- .../Message Components/SelectMenuOption.cs | 10 +- .../Slash Commands/SlashCommandBuilder.cs | 74 ++++----- .../ApplicationCommandPermissions.cs | 18 +-- .../GuildApplicationCommandPermissions.cs | 8 +- .../Entities/Stickers/StickerPack.cs | 16 +- .../API/Common/ActionRowComponent.cs | 4 +- .../API/Common/ApplicationCommandOption.cs | 30 ++-- .../API/Common/ButtonComponent.cs | 18 +-- .../API/Common/SelectMenuComponent.cs | 14 +- .../API/Common/SelectMenuOption.cs | 12 +- src/Discord.Net.Rest/API/Net/MultipartFile.cs | 2 +- .../Rest/CreateApplicationCommandParams.cs | 8 +- src/Discord.Net.Rest/DiscordRestApiClient.cs | 42 ++--- .../Entities/Channels/RestStageChannel.cs | 40 ++--- .../Entities/Channels/RestTextChannel.cs | 2 +- .../Entities/Channels/RestThreadChannel.cs | 26 +-- .../Entities/Guilds/RestGuild.cs | 16 +- .../Interactions/RestApplicationCommand.cs | 14 +- .../RestApplicationCommandChoice.cs | 4 +- .../RestApplicationCommandOption.cs | 14 +- .../Interactions/RestGlobalCommand.cs | 2 +- .../Entities/Interactions/RestGuildCommand.cs | 10 +- .../Entities/Messages/CustomSticker.cs | 10 +- .../Entities/Messages/RestFollowupMessage.cs | 4 +- .../Messages/RestInteractionMessage.cs | 6 +- .../Entities/Messages/Sticker.cs | 2 +- .../Entities/Messages/StickerItem.cs | 6 +- .../Entities/Users/RestThreadUser.cs | 8 +- .../DiscordShardedClient.cs | 2 +- .../DiscordSocketClient.cs | 20 +-- .../DiscordSocketConfig.cs | 6 +- .../Entities/Channels/SocketStageChannel.cs | 44 ++--- .../Entities/Channels/SocketTextChannel.cs | 2 +- .../Entities/Channels/SocketThreadChannel.cs | 46 +++--- .../Entities/Guilds/SocketGuild.cs | 22 +-- .../Message Commands/SocketMessageCommand.cs | 2 +- .../User Commands/SocketUserCommand.cs | 2 +- .../SocketMessageComponent.cs | 20 +-- .../SocketMessageComponentData.cs | 6 +- .../SocketAutocompleteInteraction.cs | 4 +- .../SocketAutocompleteInteractionData.cs | 12 +- .../Slash Commands/SocketSlashCommand.cs | 2 +- .../Slash Commands/SocketSlashCommandData.cs | 2 +- .../SocketSlashCommandDataOption.cs | 40 ++--- .../SocketApplicationCommand.cs | 24 +-- .../SocketApplicationCommandChoice.cs | 4 +- .../SocketApplicationCommandOption.cs | 14 +- .../SocketBaseCommand/SocketCommandBase.cs | 8 +- .../SocketCommandBaseData.cs | 4 +- .../SocketBaseCommand/SocketResolvableData.cs | 10 +- .../Entities/Interaction/SocketInteraction.cs | 28 ++-- .../Entities/Stickers/SocketCustomSticker.cs | 18 +-- .../Entities/Stickers/SocketSticker.cs | 38 ++--- .../Entities/Stickers/SocketUnknownSticker.cs | 6 +- .../Entities/Users/SocketThreadUser.cs | 20 +-- .../Helpers/DiagnosticResult.cs | 20 +-- .../ChannelsTests.cs | 2 +- .../GuildTests.cs | 2 +- 68 files changed, 550 insertions(+), 543 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index 695c14461..d72a1cac2 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -4917,7 +4917,11 @@ Present if this option is a group or subcommand. - + + + Options for the , see The docs. + + The type of this . @@ -5318,7 +5322,7 @@ Builds this builder into a used to send your components. - A that can be sent with . + A that can be sent with . @@ -6021,6 +6025,7 @@ The description of this option. If this option is required for this command. If this option is the default option. + If this option is set to autocompleate. The options of the option to add. The choices of this option. The current builder. @@ -8262,7 +8267,7 @@ - Gets a value that indicates whether the current user has reacted to this. + Gets a value that indicates whether the current user has reacted to true if the user has reacted to the message; otherwise false. @@ -10266,7 +10271,7 @@ The following example checks if the current user has the ability to send a message with attachment in this channel; if so, uploads a file via . - + if (currentUser?.GetPermissions(targetChannel)?.AttachFiles) await targetChannel.SendFileAsync("fortnite.png"); @@ -11086,6 +11091,7 @@ The message to remove reactions from. + The user who removed the reaction. An array of reactions to remove from the message. The options to be used when sending the request. @@ -11098,6 +11104,7 @@ Sends an inline reply that references a message. + The message that is being replyed on. The message to be sent. Determines whether the message should be read aloud by Discord or not. The to be sent. @@ -11107,6 +11114,8 @@ If null, all mentioned roles and users will be notified. The options to be used when sending the request. + The message components to be included with this message. Used for interactions. + A collection of stickers to send with the message. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -11184,6 +11193,7 @@ Whether the message should be read aloud by Discord or not. The to be sent. The options to be used when sending the request. + The message component to be included with this message. Used for interactions. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -11231,6 +11241,7 @@ Whether the message should be read aloud by Discord or not. The to be sent. The options to be used when sending the request. + The message component to be included with this message. Used for interactions. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -11825,12 +11836,8 @@ Initializes a new instance of the class. - The request that was sent prior to the exception. - The Discord status code returned. - The reason behind the exception. - diff --git a/src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs b/src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs index 9fe461d6f..2a97a7295 100644 --- a/src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs +++ b/src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs @@ -33,10 +33,10 @@ namespace Discord internal AutocompleteOption(ApplicationCommandOptionType type, string name, object value, bool focused) { - this.Type = type; - this.Name = name; - this.Value = value; - this.Focused = focused; + Type = type; + Name = name; + Value = value; + Focused = focused; } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs index 881eef80d..2536c3c51 100644 --- a/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs +++ b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs @@ -83,8 +83,8 @@ namespace Discord /// public AutocompleteResult(string name, object value) { - this.Name = name; - this.Value = value; + Name = name; + Value = value; } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs index ce9c75452..495301d00 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Context Menus/MessageCommandBuilder.cs @@ -53,8 +53,8 @@ namespace Discord { MessageCommandProperties props = new MessageCommandProperties() { - Name = this.Name, - DefaultPermission = this.DefaultPermission + Name = Name, + DefaultPermission = DefaultPermission }; return props; @@ -70,7 +70,7 @@ namespace Discord /// public MessageCommandBuilder WithName(string name) { - this.Name = name; + Name = name; return this; } @@ -81,7 +81,7 @@ namespace Discord /// The current builder. public MessageCommandBuilder WithDefaultPermission (bool value) { - this.DefaultPermission = value; + DefaultPermission = value; return this; } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs index a49250d08..075843756 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Context Menus/UserCommandBuilder.cs @@ -51,8 +51,8 @@ namespace Discord { UserCommandProperties props = new UserCommandProperties() { - Name = this.Name, - DefaultPermission = this.DefaultPermission + Name = Name, + DefaultPermission = DefaultPermission }; return props; @@ -68,7 +68,7 @@ namespace Discord /// public UserCommandBuilder WithName(string name) { - this.Name = name; + Name = name; return this; } @@ -79,7 +79,7 @@ namespace Discord /// The current builder. public UserCommandBuilder WithDefaultPermission (bool value) { - this.DefaultPermission = value; + DefaultPermission = value; return this; } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs index d4ae02383..a9dd27bea 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ActionRowComponent.cs @@ -25,7 +25,7 @@ namespace Discord internal ActionRowComponent() { } internal ActionRowComponent(List components) { - this.Components = components; + Components = components; } string IMessageComponent.CustomId => null; diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs index 6347e9d2d..bad9f8aa3 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ButtonComponent.cs @@ -55,16 +55,16 @@ namespace Discord /// A newly created button builder with the same properties as this button. /// public ButtonBuilder ToBuilder() - => new ButtonBuilder(this.Label, this.CustomId, this.Style, this.Url, this.Emote, this.Disabled); + => new ButtonBuilder(Label, CustomId, Style, Url, Emote, Disabled); internal ButtonComponent(ButtonStyle style, string label, IEmote emote, string customId, string url, bool disabled) { - this.Style = style; - this.Label = label; - this.Emote = emote; - this.CustomId = customId; - this.Url = url; - this.Disabled = disabled; + Style = style; + Label = label; + Emote = emote; + CustomId = customId; + Url = url; + Disabled = disabled; } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs index 7725688b8..b0050ee36 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs @@ -69,14 +69,14 @@ namespace Discord switch (component) { case ButtonComponent button: - this.WithButton(button.Label, button.CustomId, button.Style, button.Emote, button.Url, button.Disabled, row); + WithButton(button.Label, button.CustomId, button.Style, button.Emote, button.Url, button.Disabled, row); break; case ActionRowComponent actionRow: foreach (var cmp in actionRow.Components) AddComponent(cmp, row); break; case SelectMenuComponent menu: - this.WithSelectMenu(menu.Placeholder, menu.CustomId, menu.Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)).ToList(), menu.Placeholder, menu.MinValues, menu.MaxValues, menu.Disabled, row); + WithSelectMenu(menu.Placeholder, menu.CustomId, menu.Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)).ToList(), menu.Placeholder, menu.MinValues, menu.MaxValues, menu.Disabled, row); break; } } @@ -187,7 +187,7 @@ namespace Discord .WithUrl(url) .WithDisabled(disabled); - return this.WithButton(button, row); + return WithButton(button, row); } /// @@ -245,8 +245,8 @@ namespace Discord /// A that can be sent with . public MessageComponent Build() { - if (this._actionRows != null) - return new MessageComponent(this._actionRows.Select(x => x.Build()).ToList()); + if (_actionRows != null) + return new MessageComponent(_actionRows.Select(x => x.Build()).ToList()); else return MessageComponent.Empty; } @@ -295,7 +295,7 @@ namespace Discord /// The current builder. public ActionRowBuilder WithComponents(List components) { - this.Components = components; + Components = components; return this; } @@ -307,10 +307,10 @@ namespace Discord /// The current builder. public ActionRowBuilder AddComponent(IMessageComponent component) { - if (this.Components.Count >= MaxChildCount) + if (Components.Count >= MaxChildCount) throw new InvalidOperationException($"Components count reached {MaxChildCount}"); - this.Components.Add(component); + Components.Add(component); return this; } @@ -320,7 +320,7 @@ namespace Discord /// A that can be used within a public ActionRowComponent Build() { - return new ActionRowComponent(this._components); + return new ActionRowComponent(_components); } internal bool CanTakeComponent(IMessageComponent component) @@ -330,12 +330,12 @@ namespace Discord case ComponentType.ActionRow: return false; case ComponentType.Button: - if (this.Components.Any(x => x.Type == ComponentType.SelectMenu)) + if (Components.Any(x => x.Type == ComponentType.SelectMenu)) return false; else - return this.Components.Count < 5; + return Components.Count < 5; case ComponentType.SelectMenu: - return this.Components.Count == 0; + return Components.Count == 0; default: return false; } @@ -435,12 +435,12 @@ namespace Discord /// Disabled this button or not. public ButtonBuilder(string label = null, string customId = null, ButtonStyle style = ButtonStyle.Primary, string url = null, IEmote emote = null, bool disabled = false) { - this.CustomId = customId; - this.Style = style; - this.Url = url; - this.Label = label; - this.Disabled = disabled; - this.Emote = emote; + CustomId = customId; + Style = style; + Url = url; + Label = label; + Disabled = disabled; + Emote = emote; } /// @@ -448,12 +448,12 @@ namespace Discord /// public ButtonBuilder(ButtonComponent button) { - this.CustomId = button.CustomId; - this.Style = button.Style; - this.Url = button.Url; - this.Label = button.Label; - this.Disabled = button.Disabled; - this.Emote = button.Emote; + CustomId = button.CustomId; + Style = button.Style; + Url = button.Url; + Label = button.Label; + Disabled = button.Disabled; + Emote = button.Emote; } /// @@ -514,7 +514,7 @@ namespace Discord /// The current builder. public ButtonBuilder WithLabel(string label) { - this.Label = label; + Label = label; return this; } @@ -525,7 +525,7 @@ namespace Discord /// The current builder. public ButtonBuilder WithStyle(ButtonStyle style) { - this.Style = style; + Style = style; return this; } @@ -536,7 +536,7 @@ namespace Discord /// The current builder. public ButtonBuilder WithEmote(IEmote emote) { - this.Emote = emote; + Emote = emote; return this; } @@ -547,7 +547,7 @@ namespace Discord /// The current builder. public ButtonBuilder WithUrl(string url) { - this.Url = url; + Url = url; return this; } @@ -559,7 +559,7 @@ namespace Discord /// The current builder. public ButtonBuilder WithCustomId(string id) { - this.CustomId = id; + CustomId = id; return this; } @@ -570,7 +570,7 @@ namespace Discord /// The current builder. public ButtonBuilder WithDisabled(bool disabled) { - this.Disabled = disabled; + Disabled = disabled; return this; } @@ -585,23 +585,23 @@ namespace Discord /// A non-link button must contain a custom id public ButtonComponent Build() { - if (string.IsNullOrEmpty(this.Label) && this.Emote == null) + if (string.IsNullOrEmpty(Label) && Emote == null) throw new InvalidOperationException("A button must have an Emote or a label!"); - if (!(string.IsNullOrEmpty(this.Url) ^ string.IsNullOrEmpty(this.CustomId))) + if (!(string.IsNullOrEmpty(Url) ^ string.IsNullOrEmpty(CustomId))) throw new InvalidOperationException("A button must contain either a URL or a CustomId, but not both!"); - if (this.Style == ButtonStyle.Link) + if (Style == ButtonStyle.Link) { - if (string.IsNullOrEmpty(this.Url)) + if (string.IsNullOrEmpty(Url)) throw new InvalidOperationException("Link buttons must have a link associated with them"); else - UrlValidation.Validate(this.Url); + UrlValidation.Validate(Url); } - else if (string.IsNullOrEmpty(this.CustomId)) + else if (string.IsNullOrEmpty(CustomId)) throw new InvalidOperationException("Non-link buttons must have a custom id associated with them"); - return new ButtonComponent(this.Style, this.Label, this.Emote, this.CustomId, this.Url, this.Disabled); + return new ButtonComponent(Style, Label, Emote, CustomId, Url, Disabled); } } @@ -736,12 +736,12 @@ namespace Discord /// public SelectMenuBuilder(SelectMenuComponent selectMenu) { - this.Placeholder = selectMenu.Placeholder; - this.CustomId = selectMenu.Placeholder; - this.MaxValues = selectMenu.MaxValues; - this.MinValues = selectMenu.MinValues; - this.Disabled = selectMenu.Disabled; - this.Options = selectMenu.Options? + Placeholder = selectMenu.Placeholder; + CustomId = selectMenu.Placeholder; + MaxValues = selectMenu.MaxValues; + MinValues = selectMenu.MinValues; + Disabled = selectMenu.Disabled; + Options = selectMenu.Options? .Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)) .ToList(); } @@ -757,12 +757,12 @@ namespace Discord /// Disabled this select menu or not. public SelectMenuBuilder(string customId, List options, string placeholder = null, int maxValues = 1, int minValues = 1, bool disabled = false) { - this.CustomId = customId; - this.Options = options; - this.Placeholder = placeholder; - this.Disabled = disabled; - this.MaxValues = maxValues; - this.MinValues = minValues; + CustomId = customId; + Options = options; + Placeholder = placeholder; + Disabled = disabled; + MaxValues = maxValues; + MinValues = minValues; } /// @@ -775,7 +775,7 @@ namespace Discord /// public SelectMenuBuilder WithCustomId(string customId) { - this.CustomId = customId; + CustomId = customId; return this; } @@ -789,7 +789,7 @@ namespace Discord /// public SelectMenuBuilder WithPlaceholder(string placeholder) { - this.Placeholder = placeholder; + Placeholder = placeholder; return this; } @@ -803,7 +803,7 @@ namespace Discord /// public SelectMenuBuilder WithMinValues(int minValues) { - this.MinValues = minValues; + MinValues = minValues; return this; } @@ -817,7 +817,7 @@ namespace Discord /// public SelectMenuBuilder WithMaxValues(int maxValues) { - this.MaxValues = maxValues; + MaxValues = maxValues; return this; } @@ -831,7 +831,7 @@ namespace Discord /// public SelectMenuBuilder WithOptions(List options) { - this.Options = options; + Options = options; return this; } @@ -845,10 +845,10 @@ namespace Discord /// public SelectMenuBuilder AddOption(SelectMenuOptionBuilder option) { - if (this.Options.Count >= MaxOptionCount) + if (Options.Count >= MaxOptionCount) throw new InvalidOperationException($"Options count reached {MaxOptionCount}."); - this.Options.Add(option); + Options.Add(option); return this; } @@ -879,7 +879,7 @@ namespace Discord /// public SelectMenuBuilder WithDisabled(bool disabled) { - this.Disabled = disabled; + Disabled = disabled; return this; } @@ -889,9 +889,9 @@ namespace Discord /// The newly built public SelectMenuComponent Build() { - var options = this.Options?.Select(x => x.Build()).ToList(); + var options = Options?.Select(x => x.Build()).ToList(); - return new SelectMenuComponent(this.CustomId, options, this.Placeholder, this.MinValues, this.MaxValues, this.Disabled); + return new SelectMenuComponent(CustomId, options, Placeholder, MinValues, MaxValues, Disabled); } } @@ -1012,11 +1012,11 @@ namespace Discord /// Render this option as selected by default or not. public SelectMenuOptionBuilder(string label, string value, string description = null, IEmote emote = null, bool? @default = null) { - this.Label = label; - this.Value = value; - this.Description = description; - this.Emote = emote; - this.Default = @default; + Label = label; + Value = value; + Description = description; + Emote = emote; + Default = @default; } /// @@ -1024,11 +1024,11 @@ namespace Discord /// public SelectMenuOptionBuilder(SelectMenuOption option) { - this.Label = option.Label; - this.Value = option.Value; - this.Description = option.Description; - this.Emote = option.Emote; - this.Default = option.Default; + Label = option.Label; + Value = option.Value; + Description = option.Description; + Emote = option.Emote; + Default = option.Default; } /// @@ -1041,7 +1041,7 @@ namespace Discord /// public SelectMenuOptionBuilder WithLabel(string label) { - this.Label = label; + Label = label; return this; } @@ -1055,7 +1055,7 @@ namespace Discord /// public SelectMenuOptionBuilder WithValue(string value) { - this.Value = value; + Value = value; return this; } @@ -1069,7 +1069,7 @@ namespace Discord /// public SelectMenuOptionBuilder WithDescription(string description) { - this.Description = description; + Description = description; return this; } @@ -1082,7 +1082,7 @@ namespace Discord /// public SelectMenuOptionBuilder WithEmote(IEmote emote) { - this.Emote = emote; + Emote = emote; return this; } @@ -1095,7 +1095,7 @@ namespace Discord /// public SelectMenuOptionBuilder WithDefault(bool defaultValue) { - this.Default = defaultValue; + Default = defaultValue; return this; } @@ -1105,7 +1105,7 @@ namespace Discord /// The newly built . public SelectMenuOption Build() { - return new SelectMenuOption(this.Label, this.Value, this.Description, this.Emote, this.Default); + return new SelectMenuOption(Label, Value, Description, Emote, Default); } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs index 82df2550e..c1c8b2817 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/MessageComponent.cs @@ -18,7 +18,7 @@ namespace Discord internal MessageComponent(List components) { - this.Components = components; + Components = components; } /// diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuComponent.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuComponent.cs index 6ea4c07fe..4fa3e4393 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuComponent.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuComponent.cs @@ -52,21 +52,21 @@ namespace Discord /// public SelectMenuBuilder ToBuilder() => new SelectMenuBuilder( - this.CustomId, - this.Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)).ToList(), - this.Placeholder, - this.MaxValues, - this.MinValues, - this.Disabled); + CustomId, + Options.Select(x => new SelectMenuOptionBuilder(x.Label, x.Value, x.Description, x.Emote, x.Default)).ToList(), + Placeholder, + MaxValues, + MinValues, + Disabled); internal SelectMenuComponent(string customId, List options, string placeholder, int minValues, int maxValues, bool disabled) { - this.CustomId = customId; - this.Options = options; - this.Placeholder = placeholder; - this.MinValues = minValues; - this.MaxValues = maxValues; - this.Disabled = disabled; + CustomId = customId; + Options = options; + Placeholder = placeholder; + MinValues = minValues; + MaxValues = maxValues; + Disabled = disabled; } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuOption.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuOption.cs index e5425971a..624b652be 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuOption.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuOption.cs @@ -38,11 +38,11 @@ namespace Discord internal SelectMenuOption(string label, string value, string description, IEmote emote, bool? defaultValue) { - this.Label = label; - this.Value = value; - this.Description = description; - this.Emote = emote; - this.Default = defaultValue; + Label = label; + Value = value; + Description = description; + Emote = emote; + Default = defaultValue; } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs index b41be71fa..4abf84eb3 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs @@ -100,16 +100,16 @@ namespace Discord { SlashCommandProperties props = new SlashCommandProperties() { - Name = this.Name, - Description = this.Description, - DefaultPermission = this.DefaultPermission, + Name = Name, + Description = Description, + DefaultPermission = DefaultPermission, }; - if (this.Options != null && this.Options.Any()) + if (Options != null && Options.Any()) { var options = new List(); - this.Options.ForEach(x => options.Add(x.Build())); + Options.ForEach(x => options.Add(x.Build())); props.Options = options; } @@ -127,7 +127,7 @@ namespace Discord /// public SlashCommandBuilder WithName(string name) { - this.Name = name; + Name = name; return this; } @@ -138,7 +138,7 @@ namespace Discord /// The current builder. public SlashCommandBuilder WithDescription(string description) { - this.Description = description; + Description = description; return this; } @@ -149,7 +149,7 @@ namespace Discord /// The current builder. public SlashCommandBuilder WithDefaultPermission(bool value) { - this.DefaultPermission = value; + DefaultPermission = value; return this; } @@ -186,8 +186,8 @@ namespace Discord // make sure theres only one option with default set to true if (isDefault.HasValue && isDefault.Value) { - if (this.Options != null) - if (this.Options.Any(x => x.Default.HasValue && x.Default.Value)) + if (Options != null) + if (Options.Any(x => x.Default.HasValue && x.Default.Value)) throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault)); } @@ -237,16 +237,16 @@ namespace Discord /// The current builder. public SlashCommandBuilder AddOption(SlashCommandOptionBuilder option) { - if (this.Options == null) - this.Options = new List(); + if (Options == null) + Options = new List(); - if (this.Options.Count >= MaxOptionsCount) + if (Options.Count >= MaxOptionsCount) throw new ArgumentOutOfRangeException(nameof(Options), $"Cannot have more than {MaxOptionsCount} options!"); if (option == null) throw new ArgumentNullException(nameof(option), "Option cannot be null"); - this.Options.Add(option); + Options.Add(option); return this; } /// @@ -262,13 +262,13 @@ namespace Discord if (options.Length == 0) throw new ArgumentException(nameof(options), "Options cannot be empty!"); - if (this.Options == null) - this.Options = new List(); + if (Options == null) + Options = new List(); - if (this.Options.Count + options.Length > MaxOptionsCount) + if (Options.Count + options.Length > MaxOptionsCount) throw new ArgumentOutOfRangeException(nameof(options), $"Cannot have more than {MaxOptionsCount} options!"); - this.Options.AddRange(options); + Options.AddRange(options); return this; } } @@ -365,7 +365,7 @@ namespace Discord /// The built version of this option. public ApplicationCommandOptionProperties Build() { - bool isSubType = this.Type == ApplicationCommandOptionType.SubCommandGroup; + bool isSubType = Type == ApplicationCommandOptionType.SubCommandGroup; if (isSubType && (Options == null || !Options.Any())) throw new ArgumentException(nameof(Options), "SubCommands/SubCommandGroups must have at least one option"); @@ -375,14 +375,14 @@ namespace Discord return new ApplicationCommandOptionProperties() { - Name = this.Name, - Description = this.Description, - Default = this.Default, - Required = this.Required, - Type = this.Type, - Options = this.Options?.Count > 0 ? new List(this.Options.Select(x => x.Build())) : null, - Choices = this.Choices, - Autocomplete = this.Autocomplete + Name = Name, + Description = Description, + Default = Default, + Required = Required, + Type = Type, + Options = Options?.Count > 0 ? new List(Options.Select(x => x.Build())) : null, + Choices = Choices, + Autocomplete = Autocomplete }; } @@ -418,8 +418,8 @@ namespace Discord // make sure theres only one option with default set to true if (isDefault) { - if (this.Options != null) - if (this.Options.Any(x => x.Default.HasValue && x.Default.Value)) + if (Options != null) + if (Options.Any(x => x.Default.HasValue && x.Default.Value)) throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault)); } @@ -443,10 +443,10 @@ namespace Discord /// The current builder. public SlashCommandOptionBuilder AddOption(SlashCommandOptionBuilder option) { - if (this.Options == null) - this.Options = new List(); + if (Options == null) + Options = new List(); - if (this.Options.Count >= SlashCommandBuilder.MaxOptionsCount) + if (Options.Count >= SlashCommandBuilder.MaxOptionsCount) throw new ArgumentOutOfRangeException(nameof(Choices), $"There can only be {SlashCommandBuilder.MaxOptionsCount} options per sub command group!"); if (option == null) @@ -527,7 +527,7 @@ namespace Discord /// The current builder. public SlashCommandOptionBuilder WithName(string name) { - this.Name = name; + Name = name; return this; } @@ -539,7 +539,7 @@ namespace Discord /// The current builder. public SlashCommandOptionBuilder WithDescription(string description) { - this.Description = description; + Description = description; return this; } @@ -550,7 +550,7 @@ namespace Discord /// The current builder. public SlashCommandOptionBuilder WithRequired(bool value) { - this.Required = value; + Required = value; return this; } @@ -561,7 +561,7 @@ namespace Discord /// The current builder. public SlashCommandOptionBuilder WithDefault(bool value) { - this.Default = value; + Default = value; return this; } @@ -572,7 +572,7 @@ namespace Discord /// The current builder. public SlashCommandOptionBuilder WithType(ApplicationCommandOptionType type) { - this.Type = type; + Type = type; return this; } } diff --git a/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs index 476960522..28a6455e2 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ApplicationCommandPermissions.cs @@ -30,9 +30,9 @@ namespace Discord /// The value of this permission. public ApplicationCommandPermission(ulong targetId, ApplicationCommandPermissionTarget targetType, bool allow) { - this.TargetId = targetId; - this.TargetType = targetType; - this.Permission = allow; + TargetId = targetId; + TargetType = targetType; + Permission = allow; } /// @@ -42,9 +42,9 @@ namespace Discord /// The value of this permission. public ApplicationCommandPermission(IUser target, bool allow) { - this.TargetId = target.Id; - this.Permission = allow; - this.TargetType = ApplicationCommandPermissionTarget.User; + TargetId = target.Id; + Permission = allow; + TargetType = ApplicationCommandPermissionTarget.User; } /// @@ -54,9 +54,9 @@ namespace Discord /// The value of this permission. public ApplicationCommandPermission(IRole target, bool allow) { - this.TargetId = target.Id; - this.Permission = allow; - this.TargetType = ApplicationCommandPermissionTarget.Role; + TargetId = target.Id; + Permission = allow; + TargetType = ApplicationCommandPermissionTarget.Role; } } } diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildApplicationCommandPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/GuildApplicationCommandPermissions.cs index 5145f5dc6..4be724453 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildApplicationCommandPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildApplicationCommandPermissions.cs @@ -34,10 +34,10 @@ namespace Discord internal GuildApplicationCommandPermission(ulong commandId, ulong appId, ulong guildId, ApplicationCommandPermission[] permissions) { - this.CommandId = commandId; - this.ApplicationId = appId; - this.GuildId = guildId; - this.Permissions = permissions; + CommandId = commandId; + ApplicationId = appId; + GuildId = guildId; + Permissions = permissions; } } } diff --git a/src/Discord.Net.Core/Entities/Stickers/StickerPack.cs b/src/Discord.Net.Core/Entities/Stickers/StickerPack.cs index b0750efc1..76d424a47 100644 --- a/src/Discord.Net.Core/Entities/Stickers/StickerPack.cs +++ b/src/Discord.Net.Core/Entities/Stickers/StickerPack.cs @@ -50,14 +50,14 @@ namespace Discord internal StickerPack(string name, ulong id, ulong skuid, ulong? coverStickerId, string description, ulong bannerAssetId, IEnumerable stickers) { - this.Name = name; - this.Id = id; - this.SkuId = skuid; - this.CoverStickerId = coverStickerId; - this.Description = description; - this.BannerAssetId = bannerAssetId; - - this.Stickers = stickers.ToImmutableArray(); + Name = name; + Id = id; + SkuId = skuid; + CoverStickerId = coverStickerId; + Description = description; + BannerAssetId = bannerAssetId; + + Stickers = stickers.ToImmutableArray(); } } } diff --git a/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs b/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs index 270532a18..417fb1b98 100644 --- a/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs +++ b/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs @@ -19,8 +19,8 @@ namespace Discord.API internal ActionRowComponent() { } internal ActionRowComponent(Discord.ActionRowComponent c) { - this.Type = c.Type; - this.Components = c.Components?.Select(x => + Type = c.Type; + Components = c.Components?.Select(x => { switch (x.Type) { diff --git a/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs b/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs index 2169e601e..93ee2e9b5 100644 --- a/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs +++ b/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs @@ -37,28 +37,28 @@ namespace Discord.API public ApplicationCommandOption(IApplicationCommandOption cmd) { - this.Choices = cmd.Choices.Select(x => new ApplicationCommandOptionChoice() + Choices = cmd.Choices.Select(x => new ApplicationCommandOptionChoice() { Name = x.Name, Value = x.Value }).ToArray(); - this.Options = cmd.Options.Select(x => new ApplicationCommandOption(x)).ToArray(); + Options = cmd.Options.Select(x => new ApplicationCommandOption(x)).ToArray(); - this.Required = cmd.Required.HasValue + Required = cmd.Required.HasValue ? cmd.Required.Value : Optional.Unspecified; - this.Default = cmd.Default.HasValue + Default = cmd.Default.HasValue ? cmd.Default.Value : Optional.Unspecified; - this.Name = cmd.Name; - this.Type = cmd.Type; - this.Description = cmd.Description; + Name = cmd.Name; + Type = cmd.Type; + Description = cmd.Description; } public ApplicationCommandOption(Discord.ApplicationCommandOptionProperties option) { - this.Choices = option.Choices != null + Choices = option.Choices != null ? option.Choices.Select(x => new ApplicationCommandOptionChoice() { Name = x.Name, @@ -66,22 +66,22 @@ namespace Discord.API }).ToArray() : Optional.Unspecified; - this.Options = option.Options != null + Options = option.Options != null ? option.Options.Select(x => new ApplicationCommandOption(x)).ToArray() : Optional.Unspecified; - this.Required = option.Required.HasValue + Required = option.Required.HasValue ? option.Required.Value : Optional.Unspecified; - this.Default = option.Default.HasValue + Default = option.Default.HasValue ? option.Default.Value : Optional.Unspecified; - this.Name = option.Name; - this.Type = option.Type; - this.Description = option.Description; - this.Autocomplete = option.Autocomplete; + Name = option.Name; + Type = option.Type; + Description = option.Description; + Autocomplete = option.Autocomplete; } } } diff --git a/src/Discord.Net.Rest/API/Common/ButtonComponent.cs b/src/Discord.Net.Rest/API/Common/ButtonComponent.cs index afd50701b..b941bf593 100644 --- a/src/Discord.Net.Rest/API/Common/ButtonComponent.cs +++ b/src/Discord.Net.Rest/API/Common/ButtonComponent.cs @@ -34,18 +34,18 @@ namespace Discord.API public ButtonComponent(Discord.ButtonComponent c) { - this.Type = c.Type; - this.Style = c.Style; - this.Label = c.Label; - this.CustomId = c.CustomId; - this.Url = c.Url; - this.Disabled = c.Disabled; + Type = c.Type; + Style = c.Style; + Label = c.Label; + CustomId = c.CustomId; + Url = c.Url; + Disabled = c.Disabled; if (c.Emote != null) { if (c.Emote is Emote e) { - this.Emote = new Emoji() + Emote = new Emoji() { Name = e.Name, Animated = e.Animated, @@ -54,7 +54,7 @@ namespace Discord.API } else { - this.Emote = new Emoji() + Emote = new Emoji() { Name = c.Emote.Name }; @@ -63,6 +63,6 @@ namespace Discord.API } [JsonIgnore] - string IMessageComponent.CustomId => this.CustomId.GetValueOrDefault(); + string IMessageComponent.CustomId => CustomId.GetValueOrDefault(); } } diff --git a/src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs b/src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs index f99b8aa7d..5476565dc 100644 --- a/src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs +++ b/src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs @@ -34,13 +34,13 @@ namespace Discord.API public SelectMenuComponent(Discord.SelectMenuComponent component) { - this.Type = component.Type; - this.CustomId = component.CustomId; - this.Options = component.Options.Select(x => new SelectMenuOption(x)).ToArray(); - this.Placeholder = component.Placeholder; - this.MinValues = component.MinValues; - this.MaxValues = component.MaxValues; - this.Disabled = component.Disabled; + Type = component.Type; + CustomId = component.CustomId; + Options = component.Options.Select(x => new SelectMenuOption(x)).ToArray(); + Placeholder = component.Placeholder; + MinValues = component.MinValues; + MaxValues = component.MaxValues; + Disabled = component.Disabled; } } } diff --git a/src/Discord.Net.Rest/API/Common/SelectMenuOption.cs b/src/Discord.Net.Rest/API/Common/SelectMenuOption.cs index 5c6f2816b..cb0e63035 100644 --- a/src/Discord.Net.Rest/API/Common/SelectMenuOption.cs +++ b/src/Discord.Net.Rest/API/Common/SelectMenuOption.cs @@ -28,15 +28,15 @@ namespace Discord.API public SelectMenuOption(Discord.SelectMenuOption option) { - this.Label = option.Label; - this.Value = option.Value; - this.Description = option.Description; + Label = option.Label; + Value = option.Value; + Description = option.Description; if (option.Emote != null) { if (option.Emote is Emote e) { - this.Emoji = new Emoji() + Emoji = new Emoji() { Name = e.Name, Animated = e.Animated, @@ -45,14 +45,14 @@ namespace Discord.API } else { - this.Emoji = new Emoji() + Emoji = new Emoji() { Name = option.Emote.Name }; } } - this.Default = option.Default.HasValue ? option.Default.Value : Optional.Unspecified; + Default = option.Default.HasValue ? option.Default.Value : Optional.Unspecified; } } } diff --git a/src/Discord.Net.Rest/API/Net/MultipartFile.cs b/src/Discord.Net.Rest/API/Net/MultipartFile.cs index ab28c0dbc..d6bc4c7ab 100644 --- a/src/Discord.Net.Rest/API/Net/MultipartFile.cs +++ b/src/Discord.Net.Rest/API/Net/MultipartFile.cs @@ -12,7 +12,7 @@ namespace Discord.Net.Rest { Stream = stream; Filename = filename; - this.ContentType = contentType; + ContentType = contentType; } } } diff --git a/src/Discord.Net.Rest/API/Rest/CreateApplicationCommandParams.cs b/src/Discord.Net.Rest/API/Rest/CreateApplicationCommandParams.cs index ff72429a3..7fe8b10ad 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateApplicationCommandParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateApplicationCommandParams.cs @@ -28,10 +28,10 @@ namespace Discord.API.Rest public CreateApplicationCommandParams() { } public CreateApplicationCommandParams(string name, string description, ApplicationCommandType type, ApplicationCommandOption[] options = null) { - this.Name = name; - this.Description = description; - this.Options = Optional.Create(options); - this.Type = type; + Name = name; + Description = description; + Options = Optional.Create(options); + Type = type; } } } diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index f42d33871..dfe003f53 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -1134,7 +1134,7 @@ namespace Discord.API { options = RequestOptions.CreateOrClone(options); - return await SendAsync("GET", () => $"applications/{this.CurrentUserId}/commands", new BucketIds(), options: options).ConfigureAwait(false); + return await SendAsync("GET", () => $"applications/{CurrentUserId}/commands", new BucketIds(), options: options).ConfigureAwait(false); } public async Task GetGlobalApplicationCommandAsync(ulong id, RequestOptions options = null) @@ -1145,7 +1145,7 @@ namespace Discord.API try { - return await SendAsync("GET", () => $"applications/{this.CurrentUserId}/commands/{id}", new BucketIds(), options: options).ConfigureAwait(false); + return await SendAsync("GET", () => $"applications/{CurrentUserId}/commands/{id}", new BucketIds(), options: options).ConfigureAwait(false); } catch(HttpException x) when (x.HttpCode == HttpStatusCode.NotFound) { return null; } } @@ -1165,38 +1165,38 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); - return await TrySendApplicationCommandAsync(SendJsonAsync("POST", () => $"applications/{this.CurrentUserId}/commands", command, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("POST", () => $"applications/{CurrentUserId}/commands", command, new BucketIds(), options: options)).ConfigureAwait(false); } public async Task ModifyGlobalApplicationCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); - return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); } public async Task ModifyGlobalApplicationUserCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); - return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); } public async Task ModifyGlobalApplicationMessageCommandAsync(ModifyApplicationCommandParams command, ulong commandId, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); - return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); } public async Task DeleteGlobalApplicationCommandAsync(ulong commandId, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); - await SendAsync("DELETE", () => $"applications/{this.CurrentUserId}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false); + await SendAsync("DELETE", () => $"applications/{CurrentUserId}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false); } public async Task BulkOverwriteGlobalApplicationCommandsAsync(CreateApplicationCommandParams[] commands, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); - return await TrySendApplicationCommandAsync(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PUT", () => $"applications/{CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); } public async Task GetGuildApplicationCommandsAsync(ulong guildId, RequestOptions options = null) @@ -1205,7 +1205,7 @@ namespace Discord.API var bucket = new BucketIds(guildId: guildId); - return await SendAsync("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", bucket, options: options).ConfigureAwait(false); + return await SendAsync("GET", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands", bucket, options: options).ConfigureAwait(false); } public async Task GetGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) @@ -1216,7 +1216,7 @@ namespace Discord.API try { - return await SendAsync("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options); + return await SendAsync("GET", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options); } catch(HttpException x) when (x.HttpCode == HttpStatusCode.NotFound) { return null; } } @@ -1238,7 +1238,7 @@ namespace Discord.API var bucket = new BucketIds(guildId: guildId); - return await TrySendApplicationCommandAsync(SendJsonAsync("POST", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", command, bucket, options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("POST", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands", command, bucket, options: options)).ConfigureAwait(false); } public async Task ModifyGuildApplicationCommandAsync(ModifyApplicationCommandParams command, ulong guildId, ulong commandId, RequestOptions options = null) { @@ -1246,7 +1246,7 @@ namespace Discord.API var bucket = new BucketIds(guildId: guildId); - return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options)).ConfigureAwait(false); } public async Task DeleteGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) { @@ -1254,7 +1254,7 @@ namespace Discord.API var bucket = new BucketIds(guildId: guildId); - await SendAsync("DELETE", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false); + await SendAsync("DELETE", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false); } public async Task BulkOverwriteGuildApplicationCommandsAsync(ulong guildId, CreateApplicationCommandParams[] commands, RequestOptions options = null) @@ -1263,7 +1263,7 @@ namespace Discord.API var bucket = new BucketIds(guildId: guildId); - return await TrySendApplicationCommandAsync(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PUT", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options)).ConfigureAwait(false); } #endregion @@ -1283,19 +1283,19 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); - return await SendAsync("GET", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options).ConfigureAwait(false); + return await SendAsync("GET", () => $"webhooks/{CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options).ConfigureAwait(false); } public async Task ModifyInteractionResponseAsync(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); - return await SendJsonAsync("PATCH", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options); + return await SendJsonAsync("PATCH", () => $"webhooks/{CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options); } public async Task DeleteInteractionResponseAsync(string interactionToken, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); - await SendAsync("DELETE", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options); + await SendAsync("DELETE", () => $"webhooks/{CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options); } public async Task CreateInteractionFollowupMessageAsync(CreateWebhookMessageParams args, string token, RequestOptions options = null) @@ -1345,7 +1345,7 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); - return await SendAsync("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false); + return await SendAsync("GET", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false); } public async Task GetGuildApplicationCommandPermissionAsync(ulong guildId, ulong commandId, RequestOptions options = null) @@ -1355,7 +1355,7 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); - return await SendAsync("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false); + return await SendAsync("GET", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false); } public async Task ModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissionsParams permissions, ulong guildId, ulong commandId, RequestOptions options = null) @@ -1365,7 +1365,7 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); - return await SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); + return await SendJsonAsync("PUT", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); } public async Task> BatchModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissions[] permissions, ulong guildId, RequestOptions options = null) @@ -1375,7 +1375,7 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); - return await SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); + return await SendJsonAsync("PUT", () => $"applications/{CurrentUserId}/guilds/{guildId}/commands/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); } #endregion diff --git a/src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs index dd5d2bfa9..41877befc 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestStageChannel.cs @@ -39,18 +39,18 @@ namespace Discord.Rest internal void Update(StageInstance model, bool isLive = false) { - this.Live = isLive; + Live = isLive; if(isLive) { - this.Topic = model.Topic; - this.PrivacyLevel = model.PrivacyLevel; - this.DiscoverableDisabled = model.DiscoverableDisabled; + Topic = model.Topic; + PrivacyLevel = model.PrivacyLevel; + DiscoverableDisabled = model.DiscoverableDisabled; } else { - this.Topic = null; - this.PrivacyLevel = null; - this.DiscoverableDisabled = null; + Topic = null; + PrivacyLevel = null; + DiscoverableDisabled = null; } } @@ -67,7 +67,7 @@ namespace Discord.Rest { var args = new API.Rest.CreateStageInstanceParams() { - ChannelId = this.Id, + ChannelId = Id, PrivacyLevel = privacyLevel, Topic = topic }; @@ -80,7 +80,7 @@ namespace Discord.Rest /// public async Task StopStageAsync(RequestOptions options = null) { - await Discord.ApiClient.DeleteStageInstanceAsync(this.Id, options); + await Discord.ApiClient.DeleteStageInstanceAsync(Id, options); Update(null, false); } @@ -90,7 +90,7 @@ namespace Discord.Rest { await base.UpdateAsync(options); - var model = await Discord.ApiClient.GetStageInstanceAsync(this.Id, options); + var model = await Discord.ApiClient.GetStageInstanceAsync(Id, options); Update(model, model != null); } @@ -100,10 +100,10 @@ namespace Discord.Rest { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, RequestToSpeakTimestamp = DateTimeOffset.UtcNow }; - return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); + return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); } /// @@ -111,10 +111,10 @@ namespace Discord.Rest { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, Suppressed = false }; - return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); + return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); } /// @@ -122,10 +122,10 @@ namespace Discord.Rest { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, Suppressed = true }; - return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); + return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); } /// @@ -133,11 +133,11 @@ namespace Discord.Rest { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, Suppressed = false }; - return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); + return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args); } /// @@ -145,11 +145,11 @@ namespace Discord.Rest { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, Suppressed = true }; - return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); + return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args); } } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index 6502c9d1f..05980ac7a 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -261,7 +261,7 @@ namespace Discord.Rest ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, RequestOptions options = null) { var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, options); - return RestThreadChannel.Create(Discord, this.Guild, model); + return RestThreadChannel.Create(Discord, Guild, model); } #endregion diff --git a/src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs index 640b7443b..d9b223f18 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestThreadChannel.cs @@ -58,21 +58,21 @@ namespace Discord.Rest { base.Update(model); - this.Joined = model.ThreadMember.IsSpecified; + Joined = model.ThreadMember.IsSpecified; if (model.ThreadMetadata.IsSpecified) { - this.Archived = model.ThreadMetadata.Value.Archived; - this.AutoArchiveDuration = model.ThreadMetadata.Value.AutoArchiveDuration; - this.ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp; - this.Locked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false); + Archived = model.ThreadMetadata.Value.Archived; + AutoArchiveDuration = model.ThreadMetadata.Value.AutoArchiveDuration; + ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp; + Locked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false); } - this.MemberCount = model.MemberCount.GetValueOrDefault(0); - this.MessageCount = model.MessageCount.GetValueOrDefault(0); - this.Type = (ThreadType)model.Type; - this.ParentChannelId = model.CategoryId.Value; + MemberCount = model.MemberCount.GetValueOrDefault(0); + MessageCount = model.MessageCount.GetValueOrDefault(0); + Type = (ThreadType)model.Type; + ParentChannelId = model.CategoryId.Value; } /// @@ -213,18 +213,18 @@ namespace Discord.Rest /// public Task JoinAsync(RequestOptions options = null) - => Discord.ApiClient.JoinThreadAsync(this.Id, options); + => Discord.ApiClient.JoinThreadAsync(Id, options); /// public Task LeaveAsync(RequestOptions options = null) - => Discord.ApiClient.LeaveThreadAsync(this.Id, options); + => Discord.ApiClient.LeaveThreadAsync(Id, options); /// public Task AddUserAsync(IGuildUser user, RequestOptions options = null) - => Discord.ApiClient.AddThreadMemberAsync(this.Id, user.Id, options); + => Discord.ApiClient.AddThreadMemberAsync(Id, user.Id, options); /// public Task RemoveUserAsync(IGuildUser user, RequestOptions options = null) - => Discord.ApiClient.RemoveThreadMemberAsync(this.Id, user.Id, options); + => Discord.ApiClient.RemoveThreadMemberAsync(Id, user.Id, options); } } diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index d78ff07cc..5e56fd56e 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -290,7 +290,7 @@ namespace Discord.Rest /// A task that represents the asynchronous delete operation. /// public Task DeleteSlashCommandsAsync(RequestOptions options = null) - => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, this.Id, options); + => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, Id, options); /// /// Gets a collection of slash commands created by the current user in this guild. @@ -933,7 +933,7 @@ namespace Discord.Rest /// if found, otherwise . /// public async Task GetApplicationCommandAsync(ulong id, RequestOptions options = null) - => await ClientHelper.GetGuildApplicationCommand(Discord, id, this.Id, options); + => await ClientHelper.GetGuildApplicationCommand(Discord, id, Id, options); /// /// Creates an application command within this guild. /// @@ -944,9 +944,9 @@ namespace Discord.Rest /// public async Task CreateApplicationCommandAsync(ApplicationCommandProperties properties, RequestOptions options = null) { - var model = await InteractionHelper.CreateGuildCommand(Discord, this.Id, properties, options); + var model = await InteractionHelper.CreateGuildCommand(Discord, Id, properties, options); - return RestGuildCommand.Create(Discord, model, this.Id); + return RestGuildCommand.Create(Discord, model, Id); } /// /// Overwrites the application commands within this guild. @@ -959,9 +959,9 @@ namespace Discord.Rest public async Task> BulkOverwriteApplicationCommandsAsync(ApplicationCommandProperties[] properties, RequestOptions options = null) { - var models = await InteractionHelper.BulkOverwriteGuildCommands(Discord, this.Id, properties, options); + var models = await InteractionHelper.BulkOverwriteGuildCommands(Discord, Id, properties, options); - return models.Select(x => RestGuildCommand.Create(Discord, x, this.Id)).ToImmutableArray(); + return models.Select(x => RestGuildCommand.Create(Discord, x, Id)).ToImmutableArray(); } /// @@ -1066,7 +1066,7 @@ namespace Discord.Rest /// public async Task GetStickerAsync(ulong id, RequestOptions options = null) { - var model = await Discord.ApiClient.GetGuildStickerAsync(this.Id, id, options).ConfigureAwait(false); + var model = await Discord.ApiClient.GetGuildStickerAsync(Id, id, options).ConfigureAwait(false); if (model == null) return null; @@ -1083,7 +1083,7 @@ namespace Discord.Rest /// public async Task> GetStickersAsync(RequestOptions options = null) { - var models = await Discord.ApiClient.ListGuildStickersAsync(this.Id, options).ConfigureAwait(false); + var models = await Discord.ApiClient.ListGuildStickersAsync(Id, options).ConfigureAwait(false); if (models.Length == 0) return null; diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs index 439790f26..80ba28496 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommand.cs @@ -35,7 +35,7 @@ namespace Discord.Rest /// public DateTimeOffset CreatedAt - => SnowflakeUtils.FromSnowflake(this.Id); + => SnowflakeUtils.FromSnowflake(Id); internal RestApplicationCommand(BaseDiscordClient client, ulong id) : base(client, id) @@ -57,13 +57,13 @@ namespace Discord.Rest internal virtual void Update(Model model) { - this.Type = model.Type; - this.ApplicationId = model.ApplicationId; - this.Name = model.Name; - this.Description = model.Description; - this.DefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); + Type = model.Type; + ApplicationId = model.ApplicationId; + Name = model.Name; + Description = model.Description; + DefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); - this.Options = model.Options.IsSpecified + Options = model.Options.IsSpecified ? model.Options.Value.Select(x => RestApplicationCommandOption.Create(x)).ToImmutableArray() : null; } diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs index 902afdd44..cd1f73768 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandChoice.cs @@ -20,8 +20,8 @@ namespace Discord.Rest internal RestApplicationCommandChoice(Model model) { - this.Name = model.Name; - this.Value = model.Value; + Name = model.Name; + Value = model.Value; } } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs index 78f9c0e30..511712d97 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs @@ -50,21 +50,21 @@ namespace Discord.Rest internal void Update(Model model) { - this.Type = model.Type; - this.Name = model.Name; - this.Description = model.Description; + Type = model.Type; + Name = model.Name; + Description = model.Description; if (model.Default.IsSpecified) - this.Default = model.Default.Value; + Default = model.Default.Value; if (model.Required.IsSpecified) - this.Required = model.Required.Value; + Required = model.Required.Value; - this.Options = model.Options.IsSpecified + Options = model.Options.IsSpecified ? model.Options.Value.Select(x => Create(x)).ToImmutableArray() : null; - this.Choices = model.Choices.IsSpecified + Choices = model.Choices.IsSpecified ? model.Choices.Value.Select(x => new RestApplicationCommandChoice(x)).ToImmutableArray() : null; } diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs index 8d8ae5983..bee1f39cd 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/RestGlobalCommand.cs @@ -40,7 +40,7 @@ namespace Discord.Rest public override async Task ModifyAsync(Action func, RequestOptions options = null) { var cmd = await InteractionHelper.ModifyGlobalCommand(Discord, this, func, options).ConfigureAwait(false); - this.Update(cmd); + Update(cmd); } } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs index 48f402297..fb41c1812 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/RestGuildCommand.cs @@ -20,7 +20,7 @@ namespace Discord.Rest internal RestGuildCommand(BaseDiscordClient client, ulong id, ulong guildId) : base(client, id) { - this.GuildId = guildId; + GuildId = guildId; } internal static RestGuildCommand Create(BaseDiscordClient client, Model model, ulong guildId) @@ -45,7 +45,7 @@ namespace Discord.Rest public override async Task ModifyAsync(Action func, RequestOptions options = null) { var model = await InteractionHelper.ModifyGuildCommand(Discord, this, GuildId, func, options).ConfigureAwait(false); - this.Update(model); + Update(model); } /// @@ -57,7 +57,7 @@ namespace Discord.Rest /// object defining the permissions of the current slash command. /// public Task GetCommandPermission(RequestOptions options = null) - => InteractionHelper.GetGuildCommandPermissionAsync(Discord, this.GuildId, this.Id, options); + => InteractionHelper.GetGuildCommandPermissionAsync(Discord, GuildId, Id, options); /// /// Modifies the current command permissions for this guild command. @@ -69,7 +69,7 @@ namespace Discord.Rest /// object containing the modified permissions. /// public Task ModifyCommandPermissions(ApplicationCommandPermission[] permissions, RequestOptions options = null) - => InteractionHelper.ModifyGuildCommandPermissionsAsync(Discord, this.GuildId, this.Id, permissions, options); + => InteractionHelper.ModifyGuildCommandPermissionsAsync(Discord, GuildId, Id, permissions, options); /// /// Gets the guild that this slash command resides in. @@ -81,6 +81,6 @@ namespace Discord.Rest /// . /// public Task GetGuild(bool withCounts = false, RequestOptions options = null) - => ClientHelper.GetGuildAsync(this.Discord, this.GuildId, withCounts, options); + => ClientHelper.GetGuildAsync(Discord, GuildId, withCounts, options); } } diff --git a/src/Discord.Net.Rest/Entities/Messages/CustomSticker.cs b/src/Discord.Net.Rest/Entities/Messages/CustomSticker.cs index 5307c4920..94caf0f3f 100644 --- a/src/Discord.Net.Rest/Entities/Messages/CustomSticker.cs +++ b/src/Discord.Net.Rest/Entities/Messages/CustomSticker.cs @@ -35,14 +35,14 @@ namespace Discord.Rest internal CustomSticker(BaseDiscordClient client, ulong id, RestGuild guild, ulong? authorId = null) : base(client, id) { - this.AuthorId = authorId; - this.Guild = guild; + AuthorId = authorId; + Guild = guild; } internal CustomSticker(BaseDiscordClient client, ulong id, ulong guildId, ulong? authorId = null) : base(client, id) { - this.AuthorId = authorId; - this.GuildId = guildId; + AuthorId = authorId; + GuildId = guildId; } internal static CustomSticker Create(BaseDiscordClient client, Model model, RestGuild guild, ulong? authorId = null) @@ -70,7 +70,7 @@ namespace Discord.Rest Update(model); } - private string DebuggerDisplay => this.Guild != null ? $"{Name} in {Guild.Name} ({Id})" : $"{Name} ({Id})"; + private string DebuggerDisplay => Guild != null ? $"{Name} in {Guild.Name} ({Id})" : $"{Name} ({Id})"; IGuild ICustomSticker.Guild => Guild; } diff --git a/src/Discord.Net.Rest/Entities/Messages/RestFollowupMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestFollowupMessage.cs index a7c65b3a1..103c856be 100644 --- a/src/Discord.Net.Rest/Entities/Messages/RestFollowupMessage.cs +++ b/src/Discord.Net.Rest/Entities/Messages/RestFollowupMessage.cs @@ -19,7 +19,7 @@ namespace Discord.Rest internal RestFollowupMessage(BaseDiscordClient discord, ulong id, IUser author, string token, IMessageChannel channel) : base(discord, id, channel, author, MessageSource.Bot) { - this.Token = token; + Token = token; } internal static RestFollowupMessage Create(BaseDiscordClient discord, Model model, string token, IMessageChannel channel) @@ -66,7 +66,7 @@ namespace Discord.Rest try { var model = await InteractionHelper.ModifyFollowupMessage(Discord, this, func, options).ConfigureAwait(false); - this.Update(model); + Update(model); } catch (Discord.Net.HttpException x) { diff --git a/src/Discord.Net.Rest/Entities/Messages/RestInteractionMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestInteractionMessage.cs index 3574143fc..ae1b5f2fb 100644 --- a/src/Discord.Net.Rest/Entities/Messages/RestInteractionMessage.cs +++ b/src/Discord.Net.Rest/Entities/Messages/RestInteractionMessage.cs @@ -15,7 +15,7 @@ namespace Discord.Rest internal RestInteractionMessage(BaseDiscordClient discord, ulong id, IUser author, string token, IMessageChannel channel) : base(discord, id, channel, author, MessageSource.Bot) { - this.Token = token; + Token = token; } internal static RestInteractionMessage Create(BaseDiscordClient discord, Model model, string token, IMessageChannel channel) @@ -61,8 +61,8 @@ namespace Discord.Rest { try { - var model = await InteractionHelper.ModifyInteractionResponse(Discord, this.Token, func, options).ConfigureAwait(false); - this.Update(model); + var model = await InteractionHelper.ModifyInteractionResponse(Discord, Token, func, options).ConfigureAwait(false); + Update(model); } catch (Discord.Net.HttpException x) { diff --git a/src/Discord.Net.Rest/Entities/Messages/Sticker.cs b/src/Discord.Net.Rest/Entities/Messages/Sticker.cs index 46dbc3418..6490978e7 100644 --- a/src/Discord.Net.Rest/Entities/Messages/Sticker.cs +++ b/src/Discord.Net.Rest/Entities/Messages/Sticker.cs @@ -28,7 +28,7 @@ namespace Discord.Rest /// public string GetStickerUrl() - => CDN.GetStickerUrl(this.Id, this.Format); + => CDN.GetStickerUrl(Id, Format); internal Sticker(BaseDiscordClient client, ulong id) : base(client, id) { } diff --git a/src/Discord.Net.Rest/Entities/Messages/StickerItem.cs b/src/Discord.Net.Rest/Entities/Messages/StickerItem.cs index dade33bb9..f1bcb9951 100644 --- a/src/Discord.Net.Rest/Entities/Messages/StickerItem.cs +++ b/src/Discord.Net.Rest/Entities/Messages/StickerItem.cs @@ -21,8 +21,8 @@ namespace Discord.Rest internal StickerItem(BaseDiscordClient client, Model model) : base(client, model.Id) { - this.Name = model.Name; - this.Format = model.FormatType; + Name = model.Name; + Format = model.FormatType; } /// @@ -34,7 +34,7 @@ namespace Discord.Rest public async Task ResolveStickerAsync() { - var model = await Discord.ApiClient.GetStickerAsync(this.Id); + var model = await Discord.ApiClient.GetStickerAsync(Id); if (model.GuildId.IsSpecified) return CustomSticker.Create(Discord, model, model.GuildId.Value, model.User.IsSpecified ? model.User.Value.Id : null); diff --git a/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs b/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs index bb981bfdb..4dd7f7aaf 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestThreadUser.cs @@ -31,8 +31,8 @@ namespace Discord.Rest internal RestThreadUser(BaseDiscordClient discord, IGuild guild, IThreadChannel channel, ulong id) : base(discord, id) { - this.Guild = guild; - this.Thread = channel; + Guild = guild; + Thread = channel; } internal static RestThreadUser Create(BaseDiscordClient client, IGuild guild, Model model, IThreadChannel channel) @@ -44,7 +44,7 @@ namespace Discord.Rest internal void Update(Model model) { - this.JoinedAt = model.JoinTimestamp; + JoinedAt = model.JoinTimestamp; } /// @@ -55,6 +55,6 @@ namespace Discord.Rest /// that represents the current thread user. /// public Task GetGuildUser() - => Guild.GetUserAsync(this.Id); + => Guild.GetUserAsync(Id); } } diff --git a/src/Discord.Net.WebSocket/DiscordShardedClient.cs b/src/Discord.Net.WebSocket/DiscordShardedClient.cs index 106b79968..faafa918f 100644 --- a/src/Discord.Net.WebSocket/DiscordShardedClient.cs +++ b/src/Discord.Net.WebSocket/DiscordShardedClient.cs @@ -164,7 +164,7 @@ namespace Discord.WebSocket for (int i = 0; i < _shards.Length; i++) await _shards[i].LoginAsync(tokenType, token); - if(this._defaultStickers.Length == 0) + if(_defaultStickers.Length == 0) await DownloadDefaultStickersAsync().ConfigureAwait(false); } diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 72f22c9a5..1cd3debf4 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -82,8 +82,8 @@ namespace Discord.WebSocket { get { - if (this._shardedClient != null) - return this._shardedClient.DefaultStickerPacks; + if (_shardedClient != null) + return _shardedClient.DefaultStickerPacks; else return _defaultStickers.ToReadOnlyCollection(); } @@ -209,7 +209,7 @@ namespace Discord.WebSocket internal override async Task OnLoginAsync(TokenType tokenType, string token) { - if(this._shardedClient == null && this._defaultStickers.Length == 0) + if(_shardedClient == null && _defaultStickers.Length == 0) { var models = await ApiClient.ListNitroStickerPacksAsync().ConfigureAwait(false); @@ -2085,14 +2085,14 @@ namespace Discord.WebSocket if (channel == null) { - var channelModel = await this.Rest.ApiClient.GetChannelAsync(data.ChannelId.Value); + var channelModel = await Rest.ApiClient.GetChannelAsync(data.ChannelId.Value); if (data.GuildId.IsSpecified) - channel = SocketTextChannel.Create(State.GetGuild(data.GuildId.Value), this.State, channelModel); + channel = SocketTextChannel.Create(State.GetGuild(data.GuildId.Value), State, channelModel); else channel = (SocketChannel)SocketChannel.CreatePrivate(this, State, channelModel); - this.State.AddChannel(channel); + State.AddChannel(channel); } if (channel is ISocketMessageChannel textChannel) @@ -2224,14 +2224,14 @@ namespace Discord.WebSocket if ((threadChannel = guild.ThreadChannels.FirstOrDefault(x => x.Id == data.Id)) != null) { - threadChannel.Update(this.State, data); + threadChannel.Update(State, data); if(data.ThreadMember.IsSpecified) threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser); } else { - threadChannel = (SocketThreadChannel)guild.AddChannel(this.State, data); + threadChannel = (SocketThreadChannel)guild.AddChannel(State, data); if (data.ThreadMember.IsSpecified) threadChannel.AddOrUpdateThreadMember(data.ThreadMember.Value, guild.CurrentUser); } @@ -2322,11 +2322,11 @@ namespace Discord.WebSocket if(entity == null) { - entity = (SocketThreadChannel)guild.AddChannel(this.State, thread); + entity = (SocketThreadChannel)guild.AddChannel(State, thread); } else { - entity.Update(this.State, thread); + entity.Update(State, thread); } foreach(var member in data.Members.Where(x => x.Id.Value == entity.Id)) diff --git a/src/Discord.Net.WebSocket/DiscordSocketConfig.cs b/src/Discord.Net.WebSocket/DiscordSocketConfig.cs index 22a201c67..e2e4f9897 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketConfig.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketConfig.cs @@ -137,13 +137,13 @@ namespace Discord.WebSocket { get { - return this.maxWaitForGuildAvailable; + return maxWaitForGuildAvailable; } set { - Preconditions.AtLeast(value, 0, nameof(this.MaxWaitBetweenGuildAvailablesBeforeReady)); - this.maxWaitForGuildAvailable = value; + Preconditions.AtLeast(value, 0, nameof(MaxWaitBetweenGuildAvailablesBeforeReady)); + maxWaitForGuildAvailable = value; } } diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketStageChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketStageChannel.cs index 0aa89ac8f..1956a9b86 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketStageChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketStageChannel.cs @@ -37,7 +37,7 @@ namespace Discord.WebSocket /// Gets a collection of users who are speakers within the stage. /// public IReadOnlyCollection Speakers - => this.Users.Where(x => !x.IsSuppressed).ToImmutableArray(); + => Users.Where(x => !x.IsSuppressed).ToImmutableArray(); internal new SocketStageChannel Clone() => MemberwiseClone() as SocketStageChannel; @@ -62,18 +62,18 @@ namespace Discord.WebSocket internal void Update(StageInstance model, bool isLive = false) { - this.Live = isLive; + Live = isLive; if (isLive) { - this.Topic = model.Topic; - this.PrivacyLevel = model.PrivacyLevel; - this.DiscoverableDisabled = model.DiscoverableDisabled; + Topic = model.Topic; + PrivacyLevel = model.PrivacyLevel; + DiscoverableDisabled = model.DiscoverableDisabled; } else { - this.Topic = null; - this.PrivacyLevel = null; - this.DiscoverableDisabled = null; + Topic = null; + PrivacyLevel = null; + DiscoverableDisabled = null; } } @@ -82,14 +82,14 @@ namespace Discord.WebSocket { var args = new API.Rest.CreateStageInstanceParams() { - ChannelId = this.Id, + ChannelId = Id, Topic = topic, PrivacyLevel = privacyLevel, }; var model = await Discord.ApiClient.CreateStageInstanceAsync(args, options).ConfigureAwait(false); - this.Update(model, true); + Update(model, true); } /// @@ -97,13 +97,13 @@ namespace Discord.WebSocket { var model = await ChannelHelper.ModifyAsync(this, Discord, func, options); - this.Update(model, true); + Update(model, true); } /// public async Task StopStageAsync(RequestOptions options = null) { - await Discord.ApiClient.DeleteStageInstanceAsync(this.Id, options); + await Discord.ApiClient.DeleteStageInstanceAsync(Id, options); Update(null, false); } @@ -113,10 +113,10 @@ namespace Discord.WebSocket { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, RequestToSpeakTimestamp = DateTimeOffset.UtcNow }; - return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); + return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); } /// @@ -124,10 +124,10 @@ namespace Discord.WebSocket { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, Suppressed = false }; - return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); + return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); } /// @@ -135,10 +135,10 @@ namespace Discord.WebSocket { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, Suppressed = true }; - return Discord.ApiClient.ModifyMyVoiceState(this.Guild.Id, args, options); + return Discord.ApiClient.ModifyMyVoiceState(Guild.Id, args, options); } /// @@ -146,11 +146,11 @@ namespace Discord.WebSocket { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, Suppressed = false }; - return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); + return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args); } /// @@ -158,11 +158,11 @@ namespace Discord.WebSocket { var args = new API.Rest.ModifyVoiceStateParams() { - ChannelId = this.Id, + ChannelId = Id, Suppressed = true }; - return Discord.ApiClient.ModifyUserVoiceState(this.Guild.Id, user.Id, args); + return Discord.ApiClient.ModifyUserVoiceState(Guild.Id, user.Id, args); } } } diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs index 3e91eba06..63ada8592 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs @@ -55,7 +55,7 @@ namespace Discord.WebSocket /// Gets a collection of threads within this text channel. /// public IReadOnlyCollection Threads - => Guild.ThreadChannels.Where(x => x.ParentChannel.Id == this.Id).ToImmutableArray(); + => Guild.ThreadChannels.Where(x => x.ParentChannel.Id == Id).ToImmutableArray(); internal SocketTextChannel(DiscordSocketClient discord, ulong id, SocketGuild guild) : base(discord, id, guild) diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs index 33832096b..9a8f4b139 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketThreadChannel.cs @@ -41,7 +41,7 @@ namespace Discord.WebSocket /// if this thread is private, otherwise /// public bool IsPrivateThread - => this.Type == ThreadType.PrivateThread; + => Type == ThreadType.PrivateThread; /// /// Gets the parent channel this thread resides in. @@ -84,8 +84,8 @@ namespace Discord.WebSocket internal SocketThreadChannel(DiscordSocketClient discord, SocketGuild guild, ulong id, SocketTextChannel parent) : base(discord, id, guild) { - this.ParentChannel = parent; - this._members = new ConcurrentDictionary(); + ParentChannel = parent; + _members = new ConcurrentDictionary(); } internal new static SocketThreadChannel Create(SocketGuild guild, ClientState state, Model model) @@ -100,24 +100,24 @@ namespace Discord.WebSocket { base.Update(state, model); - this.Type = (ThreadType)model.Type; - this.MessageCount = model.MessageCount.GetValueOrDefault(-1); - this.MemberCount = model.MemberCount.GetValueOrDefault(-1); + Type = (ThreadType)model.Type; + MessageCount = model.MessageCount.GetValueOrDefault(-1); + MemberCount = model.MemberCount.GetValueOrDefault(-1); if (model.ThreadMetadata.IsSpecified) { - this.Archived = model.ThreadMetadata.Value.Archived; - this.ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp; - this.AutoArchiveDuration = (ThreadArchiveDuration)model.ThreadMetadata.Value.AutoArchiveDuration; - this.Locked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false); + Archived = model.ThreadMetadata.Value.Archived; + ArchiveTimestamp = model.ThreadMetadata.Value.ArchiveTimestamp; + AutoArchiveDuration = (ThreadArchiveDuration)model.ThreadMetadata.Value.AutoArchiveDuration; + Locked = model.ThreadMetadata.Value.Locked.GetValueOrDefault(false); } if (model.OwnerId.IsSpecified) { - this.Owner = GetUser(model.OwnerId.Value); + Owner = GetUser(model.OwnerId.Value); } - this.Joined = model.ThreadMember.IsSpecified; + Joined = model.ThreadMember.IsSpecified; } internal IReadOnlyCollection RemoveUsers(ulong[] users) @@ -139,7 +139,7 @@ namespace Discord.WebSocket member.Update(model); else { - member = SocketThreadUser.Create(this.Guild, this, model, guildMember); + member = SocketThreadUser.Create(Guild, this, model, guildMember); member.GlobalUser.AddRef(); _members[member.Id] = member; } @@ -167,10 +167,10 @@ namespace Discord.WebSocket if (!_usersDownloaded) { await DownloadUsersAsync(options); - this._usersDownloaded = true; + _usersDownloaded = true; } - return this.Users; + return Users; } @@ -181,15 +181,15 @@ namespace Discord.WebSocket /// A task representing the asyncronous download operation. public async Task DownloadUsersAsync(RequestOptions options = null) { - var users = await Discord.ApiClient.ListThreadMembersAsync(this.Id, options); + var users = await Discord.ApiClient.ListThreadMembersAsync(Id, options); lock (_downloadLock) { foreach (var threadMember in users) { - var guildUser = this.Guild.GetUser(threadMember.UserId.Value); + var guildUser = Guild.GetUser(threadMember.UserId.Value); - this.AddOrUpdateThreadMember(threadMember, guildUser); + AddOrUpdateThreadMember(threadMember, guildUser); } } } @@ -198,11 +198,11 @@ namespace Discord.WebSocket /// public Task JoinAsync(RequestOptions options = null) - => Discord.ApiClient.JoinThreadAsync(this.Id, options); + => Discord.ApiClient.JoinThreadAsync(Id, options); /// public Task LeaveAsync(RequestOptions options = null) - => Discord.ApiClient.LeaveThreadAsync(this.Id, options); + => Discord.ApiClient.LeaveThreadAsync(Id, options); /// /// Adds a user to this thread. @@ -213,7 +213,7 @@ namespace Discord.WebSocket /// A task that represents the asynchronous operation of adding a member to a thread. /// public Task AddUserAsync(IGuildUser user, RequestOptions options = null) - => Discord.ApiClient.AddThreadMemberAsync(this.Id, user.Id, options); + => Discord.ApiClient.AddThreadMemberAsync(Id, user.Id, options); /// /// Removes a user from this thread. @@ -224,7 +224,7 @@ namespace Discord.WebSocket /// A task that represents the asynchronous operation of removing a user from this thread. /// public Task RemoveUserAsync(IGuildUser user, RequestOptions options = null) - => Discord.ApiClient.RemoveThreadMemberAsync(this.Id, user.Id, options); + => Discord.ApiClient.RemoveThreadMemberAsync(Id, user.Id, options); /// @@ -339,6 +339,6 @@ namespace Discord.WebSocket public override Task SyncPermissionsAsync(RequestOptions options = null) => throw new NotImplementedException(); - string IChannel.Name => this.Name; + string IChannel.Name => Name; } } diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index e4a03f818..ccda12644 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -842,7 +842,7 @@ namespace Discord.WebSocket /// A task that represents the asynchronous delete operation. /// public Task DeleteApplicationCommandsAsync(RequestOptions options = null) - => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, this.Id, options); + => InteractionHelper.DeleteAllGuildCommandsAsync(Discord, Id, options); /// /// Gets a collection of slash commands created by the current user in this guild. @@ -854,7 +854,7 @@ namespace Discord.WebSocket /// public async Task> GetApplicationCommandsAsync(RequestOptions options = null) { - var commands = (await Discord.ApiClient.GetGuildApplicationCommandsAsync(this.Id, options)).Select(x => SocketApplicationCommand.Create(Discord, x, this.Id)); + var commands = (await Discord.ApiClient.GetGuildApplicationCommandsAsync(Id, options)).Select(x => SocketApplicationCommand.Create(Discord, x, Id)); foreach (var command in commands) { @@ -889,7 +889,7 @@ namespace Discord.WebSocket if (model == null) return null; - command = SocketApplicationCommand.Create(Discord, model, this.Id); + command = SocketApplicationCommand.Create(Discord, model, Id); Discord.State.AddCommand(command); @@ -906,7 +906,7 @@ namespace Discord.WebSocket /// public async Task CreateApplicationCommandAsync(ApplicationCommandProperties properties, RequestOptions options = null) { - var model = await InteractionHelper.CreateGuildCommand(Discord, this.Id, properties, options); + var model = await InteractionHelper.CreateGuildCommand(Discord, Id, properties, options); var entity = Discord.State.GetOrAddCommand(model.Id, (id) => SocketApplicationCommand.Create(Discord, model)); @@ -926,11 +926,11 @@ namespace Discord.WebSocket public async Task> BulkOverwriteApplicationCommandAsync(ApplicationCommandProperties[] properties, RequestOptions options = null) { - var models = await InteractionHelper.BulkOverwriteGuildCommands(Discord, this.Id, properties, options); + var models = await InteractionHelper.BulkOverwriteGuildCommands(Discord, Id, properties, options); var entities = models.Select(x => SocketApplicationCommand.Create(Discord, x)); - Discord.State.PurgeCommands(x => !x.IsGlobalCommand && x.Guild.Id == this.Id); + Discord.State.PurgeCommands(x => !x.IsGlobalCommand && x.Guild.Id == Id); foreach(var entity in entities) { @@ -1016,7 +1016,7 @@ namespace Discord.WebSocket internal SocketRole AddOrUpdateRole(RoleModel model) { if (_roles.TryGetValue(model.Id, out SocketRole role)) - _roles[model.Id].Update(this.Discord.State, model); + _roles[model.Id].Update(Discord.State, model); else role = AddRole(model); @@ -1291,7 +1291,7 @@ namespace Discord.WebSocket if (mode == CacheMode.CacheOnly) return null; - var model = await Discord.ApiClient.GetGuildStickerAsync(this.Id, id, options).ConfigureAwait(false); + var model = await Discord.ApiClient.GetGuildStickerAsync(Id, id, options).ConfigureAwait(false); if (model == null) return null; @@ -1317,13 +1317,13 @@ namespace Discord.WebSocket public async ValueTask> GetStickersAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null) { - if (this.Stickers.Count > 0) - return this.Stickers; + if (Stickers.Count > 0) + return Stickers; if (mode == CacheMode.CacheOnly) return ImmutableArray.Create(); - var models = await Discord.ApiClient.ListGuildStickersAsync(this.Id, options).ConfigureAwait(false); + var models = await Discord.ApiClient.ListGuildStickersAsync(Id, options).ConfigureAwait(false); List stickers = new(); diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/Message Commands/SocketMessageCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/Message Commands/SocketMessageCommand.cs index 72f040cc6..efd99c2c4 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/Message Commands/SocketMessageCommand.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/Message Commands/SocketMessageCommand.cs @@ -25,7 +25,7 @@ namespace Discord.WebSocket : null; ulong? guildId = null; - if (this.Channel is SocketGuildChannel guildChannel) + if (Channel is SocketGuildChannel guildChannel) guildId = guildChannel.Guild.Id; Data = SocketMessageCommandData.Create(client, dataModel, model.Id, guildId); diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommand.cs index 5345c08f7..a61279db9 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommand.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Context Menu Commands/User Commands/SocketUserCommand.cs @@ -25,7 +25,7 @@ namespace Discord.WebSocket : null; ulong? guildId = null; - if (this.Channel is SocketGuildChannel guildChannel) + if (Channel is SocketGuildChannel guildChannel) guildId = guildChannel.Guild.Id; Data = SocketUserCommandData.Create(client, dataModel, model.Id, guildId); diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs index 7b2cc2062..aa3a915ae 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs @@ -32,7 +32,7 @@ namespace Discord.WebSocket (DataModel)model.Data.Value : null; - this.Data = new SocketMessageComponentData(dataModel); + Data = new SocketMessageComponentData(dataModel); } new internal static SocketMessageComponent Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel) @@ -48,10 +48,10 @@ namespace Discord.WebSocket if (model.Message.IsSpecified) { - if (this.Message == null) + if (Message == null) { SocketUser author = null; - if (this.Channel is SocketGuildChannel channel) + if (Channel is SocketGuildChannel channel) { if (model.Message.Value.WebhookId.IsSpecified) author = SocketWebhookUser.Create(channel.Guild, Discord.State, model.Message.Value.Author.Value, model.Message.Value.WebhookId.Value); @@ -59,13 +59,13 @@ namespace Discord.WebSocket author = channel.Guild.GetUser(model.Message.Value.Author.Value.Id); } else if (model.Message.Value.Author.IsSpecified) - author = (this.Channel as SocketChannel).GetUser(model.Message.Value.Author.Value.Id); + author = (Channel as SocketChannel).GetUser(model.Message.Value.Author.Value.Id); - this.Message = SocketUserMessage.Create(this.Discord, this.Discord.State, author, this.Channel, model.Message.Value); + Message = SocketUserMessage.Create(Discord, Discord.State, author, Channel, model.Message.Value); } else { - this.Message.Update(this.Discord.State, model.Message.Value); + Message.Update(Discord.State, model.Message.Value); } } } @@ -131,7 +131,7 @@ namespace Discord.WebSocket if (ephemeral) response.Data.Value.Flags = MessageFlags.Ephemeral; - await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options); + await InteractionHelper.SendInteractionResponse(Discord, response, Id, Token, options); } /// @@ -210,7 +210,7 @@ namespace Discord.WebSocket } }; - await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, this.Token, options); + await InteractionHelper.SendInteractionResponse(Discord, response, Id, Token, options); } /// @@ -371,7 +371,7 @@ namespace Discord.WebSocket }; - return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); + return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, Id, Token, options); } /// @@ -384,7 +384,7 @@ namespace Discord.WebSocket }; - return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); + return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, Id, Token, options); } } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponentData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponentData.cs index a24fd59ac..098478612 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponentData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponentData.cs @@ -29,9 +29,9 @@ namespace Discord.WebSocket internal SocketMessageComponentData(Model model) { - this.CustomId = model.CustomId; - this.Type = model.ComponentType; - this.Values = model.Values.GetValueOrDefault(); + CustomId = model.CustomId; + Type = model.ComponentType; + Values = model.Values.GetValueOrDefault(); } } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs index fe6322392..0eb22f29d 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs @@ -54,7 +54,7 @@ namespace Discord.WebSocket /// A task that represents the asynchronous operation of responding to this interaction. /// public Task RespondAsync(IEnumerable result, RequestOptions options = null) - => InteractionHelper.SendAutocompleteResult(Discord, result, this.Id, this.Token, options); + => InteractionHelper.SendAutocompleteResult(Discord, result, Id, Token, options); /// /// Responds to this interaction with a set of choices. @@ -71,7 +71,7 @@ namespace Discord.WebSocket /// A task that represents the asynchronous operation of responding to this interaction. /// public Task RespondAsync(RequestOptions options = null, params AutocompleteResult[] result) - => InteractionHelper.SendAutocompleteResult(Discord, result, this.Id, this.Token, options); + => InteractionHelper.SendAutocompleteResult(Discord, result, Id, Token, options); /// diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs index 34087116d..06e313b44 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs @@ -48,13 +48,13 @@ namespace Discord.WebSocket { var options = model.Options.Select(x => new AutocompleteOption(x.Type, x.Name, x.Value, x.Focused)); - this.Current = options.FirstOrDefault(x => x.Focused); - this.Options = options.ToImmutableArray(); + Current = options.FirstOrDefault(x => x.Focused); + Options = options.ToImmutableArray(); - this.CommandName = model.Name; - this.CommandId = model.Id; - this.Type = model.Type; - this.Version = model.Version; + CommandName = model.Name; + CommandId = model.Id; + Type = model.Type; + Version = model.Version; } } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs index 05c051f12..db53f5d08 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs @@ -25,7 +25,7 @@ namespace Discord.WebSocket : null; ulong? guildId = null; - if (this.Channel is SocketGuildChannel guildChannel) + if (Channel is SocketGuildChannel guildChannel) guildId = guildChannel.Guild.Id; Data = SocketSlashCommandData.Create(client, dataModel, guildId); diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs index 4b6764bf7..7b504f119 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandData.cs @@ -23,7 +23,7 @@ namespace Discord.WebSocket { base.Update(model); - this.Options = model.Options.IsSpecified + Options = model.Options.IsSpecified ? model.Options.Value.Select(x => new SocketSlashCommandDataOption(this, x)).ToImmutableArray() : null; } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs index ef6a187a4..b2ea82856 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommandDataOption.cs @@ -28,8 +28,8 @@ namespace Discord.WebSocket internal SocketSlashCommandDataOption() { } internal SocketSlashCommandDataOption(SocketSlashCommandData data, Model model) { - this.Name = model.Name; - this.Type = model.Type; + Name = model.Name; + Type = model.Type; if (model.Value.IsSpecified) { @@ -41,23 +41,23 @@ namespace Discord.WebSocket case ApplicationCommandOptionType.Mentionable: if (ulong.TryParse($"{model.Value.Value}", out var valueId)) { - switch (this.Type) + switch (Type) { case ApplicationCommandOptionType.User: { var guildUser = data.ResolvableData.GuildMembers.FirstOrDefault(x => x.Key == valueId).Value; if (guildUser != null) - this.Value = guildUser; + Value = guildUser; else - this.Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value; + Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value; } break; case ApplicationCommandOptionType.Channel: - this.Value = data.ResolvableData.Channels.FirstOrDefault(x => x.Key == valueId).Value; + Value = data.ResolvableData.Channels.FirstOrDefault(x => x.Key == valueId).Value; break; case ApplicationCommandOptionType.Role: - this.Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value; + Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value; break; case ApplicationCommandOptionType.Mentionable: { @@ -66,54 +66,54 @@ namespace Discord.WebSocket var guildUser = data.ResolvableData.GuildMembers.FirstOrDefault(x => x.Key == valueId).Value; if (guildUser != null) - this.Value = guildUser; + Value = guildUser; else - this.Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value; + Value = data.ResolvableData.Users.FirstOrDefault(x => x.Key == valueId).Value; } else if(data.ResolvableData.Roles.Any(x => x.Key == valueId)) { - this.Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value; + Value = data.ResolvableData.Roles.FirstOrDefault(x => x.Key == valueId).Value; } } break; default: - this.Value = model.Value.Value; + Value = model.Value.Value; break; } } break; case ApplicationCommandOptionType.String: - this.Value = model.Value.ToString(); + Value = model.Value.ToString(); break; case ApplicationCommandOptionType.Integer: { if (model.Value.Value is long val) - this.Value = val; + Value = val; else if (long.TryParse(model.Value.Value.ToString(), out long res)) - this.Value = res; + Value = res; } break; case ApplicationCommandOptionType.Boolean: { if (model.Value.Value is bool val) - this.Value = val; + Value = val; else if (bool.TryParse(model.Value.Value.ToString(), out bool res)) - this.Value = res; + Value = res; } break; case ApplicationCommandOptionType.Number: { if (model.Value.Value is int val) - this.Value = val; + Value = val; else if (double.TryParse(model.Value.Value.ToString(), out double res)) - this.Value = res; + Value = res; } break; } } - this.Options = model.Options.IsSpecified + Options = model.Options.IsSpecified ? model.Options.Value.Select(x => new SocketSlashCommandDataOption(data, x)).ToImmutableArray() : null; } @@ -130,7 +130,7 @@ namespace Discord.WebSocket #region IApplicationCommandInteractionDataOption IReadOnlyCollection IApplicationCommandInteractionDataOption.Options - => this.Options; + => Options; #endregion } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommand.cs index 2c142e811..f70f5b8a3 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommand.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommand.cs @@ -47,20 +47,20 @@ namespace Discord.WebSocket /// public DateTimeOffset CreatedAt - => SnowflakeUtils.FromSnowflake(this.Id); + => SnowflakeUtils.FromSnowflake(Id); /// /// Returns the guild this command resides in, if this command is a global command then it will return /// public SocketGuild Guild - => GuildId.HasValue ? Discord.GetGuild(this.GuildId.Value) : null; + => GuildId.HasValue ? Discord.GetGuild(GuildId.Value) : null; private ulong? GuildId { get; set; } internal SocketApplicationCommand(DiscordSocketClient client, ulong id, ulong? guildId) : base(client, id) { - this.GuildId = guildId; + GuildId = guildId; } internal static SocketApplicationCommand Create(DiscordSocketClient client, GatewayModel model) { @@ -78,19 +78,19 @@ namespace Discord.WebSocket internal void Update(Model model) { - this.ApplicationId = model.ApplicationId; - this.Description = model.Description; - this.Name = model.Name; - this.DefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); + ApplicationId = model.ApplicationId; + Description = model.Description; + Name = model.Name; + DefaultPermission = model.DefaultPermissions.GetValueOrDefault(true); - this.Options = model.Options.IsSpecified + Options = model.Options.IsSpecified ? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray() : new ImmutableArray(); } /// public Task DeleteAsync(RequestOptions options = null) - => InteractionHelper.DeleteUnknownApplicationCommand(Discord, this.GuildId, this, options); + => InteractionHelper.DeleteUnknownApplicationCommand(Discord, GuildId, this, options); /// public Task ModifyAsync(Action func, RequestOptions options = null) @@ -103,16 +103,16 @@ namespace Discord.WebSocket { Model command = null; - if (this.IsGlobalCommand) + if (IsGlobalCommand) { command = await InteractionHelper.ModifyGlobalCommand(Discord, this, func, options).ConfigureAwait(false); } else { - command = await InteractionHelper.ModifyGuildCommand(Discord, this, this.GuildId.Value, func, options); + command = await InteractionHelper.ModifyGuildCommand(Discord, this, GuildId.Value, func, options); } - this.Update(command); + Update(command); } #endregion diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandChoice.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandChoice.cs index e9809b7ba..0f36af0b8 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandChoice.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandChoice.cs @@ -27,8 +27,8 @@ namespace Discord.WebSocket } internal void Update(Model model) { - this.Name = model.Name; - this.Value = model.Value; + Name = model.Name; + Value = model.Value; } } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandOption.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandOption.cs index 0a90a8073..08b2757cd 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandOption.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketApplicationCommandOption.cs @@ -48,23 +48,23 @@ namespace Discord.WebSocket internal void Update(Model model) { - this.Name = model.Name; - this.Type = model.Type; - this.Description = model.Description; + Name = model.Name; + Type = model.Type; + Description = model.Description; - this.Default = model.Default.IsSpecified + Default = model.Default.IsSpecified ? model.Default.Value : null; - this.Required = model.Required.IsSpecified + Required = model.Required.IsSpecified ? model.Required.Value : null; - this.Choices = model.Choices.IsSpecified + Choices = model.Choices.IsSpecified ? model.Choices.Value.Select(x => SocketApplicationCommandChoice.Create(x)).ToImmutableArray() : new ImmutableArray(); - this.Options = model.Options.IsSpecified + Options = model.Options.IsSpecified ? model.Options.Value.Select(x => SocketApplicationCommandOption.Create(x)).ToImmutableArray() : new ImmutableArray(); } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs index d4b5f952d..d0622196a 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs @@ -41,7 +41,7 @@ namespace Discord.WebSocket : null; ulong? guildId = null; - if (this.Channel is SocketGuildChannel guildChannel) + if (Channel is SocketGuildChannel guildChannel) guildId = guildChannel.Guild.Id; Data = SocketCommandBaseData.Create(client, dataModel, model.Id, guildId); @@ -60,7 +60,7 @@ namespace Discord.WebSocket (DataModel)model.Data.Value : null; - this.Data.Update(data); + Data.Update(data); base.Update(model); } @@ -124,7 +124,7 @@ namespace Discord.WebSocket } }; - await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options); + await InteractionHelper.SendInteractionResponse(Discord, response, Id, Token, options); } /// @@ -285,7 +285,7 @@ namespace Discord.WebSocket } }; - return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); + return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, Id, Token, options); } } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBaseData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBaseData.cs index 64aeb5d24..cac1ce2df 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBaseData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBaseData.cs @@ -25,7 +25,7 @@ namespace Discord.WebSocket internal SocketCommandBaseData(DiscordSocketClient client, Model model, ulong? guildId) : base(client, model.Id) { - this.Type = model.Type; + Type = model.Type; if (model.Resolved.IsSpecified) { @@ -42,7 +42,7 @@ namespace Discord.WebSocket internal virtual void Update(Model model) { - this.Name = model.Name; + Name = model.Name; } IReadOnlyCollection IApplicationCommandInteractionData.Options diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs index 17c96724c..c76bc49c3 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketResolvableData.cs @@ -32,7 +32,7 @@ namespace Discord.WebSocket { var socketUser = discord.GetOrCreateUser(discord.State, user.Value); - this.Users.Add(ulong.Parse(user.Key), socketUser); + Users.Add(ulong.Parse(user.Key), socketUser); } } @@ -56,7 +56,7 @@ namespace Discord.WebSocket } discord.State.AddChannel(socketChannel); - this.Channels.Add(ulong.Parse(channel.Key), socketChannel); + Channels.Add(ulong.Parse(channel.Key), socketChannel); } } @@ -66,7 +66,7 @@ namespace Discord.WebSocket { member.Value.User = resolved.Users.Value[member.Key]; var user = guild.AddOrUpdateUser(member.Value); - this.GuildMembers.Add(ulong.Parse(member.Key), user); + GuildMembers.Add(ulong.Parse(member.Key), user); } } @@ -75,7 +75,7 @@ namespace Discord.WebSocket foreach (var role in resolved.Roles.Value) { var socketRole = guild.AddOrUpdateRole(role.Value); - this.Roles.Add(ulong.Parse(role.Key), socketRole); + Roles.Add(ulong.Parse(role.Key), socketRole); } } @@ -105,7 +105,7 @@ namespace Discord.WebSocket } var message = SocketMessage.Create(discord, discord.State, author, channel, msg.Value); - this.Messages.Add(message.Id, message); + Messages.Add(message.Id, message); } } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs index e98999d11..6a721907a 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs @@ -45,7 +45,7 @@ namespace Discord.WebSocket /// public DateTimeOffset CreatedAt - => SnowflakeUtils.FromSnowflake(this.Id); + => SnowflakeUtils.FromSnowflake(Id); /// /// if the token is valid for replying to, otherwise . @@ -58,7 +58,7 @@ namespace Discord.WebSocket internal SocketInteraction(DiscordSocketClient client, ulong id, ISocketMessageChannel channel) : base(client, id) { - this.Channel = channel; + Channel = channel; } internal static SocketInteraction Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel) @@ -93,24 +93,24 @@ namespace Discord.WebSocket internal virtual void Update(Model model) { - this.Data = model.Data.IsSpecified + Data = model.Data.IsSpecified ? model.Data.Value : null; - this.GuildId = model.GuildId.ToNullable(); - this.Token = model.Token; - this.Version = model.Version; - this.Type = model.Type; + GuildId = model.GuildId.ToNullable(); + Token = model.Token; + Version = model.Version; + Type = model.Type; - if (this.User == null) + if (User == null) { if (model.Member.IsSpecified && model.GuildId.IsSpecified) { - this.User = SocketGuildUser.Create(Discord.State.GetGuild(this.GuildId.Value), Discord.State, model.Member.Value); + User = SocketGuildUser.Create(Discord.State.GetGuild(GuildId.Value), Discord.State, model.Member.Value); } else { - this.User = SocketGlobalUser.Create(this.Discord, this.Discord.State, model.User.Value); + User = SocketGlobalUser.Create(Discord, Discord.State, model.User.Value); } } } @@ -192,7 +192,7 @@ namespace Discord.WebSocket /// The request options for this async request. /// A that represents the initial response. public Task GetOriginalResponseAsync(RequestOptions options = null) - => InteractionHelper.GetOriginalResponseAsync(this.Discord, this.Channel, this, options); + => InteractionHelper.GetOriginalResponseAsync(Discord, Channel, this, options); /// /// Edits original response for this interaction. @@ -202,8 +202,8 @@ namespace Discord.WebSocket /// A that represents the initial response. public async Task ModifyOriginalResponseAsync(Action func, RequestOptions options = null) { - var model = await InteractionHelper.ModifyInteractionResponse(this.Discord, this.Token, func, options); - return RestInteractionMessage.Create(this.Discord, model, this.Token, this.Channel); + var model = await InteractionHelper.ModifyInteractionResponse(Discord, Token, func, options); + return RestInteractionMessage.Create(Discord, model, Token, Channel); } /// @@ -219,7 +219,7 @@ namespace Discord.WebSocket private bool CheckToken() { // Tokens last for 15 minutes according to https://discord.com/developers/docs/interactions/slash-commands#responding-to-an-interaction - return (DateTime.UtcNow - this.CreatedAt.UtcDateTime).TotalMinutes <= 15d; + return (DateTime.UtcNow - CreatedAt.UtcDateTime).TotalMinutes <= 15d; } #endregion diff --git a/src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs b/src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs index 586a192dc..9acc20a14 100644 --- a/src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs +++ b/src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs @@ -27,7 +27,7 @@ namespace Discord.WebSocket /// /// public SocketGuildUser Author - => this.AuthorId.HasValue ? Guild.GetUser(this.AuthorId.Value) : null; + => AuthorId.HasValue ? Guild.GetUser(AuthorId.Value) : null; /// /// Gets the guild the sticker was created in. @@ -40,8 +40,8 @@ namespace Discord.WebSocket internal SocketCustomSticker(DiscordSocketClient client, ulong id, SocketGuild guild, ulong? authorId = null) : base(client, id) { - this.Guild = guild; - this.AuthorId = authorId; + Guild = guild; + AuthorId = authorId; } internal static SocketCustomSticker Create(DiscordSocketClient client, Model model, SocketGuild guild, ulong? authorId = null) @@ -57,16 +57,16 @@ namespace Discord.WebSocket if(!Guild.CurrentUser.GuildPermissions.Has(GuildPermission.ManageEmojisAndStickers)) throw new InvalidOperationException($"Missing permission {nameof(GuildPermission.ManageEmojisAndStickers)}"); - var model = await GuildHelper.ModifyStickerAsync(this.Discord, this.Guild.Id, this, func, options); + var model = await GuildHelper.ModifyStickerAsync(Discord, Guild.Id, this, func, options); - this.Update(model); + Update(model); } /// public async Task DeleteAsync(RequestOptions options = null) { - await GuildHelper.DeleteStickerAsync(Discord, this.Guild.Id, this, options); - Guild.RemoveSticker(this.Id); + await GuildHelper.DeleteStickerAsync(Discord, Guild.Id, this, options); + Guild.RemoveSticker(Id); } internal SocketCustomSticker Clone() => MemberwiseClone() as SocketCustomSticker; @@ -76,10 +76,10 @@ namespace Discord.WebSocket #region ICustomSticker ulong? ICustomSticker.AuthorId - => this.AuthorId; + => AuthorId; IGuild ICustomSticker.Guild - => this.Guild; + => Guild; #endregion } } diff --git a/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs b/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs index 5e4e09aa8..a1c2f1002 100644 --- a/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs +++ b/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs @@ -42,7 +42,7 @@ namespace Discord.WebSocket /// public string GetStickerUrl() - => CDN.GetStickerUrl(this.Id, this.Format); + => CDN.GetStickerUrl(Id, Format); internal SocketSticker(DiscordSocketClient client, ulong id) : base(client, id) { } @@ -62,21 +62,21 @@ namespace Discord.WebSocket internal virtual void Update(Model model) { - this.Name = model.Name; - this.Description = model.Desription; - this.PackId = model.PackId; - this.Available = model.Available; - this.Format = model.FormatType; - this.Type = model.Type; - this.SortOrder = model.SortValue; + Name = model.Name; + Description = model.Desription; + PackId = model.PackId; + Available = model.Available; + Format = model.FormatType; + Type = model.Type; + SortOrder = model.SortValue; if (model.Tags.IsSpecified) { - this.Tags = model.Tags.Value.Split(',').Select(x => x.Trim()).ToImmutableArray(); + Tags = model.Tags.Value.Split(',').Select(x => x.Trim()).ToImmutableArray(); } else { - this.Tags = ImmutableArray.Empty; + Tags = ImmutableArray.Empty; } } @@ -87,15 +87,15 @@ namespace Discord.WebSocket { if (obj is API.Sticker stickerModel) { - return stickerModel.Name == this.Name && - stickerModel.Desription == this.Description && - stickerModel.FormatType == this.Format && - stickerModel.Id == this.Id && - stickerModel.PackId == this.PackId && - stickerModel.Type == this.Type && - stickerModel.SortValue == this.SortOrder && - stickerModel.Available == this.Available && - (!stickerModel.Tags.IsSpecified || stickerModel.Tags.Value == string.Join(", ", this.Tags)); + return stickerModel.Name == Name && + stickerModel.Desription == Description && + stickerModel.FormatType == Format && + stickerModel.Id == Id && + stickerModel.PackId == PackId && + stickerModel.Type == Type && + stickerModel.SortValue == SortOrder && + stickerModel.Available == Available && + (!stickerModel.Tags.IsSpecified || stickerModel.Tags.Value == string.Join(", ", Tags)); } else return base.Equals(obj); diff --git a/src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs b/src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs index da8199c4c..db1124a32 100644 --- a/src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs +++ b/src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs @@ -49,8 +49,8 @@ namespace Discord.WebSocket internal void Update(Model model) { - this.Name = model.Name; - this.Format = model.FormatType; + Name = model.Name; + Format = model.FormatType; } /// @@ -60,7 +60,7 @@ namespace Discord.WebSocket /// The sticker representing this unknown stickers Id, if none is found then . /// public Task ResolveAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null) - => Discord.GetStickerAsync(this.Id, mode, options); + => Discord.GetStickerAsync(Id, mode, options); private new string DebuggerDisplay => $"{Name} ({Id})"; } diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs index f892216d9..2cec3d612 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs @@ -136,9 +136,9 @@ namespace Discord.WebSocket internal SocketThreadUser(SocketGuild guild, SocketThreadChannel thread, SocketGuildUser member) : base(guild.Discord, member.Id) { - this.Thread = thread; - this.Guild = guild; - this.GuildUser = member; + Thread = thread; + Guild = guild; + GuildUser = member; } internal static SocketThreadUser Create(SocketGuild guild, SocketThreadChannel thread, Model model, SocketGuildUser member) @@ -150,16 +150,16 @@ namespace Discord.WebSocket internal void Update(Model model) { - this.ThreadJoinedAt = model.JoinTimestamp; + ThreadJoinedAt = model.JoinTimestamp; if (model.Presence.IsSpecified) { - this.GuildUser.Update(Discord.State, model.Presence.Value, true); + GuildUser.Update(Discord.State, model.Presence.Value, true); } if (model.Member.IsSpecified) { - this.GuildUser.Update(Discord.State, model.Member.Value); + GuildUser.Update(Discord.State, model.Member.Value); } } @@ -198,16 +198,16 @@ namespace Discord.WebSocket public Task RemoveRolesAsync(IEnumerable roles, RequestOptions options = null) => GuildUser.RemoveRolesAsync(roles, options); /// - GuildPermissions IGuildUser.GuildPermissions => this.GuildUser.GuildPermissions; + GuildPermissions IGuildUser.GuildPermissions => GuildUser.GuildPermissions; /// - IGuild IGuildUser.Guild => this.Guild; + IGuild IGuildUser.Guild => Guild; /// - ulong IGuildUser.GuildId => this.Guild.Id; + ulong IGuildUser.GuildId => Guild.Id; /// - IReadOnlyCollection IGuildUser.RoleIds => this.GuildUser.Roles.Select(x => x.Id).ToImmutableArray(); + IReadOnlyCollection IGuildUser.RoleIds => GuildUser.Roles.Select(x => x.Id).ToImmutableArray(); internal override SocketGlobalUser GlobalUser => GuildUser.GlobalUser; diff --git a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs index 5ae6f528e..87d915494 100644 --- a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs +++ b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticResult.cs @@ -20,9 +20,9 @@ namespace TestHelper throw new ArgumentOutOfRangeException(nameof(column), "column must be >= -1"); } - this.Path = path; - this.Line = line; - this.Column = column; + Path = path; + Line = line; + Column = column; } public string Path { get; } @@ -41,16 +41,16 @@ namespace TestHelper { get { - if (this.locations == null) + if (locations == null) { - this.locations = new DiagnosticResultLocation[] { }; + locations = new DiagnosticResultLocation[] { }; } - return this.locations; + return locations; } set { - this.locations = value; + locations = value; } } @@ -64,7 +64,7 @@ namespace TestHelper { get { - return this.Locations.Length > 0 ? this.Locations[0].Path : ""; + return Locations.Length > 0 ? Locations[0].Path : ""; } } @@ -72,7 +72,7 @@ namespace TestHelper { get { - return this.Locations.Length > 0 ? this.Locations[0].Line : -1; + return Locations.Length > 0 ? Locations[0].Line : -1; } } @@ -80,7 +80,7 @@ namespace TestHelper { get { - return this.Locations.Length > 0 ? this.Locations[0].Column : -1; + return Locations.Length > 0 ? Locations[0].Column : -1; } } } diff --git a/test/Discord.Net.Tests.Integration/ChannelsTests.cs b/test/Discord.Net.Tests.Integration/ChannelsTests.cs index 3bf60772f..9bb30c4ef 100644 --- a/test/Discord.Net.Tests.Integration/ChannelsTests.cs +++ b/test/Discord.Net.Tests.Integration/ChannelsTests.cs @@ -19,7 +19,7 @@ namespace Discord public ChannelsTests(RestGuildFixture guildFixture, ITestOutputHelper output) { guild = guildFixture.Guild; - this.output = output; + output = output; output.WriteLine($"RestGuildFixture using guild: {guild.Id}"); // capture all console output guildFixture.Client.Log += LogAsync; diff --git a/test/Discord.Net.Tests.Integration/GuildTests.cs b/test/Discord.Net.Tests.Integration/GuildTests.cs index 40394a3a0..c309b0ed1 100644 --- a/test/Discord.Net.Tests.Integration/GuildTests.cs +++ b/test/Discord.Net.Tests.Integration/GuildTests.cs @@ -18,7 +18,7 @@ namespace Discord { client = guildFixture.Client; guild = guildFixture.Guild; - this.output = output; + output = output; output.WriteLine($"RestGuildFixture using guild: {guild.Id}"); guildFixture.Client.Log += LogAsync; }