From b88525aa98e0eb0dd78d54cbdfb81be267d45eea Mon Sep 17 00:00:00 2001 From: quin lynch Date: Tue, 21 Sep 2021 15:26:11 -0300 Subject: [PATCH 01/27] Add components and stickers to ReplyAsync extension --- src/Discord.Net.Core/Extensions/MessageExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Core/Extensions/MessageExtensions.cs b/src/Discord.Net.Core/Extensions/MessageExtensions.cs index b043d7b77..6d068d160 100644 --- a/src/Discord.Net.Core/Extensions/MessageExtensions.cs +++ b/src/Discord.Net.Core/Extensions/MessageExtensions.cs @@ -87,9 +87,9 @@ namespace Discord /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - public static async Task ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null) + public static async Task ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, ISticker[] stickers = null) { - return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id)).ConfigureAwait(false); + return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id), components, stickers).ConfigureAwait(false); } } } From 5987af766adbd02ca1ddbc973ba7dd0e9e10388c Mon Sep 17 00:00:00 2001 From: drobbins329 Date: Wed, 22 Sep 2021 10:02:13 -0400 Subject: [PATCH 02/27] Added SendMessagesInThreads and StartEmbeddedActivities. (#175) * Added SendMessagesInThreads and StartEmbeddedActivities. Adjusted owner perms. Change UsePublicThreads -> CreatePublicThreads Change UsePrivateThreads -> CreatePrivateThreads * removed extra /// * Added UsePublicThreads and UsePrivateThreads back with Obsolete Attribute * removed 'false' from Obsolete Attribute --- .../Entities/Permissions/GuildPermission.cs | 28 ++++++++-- .../Entities/Permissions/GuildPermissions.cs | 51 ++++++++++++------- 2 files changed, 56 insertions(+), 23 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs index 89ee20b9f..53b666b1a 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs @@ -192,17 +192,35 @@ namespace Discord /// ManageThreads = 0x04_00_00_00_00, /// - /// Allows for creating and participating in threads. + /// Allows for creating public threads. /// - UsePublicThreads = 0x08_00_00_00_00, + CreatePublicThreads = 0x08_00_00_00_00, /// - /// Allows for creating and participating in private threads. + /// Allows for creating private threads. /// - UsePrivateThreads = 0x10_00_00_00_00, + CreatePrivateThreads = 0x10_00_00_00_00, + /// + /// Allows for creating public threads. + /// + [Obsolete("UsePublicThreads has been replaced by CreatePublicThreads and SendMessagesInThreads")] + UsePublicThreads = 0x08_00_00_00_00, + /// + /// Allows for creating private threads. + /// + [Obsolete("UsePrivateThreads has been replaced by CreatePrivateThreads and SendMessagesInThreads")] + UsePrivateThreads = 0x10_00_00_00_00, /// /// Allows the usage of custom stickers from other servers. /// - UseExternalStickers = 0x20_00_00_00_00 + UseExternalStickers = 0x20_00_00_00_00, + /// + /// Allows for sending messages in threads. + /// + SendMessagesInThreads = 0x40_00_00_00_00, + /// + /// Allows for launching activities (applications with the EMBEDDED flag) in a voice channel. + /// + StartEmbeddedActivities = 0x80_00_00_00_00 } } diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs index 6c03ed0ad..05a2a7680 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs @@ -12,7 +12,7 @@ namespace Discord /// Gets a that grants all guild permissions for webhook users. public static readonly GuildPermissions Webhook = new GuildPermissions(0b00000_0000000_0001101100000_000000); /// Gets a that grants all guild permissions. - public static readonly GuildPermissions All = new GuildPermissions(0b11111111_11111_1111111_1111111111111_11111); + public static readonly GuildPermissions All = new GuildPermissions(0b1111111111_11111_1111111_1111111111111_11111); /// Gets a packed value representing all the permissions in this . public ulong RawValue { get; } @@ -90,11 +90,15 @@ namespace Discord /// If true, a user may manage threads in this guild. public bool ManageThreads => Permissions.GetValue(RawValue, GuildPermission.ManageThreads); /// If true, a user may create public threads in this guild. - public bool UsePublicThreads => Permissions.GetValue(RawValue, GuildPermission.UsePublicThreads); + public bool CreatePublicThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePublicThreads); /// If true, a user may create private threads in this guild. - public bool UsePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.UsePrivateThreads); + public bool CreatePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePrivateThreads); /// If true, a user may use external stickers in this guild. public bool UseExternalStickers => Permissions.GetValue(RawValue, GuildPermission.UseExternalStickers); + /// If true, a user may send messages in threads in this guild. + public bool SendMessagesInThreads => Permissions.GetValue(RawValue, GuildPermission.SendMessagesInThreads); + /// If true, a user launch application activites in voice channels in this guild. + public bool StartEmbeddedActivities => Permissions.GetValue(RawValue, GuildPermission.StartEmbeddedActivities); /// Creates a new with the provided packed value. public GuildPermissions(ulong rawValue) { RawValue = rawValue; } @@ -137,9 +141,11 @@ namespace Discord bool? useSlashCommands = null, bool? requestToSpeak = null, bool? manageThreads = null, - bool? usePublicThreads = null, - bool? usePrivateThreads = null, - bool? useExternalStickers = null) + bool? createPublicThreads = null, + bool? createPrivateThreads = null, + bool? useExternalStickers = null, + bool? sendMessagesInThreads = null, + bool? startEmbeddedActivities = null) { ulong value = initialValue; @@ -177,9 +183,11 @@ namespace Discord Permissions.SetValue(ref value, useSlashCommands, GuildPermission.UseSlashCommands); Permissions.SetValue(ref value, requestToSpeak, GuildPermission.RequestToSpeak); Permissions.SetValue(ref value, manageThreads, GuildPermission.ManageThreads); - Permissions.SetValue(ref value, usePublicThreads, GuildPermission.UsePublicThreads); - Permissions.SetValue(ref value, usePrivateThreads, GuildPermission.UseExternalStickers); + Permissions.SetValue(ref value, createPublicThreads, GuildPermission.CreatePublicThreads); + Permissions.SetValue(ref value, createPrivateThreads, GuildPermission.CreatePrivateThreads); Permissions.SetValue(ref value, useExternalStickers, GuildPermission.UseExternalStickers); + Permissions.SetValue(ref value, sendMessagesInThreads, GuildPermission.SendMessagesInThreads); + Permissions.SetValue(ref value, startEmbeddedActivities, GuildPermission.StartEmbeddedActivities); RawValue = value; } @@ -220,9 +228,11 @@ namespace Discord bool useSlashCommands = false, bool requestToSpeak = false, bool manageThreads = false, - bool usePublicThreads = false, - bool usePrivateThreads = false, - bool useExternalStickers = false) + bool createPublicThreads = false, + bool createPrivateThreads = false, + bool useExternalStickers = false, + bool sendMessagesInThreads = false, + bool startEmbeddedActivities = false) : this(0, createInstantInvite: createInstantInvite, manageRoles: manageRoles, @@ -258,9 +268,11 @@ namespace Discord useSlashCommands: useSlashCommands, requestToSpeak: requestToSpeak, manageThreads: manageThreads, - usePublicThreads: usePublicThreads, - usePrivateThreads: usePrivateThreads, - useExternalStickers: useExternalStickers) + createPublicThreads: createPublicThreads, + createPrivateThreads: createPrivateThreads, + useExternalStickers: useExternalStickers, + sendMessagesInThreads: sendMessagesInThreads, + startEmbeddedActivities: startEmbeddedActivities) { } /// Creates a new from this one, changing the provided non-null permissions. @@ -299,14 +311,17 @@ namespace Discord bool? useSlashCommands = null, bool? requestToSpeak = null, bool? manageThreads = null, - bool? usePublicThreads = null, - bool? usePrivateThreads = null, - bool? useExternalStickers = null) + bool? createPublicThreads = null, + bool? createPrivateThreads = null, + bool? useExternalStickers = null, + bool? sendMessagesInThreads = null, + bool? startEmbeddedActivities = null) => new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions, viewAuditLog, viewGuildInsights, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojisAndStickers, - useSlashCommands, requestToSpeak, manageThreads, usePublicThreads, usePrivateThreads, useExternalStickers); + useSlashCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, + startEmbeddedActivities); /// /// Returns a value that indicates if a specific is enabled From 016c1dc80aabdd49f6ff355ff15dba6fbf30e2d8 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Thu, 23 Sep 2021 07:03:14 -0300 Subject: [PATCH 03/27] Squashed commit of the following: commit dca41a348e36a9b4e7006ef3a76377eb32aad276 Author: quin lynch Date: Thu Sep 23 07:02:19 2021 -0300 Autocomplete commands --- src/Discord.Net.Core/Discord.Net.Core.csproj | 2 +- src/Discord.Net.Core/Discord.Net.Core.xml | 154 +++++++++++++++--- .../Interactions/ApplicationCommandOption.cs | 18 +- .../Interactions/AutocompleteOption.cs | 42 +++++ .../Interactions/AutocompleteResult.cs | 90 ++++++++++ .../Interactions/InteractionResponseType.cs | 11 +- .../Entities/Interactions/InteractionType.cs | 5 + .../SlashCommandBuilder.cs | 25 ++- .../SlashCommandProperties.cs | 0 .../API/Common/ApplicationCommandOption.cs | 4 + .../API/Common/AutocompleteInteractionData.cs | 27 +++ .../AutocompleteInteractionDataOption.cs | 24 +++ .../API/Common/InteractionCallbackData.cs | 3 + .../Interactions/InteractionHelper.cs | 22 +++ .../Net/Converters/InteractionConverter.cs | 7 + .../Discord.Net.WebSocket.xml | 104 +++++++++++- .../SocketAutocompleteInteraction.cs | 97 +++++++++++ .../SocketAutocompleteInteractionData.cs | 60 +++++++ .../SocketBaseCommand/SocketCommandBase.cs | 14 +- .../Entities/Interaction/SocketInteraction.cs | 29 ++-- 20 files changed, 681 insertions(+), 57 deletions(-) create mode 100644 src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs create mode 100644 src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs rename src/Discord.Net.Core/Entities/Interactions/{ => Slash Commands}/SlashCommandBuilder.cs (95%) rename src/Discord.Net.Core/Entities/Interactions/{ => Slash Commands}/SlashCommandProperties.cs (100%) create mode 100644 src/Discord.Net.Rest/API/Common/AutocompleteInteractionData.cs create mode 100644 src/Discord.Net.Rest/API/Common/AutocompleteInteractionDataOption.cs create mode 100644 src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs create mode 100644 src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs diff --git a/src/Discord.Net.Core/Discord.Net.Core.csproj b/src/Discord.Net.Core/Discord.Net.Core.csproj index a5fdbf230..7f494db1a 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.csproj +++ b/src/Discord.Net.Core/Discord.Net.Core.csproj @@ -1,4 +1,4 @@ - + diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index 9ca871377..ece4d69d4 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -4508,37 +4508,42 @@ - The name of this option. + Gets or sets the name of this option. - The description of this option. + Gets or sets the description of this option. - The type of this option. + Gets or sets the type of this option. - The first required option for the user to complete. only one option can be default. + Gets or sets whether or not this options is the first required option for the user to complete. only one option can be default. - if this option is required for this command, otherwise . + Gets or sets if the option is required. + + + + + Gets or sets whether or not this option supports autocomplete - choices for string and int types for the user to pick from. + Gets or sets the choices for string and int types for the user to pick from. - If the option is a subcommand or subcommand group type, this nested options will be the parameters. + Gets or sets if this option is a subcommand or subcommand group type, these nested options will be the parameters. @@ -4649,6 +4654,68 @@ ApplicationCommandType.Message is Context Menu Message command type + + + Represents an autocomplete option. + + + + + Gets the type of this option + + + + + Gets the name of the option. + + + + + Gets the value of the option. + + + + + Gets whether or not this option is focused by the executing user. + + + + + Represents a result to an autocomplete interaction. + + + + + Gets or sets the name of the result. + + + Name cannot be null and has to be between 1-100 characters in length. + + + + + + + Gets or sets the value of the result. + + + Only , , and are allowed for a value. + + + + + + + Creates a new . + + + + + Creates a new with the passed in and . + + + + A class used to build Message commands. @@ -5029,12 +5096,17 @@ - for components: ACK an interaction and edit the original message later; the user does not see a loading state + For components: ACK an interaction and edit the original message later; the user does not see a loading state - for components: edit the message the component was attached to + For components: edit the message the component was attached to + + + + + Respond with a set of choices to a autocomplete interaction @@ -5057,6 +5129,11 @@ A sent from discord. + + + An autocomplete request sent from discord. + + Represents a Row for child components to live in. @@ -5934,7 +6011,7 @@ The default permission value to set. The current builder. - + Adds an option to the current slash command. @@ -5987,37 +6064,42 @@ - The name of this option. + Gets or sets the name of this option. - The description of this option. + Gets or sets the description of this option. - The type of this option. + Gets or sets the type of this option. - The first required option for the user to complete. only one option can be default. + Gets or sets whether or not this options is the first required option for the user to complete. only one option can be default. - if this option is required for this command, otherwise . + Gets or sets if the option is required. + + + + + Gets or sets whether or not this option supports autocomplete. - choices for string and int types for the user to pick from. + Gets or sets the choices for string and int types for the user to pick from. - If the option is a subcommand or subcommand group type, this nested options will be the parameters. + Gets or sets if this option is a subcommand or subcommand group type, these nested options will be the parameters. @@ -8876,14 +8958,24 @@ authentication when used on a guild that has server-wide 2FA enabled. + + + Allows for creating public threads. + + + + + Allows for creating private threads. + + - Allows for creating and participating in threads. + Allows for creating public threads. - Allows for creating and participating in private threads. + Allows for creating private threads. @@ -8891,6 +8983,16 @@ Allows the usage of custom stickers from other servers. + + + Allows for sending messages in threads. + + + + + Allows for launching activities (applications with the EMBEDDED flag) in a voice channel. + + Gets a blank that grants no permissions. @@ -9005,25 +9107,31 @@ If true, a user may manage threads in this guild. - + If true, a user may create public threads in this guild. - + If true, a user may create private threads in this guild. If true, a user may use external stickers in this guild. + + If true, a user may send messages in threads in this guild. + + + If true, a user launch application activites in voice channels in this guild. + Creates a new with the provided packed value. Creates a new with the provided packed value after converting to ulong. - + Creates a new structure with the provided permissions. - + Creates a new from this one, changing the provided non-null permissions. diff --git a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs index 8d6e22ec1..cca832874 100644 --- a/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs +++ b/src/Discord.Net.Core/Entities/Interactions/ApplicationCommandOption.cs @@ -16,7 +16,7 @@ namespace Discord private string _description; /// - /// The name of this option. + /// Gets or sets the name of this option. /// public string Name { @@ -37,7 +37,7 @@ namespace Discord } /// - /// The description of this option. + /// Gets or sets the description of this option. /// public string Description { @@ -53,27 +53,31 @@ namespace Discord } /// - /// The type of this option. + /// Gets or sets the type of this option. /// public ApplicationCommandOptionType Type { get; set; } /// - /// The first required option for the user to complete. only one option can be default. + /// Gets or sets whether or not this options is the first required option for the user to complete. only one option can be default. /// public bool? Default { get; set; } /// - /// if this option is required for this command, otherwise . + /// Gets or sets if the option is required. /// public bool? Required { get; set; } /// - /// choices for string and int types for the user to pick from. + /// Gets or sets whether or not this option supports autocomplete. + /// + public bool Autocomplete { get; set; } + /// + /// Gets or sets the choices for string and int types for the user to pick from. /// public List Choices { get; set; } /// - /// If the option is a subcommand or subcommand group type, this nested options will be the parameters. + /// Gets or sets if this option is a subcommand or subcommand group type, these nested options will be the parameters. /// public List Options { get; set; } diff --git a/src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs b/src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs new file mode 100644 index 000000000..9fe461d6f --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/AutocompleteOption.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Discord +{ + /// + /// Represents an autocomplete option. + /// + public class AutocompleteOption + { + /// + /// Gets the type of this option + /// + public ApplicationCommandOptionType Type { get; } + + /// + /// Gets the name of the option. + /// + public string Name { get; } + + /// + /// Gets the value of the option. + /// + public object Value { get; } + + /// + /// Gets whether or not this option is focused by the executing user. + /// + public bool Focused { get; } + + internal AutocompleteOption(ApplicationCommandOptionType type, string name, object value, bool focused) + { + this.Type = type; + this.Name = name; + this.Value = value; + this.Focused = focused; + } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs new file mode 100644 index 000000000..881eef80d --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Discord +{ + /// + /// Represents a result to an autocomplete interaction. + /// + public class AutocompleteResult + { + private object _value { get; set; } + private string _name { get; set; } + + /// + /// Gets or sets the name of the result. + /// + /// + /// Name cannot be null and has to be between 1-100 characters in length. + /// + /// + /// + public string Name + { + get => _name; + set + { + if (value == null) + throw new ArgumentException("Name cannot be null!"); + if (value.Length > 100) + throw new ArgumentException("Name length must be less than or equal to 100 characters in length!"); + if (value.Length < 1) + throw new ArgumentException("Name length must at least 1 character in length!"); + _name = value; + } + } + + /// + /// Gets or sets the value of the result. + /// + /// + /// Only , , and are allowed for a value. + /// + /// + /// + public object Value + { + get => _value; + set + { + if (value == null) + throw new ArgumentNullException("Value cannot be null"); + + switch (value) + { + case string str: + _value = str; + break; + case int integer: + _value = integer; + break; + case double number: + _value = number; + break; + + default: + throw new ArgumentException($"Type {value.GetType().Name} cannot be set as a value! Only string, int, and double allowed!"); + } + } + } + + /// + /// Creates a new . + /// + public AutocompleteResult() { } + + /// + /// Creates a new with the passed in and . + /// + /// + /// + public AutocompleteResult(string name, object value) + { + this.Name = name; + this.Value = value; + } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/InteractionResponseType.cs b/src/Discord.Net.Core/Entities/Interactions/InteractionResponseType.cs index d34c282ef..de30ad868 100644 --- a/src/Discord.Net.Core/Entities/Interactions/InteractionResponseType.cs +++ b/src/Discord.Net.Core/Entities/Interactions/InteractionResponseType.cs @@ -45,13 +45,18 @@ namespace Discord DeferredChannelMessageWithSource = 5, /// - /// for components: ACK an interaction and edit the original message later; the user does not see a loading state + /// For components: ACK an interaction and edit the original message later; the user does not see a loading state /// DeferredUpdateMessage = 6, /// - /// for components: edit the message the component was attached to + /// For components: edit the message the component was attached to /// - UpdateMessage = 7 + UpdateMessage = 7, + + /// + /// Respond with a set of choices to a autocomplete interaction + /// + ApplicationCommandAutocompleteResult = 8 } } diff --git a/src/Discord.Net.Core/Entities/Interactions/InteractionType.cs b/src/Discord.Net.Core/Entities/Interactions/InteractionType.cs index 4da39b58e..989114505 100644 --- a/src/Discord.Net.Core/Entities/Interactions/InteractionType.cs +++ b/src/Discord.Net.Core/Entities/Interactions/InteractionType.cs @@ -25,5 +25,10 @@ namespace Discord /// A sent from discord. /// MessageComponent = 3, + + /// + /// An autocomplete request sent from discord. + /// + ApplicationCommandAutocomplete = 4, } } diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommandBuilder.cs b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs similarity index 95% rename from src/Discord.Net.Core/Entities/Interactions/SlashCommandBuilder.cs rename to src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs index 0f3ae1d2d..1a152feb4 100644 --- a/src/Discord.Net.Core/Entities/Interactions/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs @@ -165,7 +165,7 @@ namespace Discord /// The choices of this option. /// The current builder. public SlashCommandBuilder AddOption(string name, ApplicationCommandOptionType type, - string description, bool required = true, bool isDefault = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) + string description, bool required = true, bool isDefault = false, bool isAutocomplete = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) { // Make sure the name matches the requirements from discord Preconditions.NotNullOrEmpty(name, nameof(name)); @@ -197,6 +197,7 @@ namespace Discord option.Default = isDefault; option.Options = options; option.Type = type; + option.Autocomplete = isAutocomplete; option.Choices = choices != null ? new List(choices) : null; return AddOption(option); @@ -288,7 +289,7 @@ namespace Discord private string _description; /// - /// The name of this option. + /// Gets or sets the name of this option. /// public string Name { @@ -309,7 +310,7 @@ namespace Discord } /// - /// The description of this option. + /// Gets or sets the description of this option. /// public string Description { @@ -326,27 +327,32 @@ namespace Discord } /// - /// The type of this option. + /// Gets or sets the type of this option. /// public ApplicationCommandOptionType Type { get; set; } /// - /// The first required option for the user to complete. only one option can be default. + /// Gets or sets whether or not this options is the first required option for the user to complete. only one option can be default. /// public bool? Default { get; set; } /// - /// if this option is required for this command, otherwise . + /// Gets or sets if the option is required. /// public bool Required { get; set; } /// - /// choices for string and int types for the user to pick from. + /// Gets or sets whether or not this option supports autocomplete. + /// + public bool Autocomplete { get; set; } + + /// + /// Gets or sets the choices for string and int types for the user to pick from. /// public List Choices { get; set; } /// - /// If the option is a subcommand or subcommand group type, this nested options will be the parameters. + /// Gets or sets if this option is a subcommand or subcommand group type, these nested options will be the parameters. /// public List Options { get; set; } @@ -372,7 +378,8 @@ namespace Discord Required = this.Required, Type = this.Type, Options = this.Options?.Count > 0 ? new List(this.Options.Select(x => x.Build())) : null, - Choices = this.Choices + Choices = this.Choices, + Autocomplete = this.Autocomplete }; } diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommandProperties.cs b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandProperties.cs similarity index 100% rename from src/Discord.Net.Core/Entities/Interactions/SlashCommandProperties.cs rename to src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandProperties.cs diff --git a/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs b/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs index 3a9411720..2169e601e 100644 --- a/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs +++ b/src/Discord.Net.Rest/API/Common/ApplicationCommandOption.cs @@ -30,6 +30,9 @@ namespace Discord.API [JsonProperty("options")] public Optional Options { get; set; } + [JsonProperty("autocomplete")] + public Optional Autocomplete { get; set; } + public ApplicationCommandOption() { } public ApplicationCommandOption(IApplicationCommandOption cmd) @@ -78,6 +81,7 @@ namespace Discord.API this.Name = option.Name; this.Type = option.Type; this.Description = option.Description; + this.Autocomplete = option.Autocomplete; } } } diff --git a/src/Discord.Net.Rest/API/Common/AutocompleteInteractionData.cs b/src/Discord.Net.Rest/API/Common/AutocompleteInteractionData.cs new file mode 100644 index 000000000..ea2cd4fd9 --- /dev/null +++ b/src/Discord.Net.Rest/API/Common/AutocompleteInteractionData.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Discord.API +{ + internal class AutocompleteInteractionData : IDiscordInteractionData + { + [JsonProperty("id")] + public ulong Id { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("type")] + public ApplicationCommandType Type { get; set; } + + [JsonProperty("version")] + public ulong Version { get; set; } + + [JsonProperty("options")] + public AutocompleteInteractionDataOption[] Options { get; set; } + } +} diff --git a/src/Discord.Net.Rest/API/Common/AutocompleteInteractionDataOption.cs b/src/Discord.Net.Rest/API/Common/AutocompleteInteractionDataOption.cs new file mode 100644 index 000000000..a9d5b66f0 --- /dev/null +++ b/src/Discord.Net.Rest/API/Common/AutocompleteInteractionDataOption.cs @@ -0,0 +1,24 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Discord.API +{ + internal class AutocompleteInteractionDataOption + { + [JsonProperty("type")] + public ApplicationCommandOptionType Type { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("value")] + public object Value { get; set; } + + [JsonProperty("focused")] + public bool Focused { get; set; } + } +} diff --git a/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs b/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs index 2101f79f4..38b35c8ec 100644 --- a/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs +++ b/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs @@ -21,5 +21,8 @@ namespace Discord.API [JsonProperty("components")] public Optional Components { get; set; } + + [JsonProperty("choices")] + public Optional Choices { get; set; } } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs index ce7953e1e..52449a121 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs @@ -418,6 +418,28 @@ namespace Discord.Rest public static async Task DeletedInteractionResponse(BaseDiscordClient client, RestInteractionMessage message, RequestOptions options = null) => await client.ApiClient.DeleteInteractionFollowupMessageAsync(message.Id, message.Token, options); + + public static Task SendAutocompleteResult(BaseDiscordClient client, IEnumerable result, ulong interactionId, + string interactionToken, RequestOptions options) + { + if (result == null) + result = new AutocompleteResult[0]; + + Preconditions.AtMost(result.Count(), 20, nameof(result), "A maximum of 20 choices are allowed!"); + + var apiArgs = new InteractionResponse() + { + Type = InteractionResponseType.ApplicationCommandAutocompleteResult, + Data = new InteractionCallbackData() + { + Choices = result.Any() + ? result.Select(x => new API.ApplicationCommandOptionChoice() { Name = x.Name, Value = x.Value }).ToArray() + : new ApplicationCommandOptionChoice[0] + } + }; + + return client.ApiClient.CreateInteractionResponseAsync(apiArgs, interactionId, interactionToken, options); + } #endregion #region Guild permissions diff --git a/src/Discord.Net.Rest/Net/Converters/InteractionConverter.cs b/src/Discord.Net.Rest/Net/Converters/InteractionConverter.cs index cda3b1e24..8159165c9 100644 --- a/src/Discord.Net.Rest/Net/Converters/InteractionConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/InteractionConverter.cs @@ -53,6 +53,13 @@ namespace Discord.Net.Converters interaction.Data = messageComponent; } break; + case InteractionType.ApplicationCommandAutocomplete: + { + var autocompleteData = new API.AutocompleteInteractionData(); + serializer.Populate(result.CreateReader(), autocompleteData); + interaction.Data = autocompleteData; + } + break; } } else diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index dd0866f0c..c08906290 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -3961,6 +3961,98 @@ The value(s) of a interaction response. + + + Represents a received over the gateway. + + + + + The autocomplete data of this interaction. + + + + + Responds to this interaction with a set of choices. + + + The set of choices for the user to pick from. + + A max of 20 choices are allowed. Passing for this argument will show the executing user that + there is no choices for their autocompleted input. + + + The request options for this response. + + A task that represents the asynchronous operation of responding to this interaction. + + + + + Responds to this interaction with a set of choices. + + The request options for this response. + + The set of choices for the user to pick from. + + A max of 20 choices are allowed. Passing for this argument will show the executing user that + there is no choices for their autocompleted input. + + + + A task that represents the asynchronous operation of responding to this interaction. + + + + + + + + + + + + + + + + + + + + Represents data for a slash commands autocomplete interaction. + + + + + Gets the name of the invoked command. + + + + + Gets the id of the invoked command. + + + + + Gets the type of the invoked command. + + + + + Gets the version of the invoked command. + + + + + Gets the current autocomplete option that is activly being filled out. + + + + + Gets a collection of all the other options the executing users has filled out. + + Represents a Websocket-based slash command received over the gateway. @@ -4088,7 +4180,17 @@ - Base class for User, Message, and Slash command interactions + Base class for User, Message, and Slash command interactions. + + + + + Gets the name of the invoked command. + + + + + Gets the id of the invoked command. diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs new file mode 100644 index 000000000..fe6322392 --- /dev/null +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteraction.cs @@ -0,0 +1,97 @@ +using Discord.Rest; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Model = Discord.API.Interaction; +using DataModel = Discord.API.AutocompleteInteractionData; + + +namespace Discord.WebSocket +{ + /// + /// Represents a received over the gateway. + /// + public class SocketAutocompleteInteraction : SocketInteraction + { + /// + /// The autocomplete data of this interaction. + /// + public new SocketAutocompleteInteractionData Data { get; } + + internal SocketAutocompleteInteraction(DiscordSocketClient client, Model model, ISocketMessageChannel channel) + : base(client, model.Id, channel) + { + var dataModel = model.Data.IsSpecified + ? (DataModel)model.Data.Value + : null; + + if (dataModel != null) + Data = new SocketAutocompleteInteractionData(dataModel); + } + + internal new static SocketAutocompleteInteraction Create(DiscordSocketClient client, Model model, ISocketMessageChannel channel) + { + var entity = new SocketAutocompleteInteraction(client, model, channel); + entity.Update(model); + return entity; + } + + /// + /// Responds to this interaction with a set of choices. + /// + /// + /// The set of choices for the user to pick from. + /// + /// A max of 20 choices are allowed. Passing for this argument will show the executing user that + /// there is no choices for their autocompleted input. + /// + /// + /// The request options for this response. + /// + /// 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); + + /// + /// Responds to this interaction with a set of choices. + /// + /// The request options for this response. + /// + /// The set of choices for the user to pick from. + /// + /// A max of 20 choices are allowed. Passing for this argument will show the executing user that + /// there is no choices for their autocompleted input. + /// + /// + /// + /// 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); + + + /// + [Obsolete("Autocomplete interactions cannot be defered!", true)] + public override Task DeferAsync(bool ephemeral = false, RequestOptions options = null) => throw new NotSupportedException(); + + /// + [Obsolete("Autocomplete interactions cannot have followups!", true)] + public override Task FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null) => throw new NotSupportedException(); + + /// + [Obsolete("Autocomplete interactions cannot have followups!", true)] + public override Task FollowupWithFileAsync(string text = null, Stream fileStream = null, string fileName = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null) => throw new NotSupportedException(); + + /// + [Obsolete("Autocomplete interactions cannot have followups!", true)] + public override Task FollowupWithFileAsync(string text = null, string filePath = null, string fileName = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null) => throw new NotSupportedException(); + + /// + [Obsolete("Autocomplete interactions cannot have normal responses!", true)] + public override Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null) => throw new NotSupportedException(); + } +} diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs new file mode 100644 index 000000000..34087116d --- /dev/null +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketAutocompleteInteractionData.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DataModel = Discord.API.AutocompleteInteractionData; + + +namespace Discord.WebSocket +{ + /// + /// Represents data for a slash commands autocomplete interaction. + /// + public class SocketAutocompleteInteractionData + { + /// + /// Gets the name of the invoked command. + /// + public string CommandName { get; } + + /// + /// Gets the id of the invoked command. + /// + public ulong CommandId { get; } + + /// + /// Gets the type of the invoked command. + /// + public ApplicationCommandType Type { get; } + + /// + /// Gets the version of the invoked command. + /// + public ulong Version { get; } + + /// + /// Gets the current autocomplete option that is activly being filled out. + /// + public AutocompleteOption Current { get; } + + /// + /// Gets a collection of all the other options the executing users has filled out. + /// + public IReadOnlyCollection Options { get; } + + internal SocketAutocompleteInteractionData(DataModel model) + { + 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(); + + this.CommandName = model.Name; + this.CommandId = model.Id; + this.Type = model.Type; + this.Version = model.Version; + } + } +} diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs index c65048a34..d32abb610 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs @@ -12,10 +12,22 @@ using Model = Discord.API.Interaction; namespace Discord.WebSocket { /// - /// Base class for User, Message, and Slash command interactions + /// Base class for User, Message, and Slash command interactions. /// public class SocketCommandBase : SocketInteraction { + /// + /// Gets the name of the invoked command. + /// + public string CommandName + => Data.Name; + + /// + /// Gets the id of the invoked command. + /// + public ulong CommandId + => Data.Id; + /// /// The data associated with this interaction. /// diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs index 7baab2496..d88a7f004 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs @@ -65,23 +65,28 @@ namespace Discord.WebSocket { if (model.Type == InteractionType.ApplicationCommand) { - if (model.ApplicationId != null) - { - var dataModel = model.Data.IsSpecified ? + var dataModel = model.Data.IsSpecified ? (DataModel)model.Data.Value : null; - if (dataModel != null) - { - if (dataModel.Type.Equals(ApplicationCommandType.User)) - return SocketUserCommand.Create(client, model, channel); - if (dataModel.Type.Equals(ApplicationCommandType.Message)) - return SocketMessageCommand.Create(client, model, channel); - } + + if (dataModel == null) + return null; + + switch (dataModel.Type) + { + case ApplicationCommandType.Slash: + return SocketSlashCommand.Create(client, model, channel); + case ApplicationCommandType.Message: + return SocketMessageCommand.Create(client, model, channel); + case ApplicationCommandType.User: + return SocketUserCommand.Create(client, model, channel); + default: return null; } - return SocketSlashCommand.Create(client, model, channel); } - if (model.Type == InteractionType.MessageComponent) + else if (model.Type == InteractionType.MessageComponent) return SocketMessageComponent.Create(client, model, channel); + else if (model.Type == InteractionType.ApplicationCommandAutocomplete) + return SocketAutocompleteInteraction.Create(client, model, channel); else return null; } From 884c15c5247c784be011f2881d002415510d4ae4 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Thu, 23 Sep 2021 07:19:57 -0300 Subject: [PATCH 04/27] meta: xml. closes #171 --- src/Discord.Net.Core/Discord.Net.Core.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index ece4d69d4..d8d2d7d16 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -4533,7 +4533,7 @@ - Gets or sets whether or not this option supports autocomplete + Gets or sets whether or not this option supports autocomplete. From 9c9b7fb2c007a926d44717d5b2285303bee966c2 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Thu, 23 Sep 2021 08:53:55 -0300 Subject: [PATCH 05/27] meta: bump version --- src/Discord.Net.Core/Discord.Net.Core.csproj | 6 +++--- src/Discord.Net.Rest/Discord.Net.Rest.csproj | 6 +++--- src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.csproj b/src/Discord.Net.Core/Discord.Net.Core.csproj index 7f494db1a..b52aba214 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.csproj +++ b/src/Discord.Net.Core/Discord.Net.Core.csproj @@ -8,12 +8,12 @@ net461;netstandard2.0;netstandard2.1 netstandard2.0;netstandard2.1 Discord.Net.Labs.Core - 3.1.0 + 3.1.1 Discord.Net.Labs.Core https://github.com/Discord-Net-Labs/Discord.Net-Labs Temporary.png - 3.1.0 - 3.1.0 + 3.1.1 + 3.1.1 false diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.csproj b/src/Discord.Net.Rest/Discord.Net.Rest.csproj index 2159f5117..fcc005402 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.csproj +++ b/src/Discord.Net.Rest/Discord.Net.Rest.csproj @@ -9,11 +9,11 @@ netstandard2.0;netstandard2.1 Temporary.png https://github.com/Discord-Net-Labs/Discord.Net-Labs - 3.1.0 + 3.1.1 Discord.Net.Labs.Rest https://github.com/Discord-Net-Labs/Discord.Net-Labs - 3.1.0 - 3.1.0 + 3.1.1 + 3.1.1 ..\Discord.Net.Rest\Discord.Net.Rest.xml diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj index f166cab11..4947db946 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.csproj @@ -8,7 +8,7 @@ net461;netstandard2.0;netstandard2.1 netstandard2.0;netstandard2.1 true - 3.1.0 + 3.1.1 https://github.com/Discord-Net-Labs/Discord.Net-Labs https://github.com/Discord-Net-Labs/Discord.Net-Labs Temporary.png @@ -16,8 +16,8 @@ ..\Discord.Net.WebSocket\Discord.Net.WebSocket.xml - 3.1.0 - 3.1.0 + 3.1.1 + 3.1.1 TRACE From 091e7e2479b865f5ac697017e20093805d81c547 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Thu, 23 Sep 2021 10:57:05 -0300 Subject: [PATCH 06/27] meta: bump vers --- src/Discord.Net/Discord.Net.nuspec | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Discord.Net/Discord.Net.nuspec b/src/Discord.Net/Discord.Net.nuspec index 5f15cf79a..c41d0ff51 100644 --- a/src/Discord.Net/Discord.Net.nuspec +++ b/src/Discord.Net/Discord.Net.nuspec @@ -2,7 +2,7 @@ Discord.Net.Labs - 3.1.0$suffix$ + 3.1.1$suffix$ Discord.Net Labs Discord.Net Contributors quinchs @@ -14,24 +14,24 @@ https://avatars.githubusercontent.com/u/84047264 - - - - + + + + - - - - + + + + - - - - + + + + From fa851fb6e6b3a10e581c567f14932c939419bb34 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Thu, 23 Sep 2021 11:44:45 -0300 Subject: [PATCH 07/27] Fix sticker args --- src/Discord.Net.Rest/DiscordRestApiClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index f132cb7a4..76cef7ef8 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -745,7 +745,7 @@ namespace Discord.API { Preconditions.NotNull(args, nameof(args)); Preconditions.NotEqual(channelId, 0, nameof(channelId)); - if (!args.Embed.IsSpecified || args.Embed.Value == null) + if ((!args.Embed.IsSpecified || args.Embed.Value == null) && (!args.Stickers.IsSpecified || args.Stickers.Value == null || args.Stickers.Value.Length == 0)) Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); if (args.Content?.Length > DiscordConfig.MaxMessageSize) From 7e53fe55ddffb7d8346fc2f3d8471c87a53c5cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Thu, 23 Sep 2021 17:54:56 +0200 Subject: [PATCH 08/27] Grammer fix (#179) --- .../08-bulk-overwrite-of-global-slash-commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/interactions/application-commands/slash-commands/08-bulk-overwrite-of-global-slash-commands.md b/docs/guides/interactions/application-commands/slash-commands/08-bulk-overwrite-of-global-slash-commands.md index 71bc29653..0a1aab461 100644 --- a/docs/guides/interactions/application-commands/slash-commands/08-bulk-overwrite-of-global-slash-commands.md +++ b/docs/guides/interactions/application-commands/slash-commands/08-bulk-overwrite-of-global-slash-commands.md @@ -1,4 +1,4 @@ -If you have too many global commands then you might want to consider doing a bulk overwrite. +If you have too many global commands then you might want to consider using the bulk overwrite function. ```cs public async Task Client_Ready() { List applicationCommandProperties = new(); From d0738d67a1c78ed7f291ae9845043067376604be Mon Sep 17 00:00:00 2001 From: quin lynch Date: Fri, 24 Sep 2021 04:39:15 -0300 Subject: [PATCH 09/27] Made IVoiceChannel mentionable --- src/Discord.Net.Core/Discord.Net.Core.xml | 4 ++-- src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs | 2 +- .../Interactions/Slash Commands/SlashCommandBuilder.cs | 8 ++++---- src/Discord.Net.Rest/Discord.Net.Rest.xml | 3 +++ .../Entities/Channels/RestVoiceChannel.cs | 3 ++- src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml | 3 +++ .../Entities/Channels/SocketVoiceChannel.cs | 2 ++ .../MockedEntities/MockedVoiceChannel.cs | 2 +- 8 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index d8d2d7d16..dc10024a4 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -6011,7 +6011,7 @@ The default permission value to set. The current builder. - + Adds an option to the current slash command. @@ -6108,7 +6108,7 @@ The built version of this option. - + Adds an option to the current slash command. diff --git a/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs b/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs index 9c2d008ee..1d36a41b9 100644 --- a/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IVoiceChannel.cs @@ -6,7 +6,7 @@ namespace Discord /// /// Represents a generic voice channel in a guild. /// - public interface IVoiceChannel : INestedChannel, IAudioChannel + public interface IVoiceChannel : INestedChannel, IAudioChannel, IMentionable { /// /// Gets the bit-rate that the clients in this voice channel are requested to use. 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 1a152feb4..9581015d0 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs @@ -165,7 +165,7 @@ namespace Discord /// The choices of this option. /// The current builder. public SlashCommandBuilder AddOption(string name, ApplicationCommandOptionType type, - string description, bool required = true, bool isDefault = false, bool isAutocomplete = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) + string description, bool? required = null, bool? isDefault = null, bool isAutocomplete = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) { // Make sure the name matches the requirements from discord Preconditions.NotNullOrEmpty(name, nameof(name)); @@ -183,7 +183,7 @@ namespace Discord Preconditions.AtMost(description.Length, MaxDescriptionLength, nameof(description)); // make sure theres only one option with default set to true - if (isDefault) + if (isDefault.HasValue && isDefault.Value) { if (this.Options != null) if (this.Options.Any(x => x.Default.HasValue && x.Default.Value)) @@ -339,7 +339,7 @@ namespace Discord /// /// Gets or sets if the option is required. /// - public bool Required { get; set; } + public bool? Required { get; set; } = null; /// /// Gets or sets whether or not this option supports autocomplete. @@ -395,7 +395,7 @@ namespace Discord /// The choices of this option. /// The current builder. public SlashCommandOptionBuilder AddOption(string name, ApplicationCommandOptionType type, - string description, bool required = true, bool isDefault = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) + string description, bool? required = null, bool isDefault = false, List options = null, params ApplicationCommandOptionChoiceProperties[] choices) { // Make sure the name matches the requirements from discord Preconditions.NotNullOrEmpty(name, nameof(name)); diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index 6e6b76d21..ec2584580 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -2803,6 +2803,9 @@ + + + diff --git a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs index d1d567e27..b8ee8fc93 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs @@ -21,7 +21,8 @@ namespace Discord.Rest public int? UserLimit { get; private set; } /// public ulong? CategoryId { get; private set; } - + /// + public string Mention => MentionUtils.MentionChannel(Id); internal RestVoiceChannel(BaseDiscordClient discord, IGuild guild, ulong id) : base(discord, guild, id) { diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index c08906290..10c5d5e8d 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -2802,6 +2802,9 @@ A category channel representing the parent of this channel; null if none is set. + + + diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs index f1d61b9b3..9798272b3 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketVoiceChannel.cs @@ -32,6 +32,8 @@ namespace Discord.WebSocket public ICategoryChannel Category => CategoryId.HasValue ? Guild.GetChannel(CategoryId.Value) as ICategoryChannel : null; /// + public string Mention => MentionUtils.MentionChannel(Id); + /// public Task SyncPermissionsAsync(RequestOptions options = null) => ChannelHelper.SyncPermissionsAsync(this, Discord, options); diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs index 7c3d00fdd..159bfb034 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedVoiceChannel.cs @@ -25,7 +25,7 @@ namespace Discord public string Name => throw new NotImplementedException(); public DateTimeOffset CreatedAt => throw new NotImplementedException(); - + public string Mention => throw new NotImplementedException(); public ulong Id => throw new NotImplementedException(); public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null) From cfac5d53d9cdda35d52efada71df4d149baa79d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 11:10:51 +0200 Subject: [PATCH 10/27] Embeds array for send message async (#181) * meta: bump version * meta: bump vers * Fix sticker args * Grammer fix (#179) * Added embeds for SendMessageAsync * [JsonProperty("embed")] forgot to remove this public Optional Embed { get; set; } * It has been done as requested. * Changed the old way of handeling single embeds * Moved embeds param and added options param * xmls Co-authored-by: quin lynch --- .../Discord.Net.Commands.xml | 4 +- src/Discord.Net.Commands/ModuleBase.cs | 6 ++- src/Discord.Net.Core/Discord.Net.Core.xml | 10 ++-- .../Entities/Channels/IMessageChannel.cs | 3 +- .../Extensions/MessageExtensions.cs | 5 +- .../Extensions/UserExtensions.cs | 5 +- .../API/Rest/CreateMessageParams.cs | 4 +- src/Discord.Net.Rest/Discord.Net.Rest.xml | 17 +++--- src/Discord.Net.Rest/DiscordRestApiClient.cs | 2 +- .../Entities/Channels/ChannelHelper.cs | 24 ++++++++- .../Entities/Channels/IRestMessageChannel.cs | 3 +- .../Entities/Channels/RestDMChannel.cs | 8 +-- .../Entities/Channels/RestGroupChannel.cs | 10 ++-- .../Entities/Channels/RestTextChannel.cs | 8 +-- .../Discord.Net.WebSocket.xml | 17 +++--- .../Channels/ISocketMessageChannel.cs | 3 +- .../Entities/Channels/SocketDMChannel.cs | 10 ++-- .../Entities/Channels/SocketGroupChannel.cs | 8 +-- .../Entities/Channels/SocketTextChannel.cs | 8 +-- .../SocketMessageComponent.cs | 54 +++++++++++++++---- .../SocketBaseCommand/SocketCommandBase.cs | 51 +++++++++++++++--- .../MockedEntities/MockedDMChannel.cs | 2 +- .../MockedEntities/MockedGroupChannel.cs | 2 +- .../MockedEntities/MockedTextChannel.cs | 2 +- 24 files changed, 186 insertions(+), 80 deletions(-) diff --git a/src/Discord.Net.Commands/Discord.Net.Commands.xml b/src/Discord.Net.Commands/Discord.Net.Commands.xml index e44d71229..cf68f8786 100644 --- a/src/Discord.Net.Commands/Discord.Net.Commands.xml +++ b/src/Discord.Net.Commands/Discord.Net.Commands.xml @@ -1129,7 +1129,7 @@ - + Sends a message to the source channel. @@ -1138,7 +1138,7 @@ Specifies if Discord should read this aloud using text-to-speech. An embed to be displayed alongside the . - + A array of s to send with this response. Max 10 /// Specifies if notifications are sent for mentioned users and roles in the . If null, all mentioned roles and users will be notified. diff --git a/src/Discord.Net.Commands/ModuleBase.cs b/src/Discord.Net.Commands/ModuleBase.cs index 5f470b7b6..a44fb26c0 100644 --- a/src/Discord.Net.Commands/ModuleBase.cs +++ b/src/Discord.Net.Commands/ModuleBase.cs @@ -36,12 +36,14 @@ namespace Discord.Commands /// Specifies if notifications are sent for mentioned users and roles in the . /// If null, all mentioned roles and users will be notified. /// + /// The request options for this async request. /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions /// A collection of stickers to send with the file. - protected virtual async Task ReplyAsync(string message = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) + /// A array of s to send with this response. Max 10 + protected virtual async Task ReplyAsync(string message = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) { - return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); } /// /// The method to execute before executing the command. diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index dc10024a4..9ee2ef458 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -1507,7 +1507,7 @@ Represents a generic channel that can send and receive messages. - + Sends a message to this message channel. @@ -1528,6 +1528,7 @@ The message references to be included. Used to reply to specific messages. The message components to be included with this message. Used for interactions A collection of stickers to send with the message. + A array of s to send with this response. Max 10 A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -11087,13 +11088,14 @@ - + Sends an inline reply that references a message. The message to be sent. Determines whether the message should be read aloud by Discord or not. The to be sent. + A array of s to send with this response. Max 10 Specifies if notifications are sent for mentioned users and roles in the message . If null, all mentioned roles and users will be notified. @@ -11107,7 +11109,7 @@ An extension class for various Discord user objects. - + Sends a message via DM. @@ -11128,11 +11130,13 @@ The message to be sent. Whether the message should be read aloud by Discord or not. The to be sent. + A array of s to send with this response. Max 10 The options to be used when sending the request. Specifies if notifications are sent for mentioned users and roles in the message . If null, all mentioned roles and users will be notified. + The message components to be included with this message. Used for interactions A task that represents the asynchronous send operation. The task result contains the sent message. diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs index 1fffea6e9..49fc5f433 100644 --- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs @@ -30,11 +30,12 @@ namespace Discord /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions /// A collection of stickers to send with the message. + /// A array of s to send with this response. Max 10 /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null); + Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null); /// /// Sends a file to this message channel with an optional caption. /// diff --git a/src/Discord.Net.Core/Extensions/MessageExtensions.cs b/src/Discord.Net.Core/Extensions/MessageExtensions.cs index 6d068d160..be47c0587 100644 --- a/src/Discord.Net.Core/Extensions/MessageExtensions.cs +++ b/src/Discord.Net.Core/Extensions/MessageExtensions.cs @@ -78,6 +78,7 @@ namespace Discord /// The message to be sent. /// Determines whether the message should be read aloud by Discord or not. /// The to be sent. + /// A array of s to send with this response. Max 10 /// /// Specifies if notifications are sent for mentioned users and roles in the message . /// If null, all mentioned roles and users will be notified. @@ -87,9 +88,9 @@ namespace Discord /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - public static async Task ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, ISticker[] stickers = null) + public static async Task ReplyAsync(this IUserMessage msg, string text = null, bool isTTS = false, Embed embed = null, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null) { - return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id), components, stickers).ConfigureAwait(false); + return await msg.Channel.SendMessageAsync(text, isTTS, embed, options, allowedMentions, new MessageReference(messageId: msg.Id), components, stickers, embeds).ConfigureAwait(false); } } } diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs index 01d9f4dde..3f05b6361 100644 --- a/src/Discord.Net.Core/Extensions/UserExtensions.cs +++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs @@ -27,11 +27,13 @@ namespace Discord /// The message to be sent. /// Whether the message should be read aloud by Discord or not. /// The to be sent. + /// A array of s to send with this response. Max 10 /// The options to be used when sending the request. /// /// Specifies if notifications are sent for mentioned users and roles in the message . /// If null, all mentioned roles and users will be notified. /// + /// The message components to be included with this message. Used for interactions /// /// A task that represents the asynchronous send operation. The task result contains the sent message. /// @@ -39,11 +41,12 @@ namespace Discord string text = null, bool isTTS = false, Embed embed = null, + Embed[] embeds = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageComponent component = null) { - return await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options, allowedMentions, component: component).ConfigureAwait(false); + return await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options, allowedMentions, component: component, embeds: embeds).ConfigureAwait(false); } /// diff --git a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs index b8ee153c9..49321652f 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs @@ -15,8 +15,8 @@ namespace Discord.API.Rest [JsonProperty("tts")] public Optional IsTTS { get; set; } - [JsonProperty("embed")] - public Optional Embed { get; set; } + [JsonProperty("embeds")] + public Optional Embeds { get; set; } [JsonProperty("allowed_mentions")] public Optional AllowedMentions { get; set; } diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index ec2584580..28f8ab534 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -1718,7 +1718,7 @@ must be lesser than 86400. - + Message content is too long, length must be less or equal to . @@ -1764,12 +1764,12 @@ Represents a REST-based channel that can send and receive messages. - + Sends a message to this message channel. - This method follows the same behavior as described in . + This method follows the same behavior as described in . Please visit its documentation for more details on this method. The message to be sent. @@ -1783,6 +1783,7 @@ The message references to be included. Used to reply to specific messages. The message components to be included with this message. Used for interactions A collection of stickers to send with the message. + A array of s to send with this response. Max 10 A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -2016,7 +2017,7 @@ - + Message content is too long, length must be less or equal to . @@ -2104,7 +2105,7 @@ - + @@ -2154,7 +2155,7 @@ - + Message content is too long, length must be less or equal to . @@ -2444,7 +2445,7 @@ - + Message content is too long, length must be less or equal to . @@ -2614,7 +2615,7 @@ - + diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 76cef7ef8..8328db4e7 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -745,7 +745,7 @@ namespace Discord.API { Preconditions.NotNull(args, nameof(args)); Preconditions.NotEqual(channelId, 0, nameof(channelId)); - if ((!args.Embed.IsSpecified || args.Embed.Value == null) && (!args.Stickers.IsSpecified || args.Stickers.Value == null || args.Stickers.Value.Length == 0)) + if ((!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) && (!args.Stickers.IsSpecified || args.Stickers.Value == null || args.Stickers.Value.Length == 0)) Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); if (args.Content?.Length > DiscordConfig.MaxMessageSize) diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs index 696ffa5af..273ffab93 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs @@ -266,10 +266,22 @@ namespace Discord.Rest /// Message content is too long, length must be less or equal to . public static async Task SendMessageAsync(IMessageChannel channel, BaseDiscordClient client, - string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, RequestOptions options) + string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, RequestOptions options, Embed[] embeds) { + if (embed != null) + { + if (embeds == null) + embeds = new[] { embed }; + else + { + List listEmbeds = embeds.ToList(); + listEmbeds.Insert(0, embed); + } + } + Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); + Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); // check that user flag and user Id list are exclusive, same with role flag and role Id list if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue) @@ -292,7 +304,15 @@ namespace Discord.Rest Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed."); } - var args = new CreateMessageParams(text) { IsTTS = isTTS, Embed = embed?.ToModel(), AllowedMentions = allowedMentions?.ToModel(), MessageReference = messageReference?.ToModel(), Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional.Unspecified }; + var args = new CreateMessageParams(text) + { + IsTTS = isTTS, + Embeds = embeds?.Select(x => x.ToModel()).ToArray() ?? Optional.Unspecified, + AllowedMentions = allowedMentions?.ToModel(), + MessageReference = messageReference?.ToModel(), + Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, + Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional.Unspecified + }; var model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false); return RestUserMessage.Create(client, channel, client.CurrentUser, model); } diff --git a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs index b7f494055..2b39e97d6 100644 --- a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs @@ -27,11 +27,12 @@ namespace Discord.Rest /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions /// A collection of stickers to send with the message. + /// A array of s to send with this response. Max 10 /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null); + new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null); /// /// Sends a file to this message channel with an optional caption. /// diff --git a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs index 57869ea58..3f296f441 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs @@ -94,8 +94,8 @@ namespace Discord.Rest /// /// Message content is too long, length must be less or equal to . - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, embeds); /// /// @@ -215,8 +215,8 @@ namespace Discord.Rest async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); /// - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); #endregion #region IChannel diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs index 1b5df0d87..c575a0997 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs @@ -100,8 +100,8 @@ namespace Discord.Rest /// /// Message content is too long, length must be less or equal to . - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, embeds); /// /// @@ -133,7 +133,7 @@ namespace Discord.Rest /// /// Message content is too long, length must be less or equal to . public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers,options, isSpoiler); + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// public Task TriggerTypingAsync(RequestOptions options = null) @@ -192,8 +192,8 @@ namespace Discord.Rest async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); #endregion #region IAudioChannel diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index ffd21afa5..6502c9d1f 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -103,8 +103,8 @@ namespace Discord.Rest /// /// Message content is too long, length must be less or equal to . - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, embeds); /// /// @@ -326,8 +326,8 @@ namespace Discord.Rest async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); /// - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); #endregion #region IGuildChannel diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index 10c5d5e8d..ae283b4d1 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -1457,12 +1457,12 @@ A read-only collection of WebSocket-based messages. - + Sends a message to this message channel. - This method follows the same behavior as described in . + This method follows the same behavior as described in . Please visit its documentation for more details on this method. The message to be sent. @@ -1476,6 +1476,7 @@ The message references to be included. Used to reply to specific messages. The message components to be included with this message. Used for interactions A collection of stickers to send with the message. + A array of s to send with this response. Max 10 A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -1811,7 +1812,7 @@ - + Message content is too long, length must be less or equal to . @@ -1887,7 +1888,7 @@ - + @@ -2002,7 +2003,7 @@ - + Message content is too long, length must be less or equal to . @@ -2075,7 +2076,7 @@ - + @@ -2459,7 +2460,7 @@ - + Message content is too long, length must be less or equal to . @@ -2578,7 +2579,7 @@ - + diff --git a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs index 7a82b2c3f..8b60b18a1 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs @@ -36,11 +36,12 @@ namespace Discord.WebSocket /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions /// A collection of stickers to send with the message. + /// A array of s to send with this response. Max 10 /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null); + new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null); /// /// Sends a file to this message channel with an optional caption. /// diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs index 3f44ecfc6..a6f487cca 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs @@ -59,7 +59,7 @@ namespace Discord.WebSocket /// public Task CloseAsync(RequestOptions options = null) => ChannelHelper.DeleteAsync(this, Discord, options); -#endregion + #endregion #region Messages /// @@ -139,8 +139,8 @@ namespace Discord.WebSocket /// /// Message content is too long, length must be less or equal to . - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, embeds); /// public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) @@ -252,8 +252,8 @@ namespace Discord.WebSocket async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); /// - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); #endregion #region IChannel diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs index f1a697e01..3f758a93e 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs @@ -173,8 +173,8 @@ namespace Discord.WebSocket /// /// Message content is too long, length must be less or equal to . - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, embeds); /// public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) @@ -320,8 +320,8 @@ namespace Discord.WebSocket async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); /// - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); #endregion #region IAudioChannel diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs index 14a34cbc6..3e91eba06 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs @@ -211,8 +211,8 @@ namespace Discord.WebSocket /// /// Message content is too long, length must be less or equal to . - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, embeds); /// public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) @@ -377,8 +377,8 @@ namespace Discord.WebSocket async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); /// - async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); #endregion #region INestedChannel 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 2b834d78b..7b2cc2062 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs @@ -83,8 +83,17 @@ namespace Discord.WebSocket { if (!IsValidToken) throw new InvalidOperationException("Interaction token is no longer valid"); - if (embeds == null && embed != null) - embeds = new[] { embed }; + + if (embed != null) + { + if (embeds == null) + embeds = new[] { embed }; + else + { + List listEmbeds = embeds.ToList(); + listEmbeds.Insert(0, embed); + } + } Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); @@ -108,7 +117,7 @@ namespace Discord.WebSocket var response = new API.InteractionResponse { - Type = InteractionResponseType.ChannelMessageWithSource, + Type = InteractionResponseType.ChannelMessageWithSource, Data = new API.InteractionCallbackData { Content = text ?? Optional.Unspecified, @@ -218,8 +227,17 @@ namespace Discord.WebSocket if (!IsValidToken) throw new InvalidOperationException("Interaction token is no longer valid"); - if (embeds == null && embed != null) - embeds = new[] { embed }; + if (embed != null) + { + if (embeds == null) + embeds = new[] { embed }; + else + { + List listEmbeds = embeds.ToList(); + listEmbeds.Insert(0, embed); + } + } + Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); @@ -255,8 +273,17 @@ namespace Discord.WebSocket if (!IsValidToken) throw new InvalidOperationException("Interaction token is no longer valid"); - if (embeds == null && embed != null) - embeds = new[] { embed }; + if (embed != null) + { + if (embeds == null) + embeds = new[] { embed }; + else + { + List listEmbeds = embeds.ToList(); + listEmbeds.Insert(0, embed); + } + } + Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); @@ -295,8 +322,17 @@ namespace Discord.WebSocket if (!IsValidToken) throw new InvalidOperationException("Interaction token is no longer valid"); - if (embeds == null && embed != null) - embeds = new[] { embed }; + if (embed != null) + { + if (embeds == null) + embeds = new[] { embed }; + else + { + List listEmbeds = embeds.ToList(); + listEmbeds.Insert(0, embed); + } + } + Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs index d32abb610..d4b5f952d 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs @@ -79,8 +79,16 @@ namespace Discord.WebSocket if (!IsValidToken) throw new InvalidOperationException("Interaction token is no longer valid"); - if (embeds == null && embed != null) - embeds = new[] { embed }; + if (embed != null) + { + if (embeds == null) + embeds = new[] { embed }; + else + { + List listEmbeds = embeds.ToList(); + listEmbeds.Insert(0, embed); + } + } Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); @@ -133,8 +141,17 @@ namespace Discord.WebSocket if (!IsValidToken) throw new InvalidOperationException("Interaction token is no longer valid"); - if (embeds == null && embed != null) - embeds = new[] { embed }; + if (embed != null) + { + if (embeds == null) + embeds = new[] { embed }; + else + { + List listEmbeds = embeds.ToList(); + listEmbeds.Insert(0, embed); + } + } + Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); @@ -170,8 +187,17 @@ namespace Discord.WebSocket if (!IsValidToken) throw new InvalidOperationException("Interaction token is no longer valid"); - if (embeds == null && embed != null) - embeds = new[] { embed }; + if (embed != null) + { + if (embeds == null) + embeds = new[] { embed }; + else + { + List listEmbeds = embeds.ToList(); + listEmbeds.Insert(0, embed); + } + } + Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); @@ -210,8 +236,17 @@ namespace Discord.WebSocket if (!IsValidToken) throw new InvalidOperationException("Interaction token is no longer valid"); - if (embeds == null && embed != null) - embeds = new[] { embed }; + if (embed != null) + { + if (embeds == null) + embeds = new[] { embed }; + else + { + List listEmbeds = embeds.ToList(); + listEmbeds.Insert(0, embed); + } + } + Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs index 52eed6bc9..a7451ddd2 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs @@ -83,7 +83,7 @@ namespace Discord throw new NotImplementedException(); } - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) => throw new NotImplementedException(); + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException(); public Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) => throw new NotImplementedException(); public Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) => throw new NotImplementedException(); } diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs index bc4f66ed4..fc9a16338 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs @@ -96,7 +96,7 @@ namespace Discord throw new NotImplementedException(); } - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) { throw new NotImplementedException(); } diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs index fc39a2b07..06d0d9811 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs @@ -186,7 +186,7 @@ namespace Discord throw new NotImplementedException(); } - public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) + public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) { throw new NotImplementedException(); } From ad78542f97f8a782cabc39392368c64aeda3e509 Mon Sep 17 00:00:00 2001 From: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com> Date: Fri, 24 Sep 2021 05:22:05 -0400 Subject: [PATCH 11/27] Fix thread permissions (#183) * Update GuildPermissionsTests.cs * Update GuildPermissions.cs --- .../Entities/Permissions/GuildPermissions.cs | 16 +++++++++++++++- .../GuildPermissionsTests.cs | 8 ++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs index 05a2a7680..f909b6381 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs @@ -93,6 +93,10 @@ namespace Discord public bool CreatePublicThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePublicThreads); /// If true, a user may create private threads in this guild. public bool CreatePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePrivateThreads); + /// If true, a user may use public threads in this guild. + public bool UsePublicThreads => Permissions.GetValue(RawValue, GuildPermission.UsePublicThreads); + /// If true, a user may use private threads in this guild. + public bool UsePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.UsePrivateThreads); /// If true, a user may use external stickers in this guild. public bool UseExternalStickers => Permissions.GetValue(RawValue, GuildPermission.UseExternalStickers); /// If true, a user may send messages in threads in this guild. @@ -143,6 +147,8 @@ namespace Discord bool? manageThreads = null, bool? createPublicThreads = null, bool? createPrivateThreads = null, + bool? usePublicThreads = null, + bool? usePrivateThreads = null, bool? useExternalStickers = null, bool? sendMessagesInThreads = null, bool? startEmbeddedActivities = null) @@ -185,6 +191,8 @@ namespace Discord Permissions.SetValue(ref value, manageThreads, GuildPermission.ManageThreads); Permissions.SetValue(ref value, createPublicThreads, GuildPermission.CreatePublicThreads); Permissions.SetValue(ref value, createPrivateThreads, GuildPermission.CreatePrivateThreads); + Permissions.SetValue(ref value, usePublicThreads, GuildPermission.UsePublicThreads); + Permissions.SetValue(ref value, usePrivateThreads, GuildPermission.UsePrivateThreads); Permissions.SetValue(ref value, useExternalStickers, GuildPermission.UseExternalStickers); Permissions.SetValue(ref value, sendMessagesInThreads, GuildPermission.SendMessagesInThreads); Permissions.SetValue(ref value, startEmbeddedActivities, GuildPermission.StartEmbeddedActivities); @@ -230,6 +238,8 @@ namespace Discord bool manageThreads = false, bool createPublicThreads = false, bool createPrivateThreads = false, + bool usePublicThreads = false, + bool usePrivateThreads = false, bool useExternalStickers = false, bool sendMessagesInThreads = false, bool startEmbeddedActivities = false) @@ -270,6 +280,8 @@ namespace Discord manageThreads: manageThreads, createPublicThreads: createPublicThreads, createPrivateThreads: createPrivateThreads, + usePublicThreads: usePublicThreads, + usePrivateThreads: usePrivateThreads, useExternalStickers: useExternalStickers, sendMessagesInThreads: sendMessagesInThreads, startEmbeddedActivities: startEmbeddedActivities) @@ -313,6 +325,8 @@ namespace Discord bool? manageThreads = null, bool? createPublicThreads = null, bool? createPrivateThreads = null, + bool? usePublicThreads = null, + bool? usePrivateThreads = null, bool? useExternalStickers = null, bool? sendMessagesInThreads = null, bool? startEmbeddedActivities = null) @@ -320,7 +334,7 @@ namespace Discord viewAuditLog, viewGuildInsights, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojisAndStickers, - useSlashCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, + useSlashCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, usePublicThreads, usePrivateThreads, useExternalStickers, sendMessagesInThreads, startEmbeddedActivities); /// diff --git a/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs b/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs index 9be109c6e..68a685fdb 100644 --- a/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs +++ b/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs @@ -95,8 +95,8 @@ namespace Discord AssertFlag(() => new GuildPermissions(useSlashCommands: true), GuildPermission.UseSlashCommands); AssertFlag(() => new GuildPermissions(requestToSpeak: true), GuildPermission.RequestToSpeak); AssertFlag(() => new GuildPermissions(manageThreads: true), GuildPermission.ManageThreads); - AssertFlag(() => new GuildPermissions(usePublicThreads: true), GuildPermission.UsePublicThreads); - AssertFlag(() => new GuildPermissions(usePrivateThreads: true), GuildPermission.UsePrivateThreads); + AssertFlag(() => new GuildPermissions(createPublicThreads: true), GuildPermission.CreatePublicThreads); + AssertFlag(() => new GuildPermissions(createPrivateThreads: true), GuildPermission.CreatePrivateThreads); AssertFlag(() => new GuildPermissions(useExternalStickers: true), GuildPermission.UseExternalStickers); } @@ -171,8 +171,8 @@ namespace Discord AssertUtil(GuildPermission.UseSlashCommands, x => x.UseSlashCommands, (p, enable) => p.Modify(useSlashCommands: enable)); AssertUtil(GuildPermission.RequestToSpeak, x => x.RequestToSpeak, (p, enable) => p.Modify(requestToSpeak: enable)); AssertUtil(GuildPermission.ManageThreads, x => x.ManageThreads, (p, enable) => p.Modify(manageThreads: enable)); - AssertUtil(GuildPermission.UsePublicThreads, x => x.UsePublicThreads, (p, enable) => p.Modify(usePublicThreads: enable)); - AssertUtil(GuildPermission.UsePrivateThreads, x => x.UsePrivateThreads, (p, enable) => p.Modify(usePrivateThreads: enable)); + AssertUtil(GuildPermission.CreatePublicThreads, x => x.CreatePublicThreads, (p, enable) => p.Modify(createPublicThreads: enable)); + AssertUtil(GuildPermission.CreatePrivateThreads, x => x.CreatePrivateThreads, (p, enable) => p.Modify(createPrivateThreads: enable)); AssertUtil(GuildPermission.UseExternalStickers, x => x.UseExternalStickers, (p, enable) => p.Modify(useExternalStickers: enable)); } } From ab8e56634bd54fec398f4995f706eca705ad95a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 13:55:07 +0200 Subject: [PATCH 12/27] Use compound assignment (#186) * Used compound assignment * -||- * -||- --- .../02_commands_framework/Modules/PublicModule.cs | 2 +- .../Builders/ModuleClassBuilder.cs | 4 ++-- .../Builders/ParameterBuilder.cs | 2 +- src/Discord.Net.Commands/CommandService.cs | 6 +++--- src/Discord.Net.Commands/Info/CommandInfo.cs | 6 +++--- src/Discord.Net.Commands/Info/ParameterInfo.cs | 4 ++-- src/Discord.Net.Rest/DiscordRestApiClient.cs | 12 ++++++------ src/Discord.Net.Rest/DiscordRestClient.cs | 2 +- .../Entities/Messages/MessageHelper.cs | 2 +- src/Discord.Net.WebSocket/DiscordSocketClient.cs | 2 +- .../Helpers/DiagnosticVerifier.Helper.cs | 2 +- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/samples/02_commands_framework/Modules/PublicModule.cs b/samples/02_commands_framework/Modules/PublicModule.cs index b9263649f..18423f609 100644 --- a/samples/02_commands_framework/Modules/PublicModule.cs +++ b/samples/02_commands_framework/Modules/PublicModule.cs @@ -31,7 +31,7 @@ namespace _02_commands_framework.Modules [Command("userinfo")] public async Task UserInfoAsync(IUser user = null) { - user = user ?? Context.User; + user ??= Context.User; await ReplyAsync(user.ToString()); } diff --git a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs index 7a752090e..59500439a 100644 --- a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs @@ -116,7 +116,7 @@ namespace Discord.Commands builder.AddAliases(alias.Aliases); break; case GroupAttribute group: - builder.Name = builder.Name ?? group.Prefix; + builder.Name ??= group.Prefix; builder.Group = group.Prefix; builder.AddAliases(group.Prefix); break; @@ -158,7 +158,7 @@ namespace Discord.Commands case CommandAttribute command: builder.AddAliases(command.Text); builder.RunMode = command.RunMode; - builder.Name = builder.Name ?? command.Text; + builder.Name ??= command.Text; builder.IgnoreExtraArgs = command.IgnoreExtraArgs ?? service._ignoreExtraArgs; break; case NameAttribute name: diff --git a/src/Discord.Net.Commands/Builders/ParameterBuilder.cs b/src/Discord.Net.Commands/Builders/ParameterBuilder.cs index 7f827a27e..9ee1a748c 100644 --- a/src/Discord.Net.Commands/Builders/ParameterBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ParameterBuilder.cs @@ -131,7 +131,7 @@ namespace Discord.Commands.Builders internal ParameterInfo Build(CommandInfo info) { - if ((TypeReader ?? (TypeReader = GetReader(ParameterType))) == null) + if ((TypeReader ??= GetReader(ParameterType)) == null) throw new InvalidOperationException($"No type reader found for type {ParameterType.Name}, one must be specified"); return new ParameterInfo(this, info, Command.Module.Service); diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index f897f822a..468f7739f 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -189,7 +189,7 @@ namespace Discord.Commands /// public async Task AddModuleAsync(Type type, IServiceProvider services) { - services = services ?? EmptyServiceProvider.Instance; + services ??= EmptyServiceProvider.Instance; await _moduleLock.WaitAsync().ConfigureAwait(false); try @@ -224,7 +224,7 @@ namespace Discord.Commands /// public async Task> AddModulesAsync(Assembly assembly, IServiceProvider services) { - services = services ?? EmptyServiceProvider.Instance; + services ??= EmptyServiceProvider.Instance; await _moduleLock.WaitAsync().ConfigureAwait(false); try @@ -507,7 +507,7 @@ namespace Discord.Commands /// public async Task ExecuteAsync(ICommandContext context, string input, IServiceProvider services, MultiMatchHandling multiMatchHandling = MultiMatchHandling.Exception) { - services = services ?? EmptyServiceProvider.Instance; + services ??= EmptyServiceProvider.Instance; var searchResult = Search(input); if (!searchResult.IsSuccess) diff --git a/src/Discord.Net.Commands/Info/CommandInfo.cs b/src/Discord.Net.Commands/Info/CommandInfo.cs index 3bcef9831..773c7c773 100644 --- a/src/Discord.Net.Commands/Info/CommandInfo.cs +++ b/src/Discord.Net.Commands/Info/CommandInfo.cs @@ -123,7 +123,7 @@ namespace Discord.Commands public async Task CheckPreconditionsAsync(ICommandContext context, IServiceProvider services = null) { - services = services ?? EmptyServiceProvider.Instance; + services ??= EmptyServiceProvider.Instance; async Task CheckGroups(IEnumerable preconditions, string type) { @@ -164,7 +164,7 @@ namespace Discord.Commands public async Task ParseAsync(ICommandContext context, int startIndex, SearchResult searchResult, PreconditionResult preconditionResult = null, IServiceProvider services = null) { - services = services ?? EmptyServiceProvider.Instance; + services ??= EmptyServiceProvider.Instance; if (!searchResult.IsSuccess) return ParseResult.FromError(searchResult); @@ -201,7 +201,7 @@ namespace Discord.Commands } public async Task ExecuteAsync(ICommandContext context, IEnumerable argList, IEnumerable paramList, IServiceProvider services) { - services = services ?? EmptyServiceProvider.Instance; + services ??= EmptyServiceProvider.Instance; try { diff --git a/src/Discord.Net.Commands/Info/ParameterInfo.cs b/src/Discord.Net.Commands/Info/ParameterInfo.cs index b435b301a..a6ba9dfde 100644 --- a/src/Discord.Net.Commands/Info/ParameterInfo.cs +++ b/src/Discord.Net.Commands/Info/ParameterInfo.cs @@ -75,7 +75,7 @@ namespace Discord.Commands public async Task CheckPreconditionsAsync(ICommandContext context, object arg, IServiceProvider services = null) { - services = services ?? EmptyServiceProvider.Instance; + services ??= EmptyServiceProvider.Instance; foreach (var precondition in Preconditions) { @@ -89,7 +89,7 @@ namespace Discord.Commands public async Task ParseAsync(ICommandContext context, string input, IServiceProvider services = null) { - services = services ?? EmptyServiceProvider.Instance; + services ??= EmptyServiceProvider.Instance; return await _reader.ReadAsync(context, input, services).ConfigureAwait(false); } diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 8328db4e7..7d883fac6 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -177,7 +177,7 @@ namespace Discord.API public async Task SendAsync(string method, string endpoint, BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) { - options = options ?? new RequestOptions(); + options ??= new RequestOptions(); options.HeaderOnly = true; options.BucketId = bucketId; @@ -191,7 +191,7 @@ namespace Discord.API public async Task SendJsonAsync(string method, string endpoint, object payload, BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) { - options = options ?? new RequestOptions(); + options ??= new RequestOptions(); options.HeaderOnly = true; options.BucketId = bucketId; @@ -206,7 +206,7 @@ namespace Discord.API public async Task SendMultipartAsync(string method, string endpoint, IReadOnlyDictionary multipartArgs, BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) { - options = options ?? new RequestOptions(); + options ??= new RequestOptions(); options.HeaderOnly = true; options.BucketId = bucketId; @@ -220,7 +220,7 @@ namespace Discord.API public async Task SendAsync(string method, string endpoint, BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class { - options = options ?? new RequestOptions(); + options ??= new RequestOptions(); options.BucketId = bucketId; var request = new RestRequest(RestClient, method, endpoint, options); @@ -233,7 +233,7 @@ namespace Discord.API public async Task SendJsonAsync(string method, string endpoint, object payload, BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) where TResponse : class { - options = options ?? new RequestOptions(); + options ??= new RequestOptions(); options.BucketId = bucketId; string json = payload != null ? SerializeJson(payload) : null; @@ -248,7 +248,7 @@ namespace Discord.API public async Task SendMultipartAsync(string method, string endpoint, IReadOnlyDictionary multipartArgs, BucketId bucketId = null, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null) { - options = options ?? new RequestOptions(); + options ??= new RequestOptions(); options.BucketId = bucketId; var request = new MultipartRestRequest(RestClient, method, endpoint, multipartArgs, options); diff --git a/src/Discord.Net.Rest/DiscordRestClient.cs b/src/Discord.Net.Rest/DiscordRestClient.cs index 8254eabe9..c8f16a1f0 100644 --- a/src/Discord.Net.Rest/DiscordRestClient.cs +++ b/src/Discord.Net.Rest/DiscordRestClient.cs @@ -62,7 +62,7 @@ namespace Discord.Rest public async Task GetApplicationInfoAsync(RequestOptions options = null) { - return _applicationInfo ?? (_applicationInfo = await ClientHelper.GetApplicationInfoAsync(this, options).ConfigureAwait(false)); + return _applicationInfo ??= await ClientHelper.GetApplicationInfoAsync(this, options).ConfigureAwait(false); } public Task GetChannelAsync(ulong id, RequestOptions options = null) diff --git a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs index d50f453d7..e10be2c0a 100644 --- a/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs +++ b/src/Discord.Net.Rest/Entities/Messages/MessageHelper.cs @@ -344,7 +344,7 @@ namespace Discord.Rest tags.Add(new Tag(TagType.Emoji, index, content.Length, emoji.Id, emoji)); else //Bad Tag { - index = index + 1; + index++; continue; } index = endIndex + 1; diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index f465571d6..3e5a6d543 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -322,7 +322,7 @@ namespace Discord.WebSocket /// public override async Task GetApplicationInfoAsync(RequestOptions options = null) - => _applicationInfo ?? (_applicationInfo = await ClientHelper.GetApplicationInfoAsync(this, options ?? RequestOptions.Default).ConfigureAwait(false)); + => _applicationInfo ??= await ClientHelper.GetApplicationInfoAsync(this, options ?? RequestOptions.Default).ConfigureAwait(false); /// public override SocketGuild GetGuild(ulong id) diff --git a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs index 99654f12c..43748aa93 100644 --- a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs +++ b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs @@ -187,7 +187,7 @@ namespace TestHelper private static HashSet RecursiveReferencedAssemblies(Assembly a, HashSet assemblies = null) { - assemblies = assemblies ?? new HashSet(); + assemblies ??= new HashSet(); if (assemblies.Add(a)) { foreach (var referencedAssemblyName in a.GetReferencedAssemblies()) From d897ba1839c670d1a9c463c248c71931d4bdbde1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 13:57:39 +0200 Subject: [PATCH 13/27] Remove unnecessary suppression (#188) --- src/Discord.Net.Rest/API/Common/Application.cs | 1 - src/Discord.Net.Rest/API/Common/Attachment.cs | 1 - src/Discord.Net.Rest/API/Common/Ban.cs | 1 - src/Discord.Net.Rest/API/Common/Channel.cs | 1 - src/Discord.Net.Rest/API/Common/Connection.cs | 1 - src/Discord.Net.Rest/API/Common/Embed.cs | 1 - src/Discord.Net.Rest/API/Common/EmbedImage.cs | 1 - src/Discord.Net.Rest/API/Common/EmbedProvider.cs | 1 - src/Discord.Net.Rest/API/Common/EmbedThumbnail.cs | 1 - src/Discord.Net.Rest/API/Common/EmbedVideo.cs | 1 - src/Discord.Net.Rest/API/Common/Emoji.cs | 1 - src/Discord.Net.Rest/API/Common/Game.cs | 1 - src/Discord.Net.Rest/API/Common/Guild.cs | 1 - src/Discord.Net.Rest/API/Common/GuildMember.cs | 1 - src/Discord.Net.Rest/API/Common/GuildWidget.cs | 1 - src/Discord.Net.Rest/API/Common/Integration.cs | 1 - src/Discord.Net.Rest/API/Common/IntegrationAccount.cs | 1 - src/Discord.Net.Rest/API/Common/Invite.cs | 1 - src/Discord.Net.Rest/API/Common/InviteChannel.cs | 1 - src/Discord.Net.Rest/API/Common/InviteGuild.cs | 1 - src/Discord.Net.Rest/API/Common/InviteMetadata.cs | 1 - src/Discord.Net.Rest/API/Common/Message.cs | 1 - src/Discord.Net.Rest/API/Common/Overwrite.cs | 1 - src/Discord.Net.Rest/API/Common/Presence.cs | 1 - src/Discord.Net.Rest/API/Common/ReadState.cs | 1 - src/Discord.Net.Rest/API/Common/Relationship.cs | 1 - src/Discord.Net.Rest/API/Common/RelationshipType.cs | 1 - src/Discord.Net.Rest/API/Common/Role.cs | 1 - src/Discord.Net.Rest/API/Common/RoleTags.cs | 1 - src/Discord.Net.Rest/API/Common/Sticker.cs | 1 - src/Discord.Net.Rest/API/Common/Team.cs | 1 - src/Discord.Net.Rest/API/Common/TeamMember.cs | 1 - src/Discord.Net.Rest/API/Common/User.cs | 1 - src/Discord.Net.Rest/API/Common/UserGuild.cs | 1 - src/Discord.Net.Rest/API/Common/VoiceRegion.cs | 1 - src/Discord.Net.Rest/API/Common/VoiceState.cs | 1 - src/Discord.Net.Rest/API/Common/Webhook.cs | 1 - src/Discord.Net.Rest/API/Int53Attribute.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateChannelInviteParams.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateDMChannelParams.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateGuildBanParams.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateGuildEmoteParams.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateGuildIntegrationParams.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateGuildParams.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs | 1 - src/Discord.Net.Rest/API/Rest/CreateWebhookParams.cs | 1 - src/Discord.Net.Rest/API/Rest/DeleteMessagesParams.cs | 1 - src/Discord.Net.Rest/API/Rest/GetBotGatewayResponse.cs | 1 - src/Discord.Net.Rest/API/Rest/GetChannelMessagesParams.cs | 1 - src/Discord.Net.Rest/API/Rest/GetGatewayResponse.cs | 1 - src/Discord.Net.Rest/API/Rest/GetGuildMembersParams.cs | 1 - src/Discord.Net.Rest/API/Rest/GetGuildPruneCountResponse.cs | 1 - src/Discord.Net.Rest/API/Rest/GetGuildSummariesParams.cs | 1 - src/Discord.Net.Rest/API/Rest/GuildPruneParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyChannelPermissionsParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyCurrentUserNickParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyCurrentUserParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildChannelsParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildEmbedParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildEmoteParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildIntegrationParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildRoleParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildRolesParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyGuildWidgetParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyMessageParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyTextChannelParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyVoiceChannelParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyWebhookMessageParams.cs | 1 - src/Discord.Net.Rest/API/Rest/ModifyWebhookParams.cs | 1 - src/Discord.Net.Rest/API/Rest/SearchGuildMembersParams.cs | 1 - src/Discord.Net.Rest/API/Rest/UploadFileParams.cs | 1 - src/Discord.Net.Rest/API/Rest/UploadWebhookFileParams.cs | 1 - src/Discord.Net.Rest/DiscordRestApiClient.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GatewayOpCode.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildBanEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildEmojiUpdateEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildMemberAddEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildMemberRemoveEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildMemberUpdateEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildMembersChunkEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildRoleCreateEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildRoleDeleteEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildRoleUpdateEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/GuildSyncEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/HelloEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/MessageDeleteBulkEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/ReadyEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/RecipientEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/RequestMembersParams.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/ResumeParams.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/StatusUpdateParams.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/TypingStartEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/VoiceServerUpdateEvent.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/VoiceStateUpdateParams.cs | 1 - src/Discord.Net.WebSocket/API/Gateway/WebhookUpdateEvent.cs | 1 - src/Discord.Net.WebSocket/API/SocketFrame.cs | 1 - src/Discord.Net.WebSocket/API/Voice/IdentifyParams.cs | 1 - src/Discord.Net.WebSocket/API/Voice/ReadyEvent.cs | 1 - src/Discord.Net.WebSocket/API/Voice/SelectProtocolParams.cs | 1 - src/Discord.Net.WebSocket/API/Voice/SessionDescriptionEvent.cs | 1 - src/Discord.Net.WebSocket/API/Voice/SpeakingEvent.cs | 1 - src/Discord.Net.WebSocket/API/Voice/SpeakingParams.cs | 1 - src/Discord.Net.WebSocket/API/Voice/UdpProtocolInfo.cs | 1 - src/Discord.Net.WebSocket/API/Voice/VoiceOpCode.cs | 1 - src/Discord.Net.WebSocket/DiscordSocketApiClient.cs | 1 - src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs | 1 - 114 files changed, 114 deletions(-) diff --git a/src/Discord.Net.Rest/API/Common/Application.cs b/src/Discord.Net.Rest/API/Common/Application.cs index aba3e524b..e828f9910 100644 --- a/src/Discord.Net.Rest/API/Common/Application.cs +++ b/src/Discord.Net.Rest/API/Common/Application.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Attachment.cs b/src/Discord.Net.Rest/API/Common/Attachment.cs index 4a651d9fa..3ac445f8c 100644 --- a/src/Discord.Net.Rest/API/Common/Attachment.cs +++ b/src/Discord.Net.Rest/API/Common/Attachment.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Ban.cs b/src/Discord.Net.Rest/API/Common/Ban.cs index 202004f53..ff47c7904 100644 --- a/src/Discord.Net.Rest/API/Common/Ban.cs +++ b/src/Discord.Net.Rest/API/Common/Ban.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Channel.cs b/src/Discord.Net.Rest/API/Common/Channel.cs index 2dd004021..afd219b63 100644 --- a/src/Discord.Net.Rest/API/Common/Channel.cs +++ b/src/Discord.Net.Rest/API/Common/Channel.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; diff --git a/src/Discord.Net.Rest/API/Common/Connection.cs b/src/Discord.Net.Rest/API/Common/Connection.cs index ad0a76ac1..bd8de3902 100644 --- a/src/Discord.Net.Rest/API/Common/Connection.cs +++ b/src/Discord.Net.Rest/API/Common/Connection.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System.Collections.Generic; diff --git a/src/Discord.Net.Rest/API/Common/Embed.cs b/src/Discord.Net.Rest/API/Common/Embed.cs index fbf20d987..77efa12aa 100644 --- a/src/Discord.Net.Rest/API/Common/Embed.cs +++ b/src/Discord.Net.Rest/API/Common/Embed.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using System; using Newtonsoft.Json; using Discord.Net.Converters; diff --git a/src/Discord.Net.Rest/API/Common/EmbedImage.cs b/src/Discord.Net.Rest/API/Common/EmbedImage.cs index e650d99f4..6b5db0681 100644 --- a/src/Discord.Net.Rest/API/Common/EmbedImage.cs +++ b/src/Discord.Net.Rest/API/Common/EmbedImage.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/EmbedProvider.cs b/src/Discord.Net.Rest/API/Common/EmbedProvider.cs index e01261483..ed0f7c3c8 100644 --- a/src/Discord.Net.Rest/API/Common/EmbedProvider.cs +++ b/src/Discord.Net.Rest/API/Common/EmbedProvider.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/EmbedThumbnail.cs b/src/Discord.Net.Rest/API/Common/EmbedThumbnail.cs index 9c87ca46b..dd25a1a26 100644 --- a/src/Discord.Net.Rest/API/Common/EmbedThumbnail.cs +++ b/src/Discord.Net.Rest/API/Common/EmbedThumbnail.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/EmbedVideo.cs b/src/Discord.Net.Rest/API/Common/EmbedVideo.cs index 3a034d244..f668217f0 100644 --- a/src/Discord.Net.Rest/API/Common/EmbedVideo.cs +++ b/src/Discord.Net.Rest/API/Common/EmbedVideo.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Emoji.cs b/src/Discord.Net.Rest/API/Common/Emoji.cs index 945cc6d7e..ff0baa73e 100644 --- a/src/Discord.Net.Rest/API/Common/Emoji.cs +++ b/src/Discord.Net.Rest/API/Common/Emoji.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Game.cs b/src/Discord.Net.Rest/API/Common/Game.cs index 775b6aabc..105ce0d73 100644 --- a/src/Discord.Net.Rest/API/Common/Game.cs +++ b/src/Discord.Net.Rest/API/Common/Game.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using System.Runtime.Serialization; diff --git a/src/Discord.Net.Rest/API/Common/Guild.cs b/src/Discord.Net.Rest/API/Common/Guild.cs index c5ec00117..fd8a0bdb5 100644 --- a/src/Discord.Net.Rest/API/Common/Guild.cs +++ b/src/Discord.Net.Rest/API/Common/Guild.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/GuildMember.cs b/src/Discord.Net.Rest/API/Common/GuildMember.cs index fc2092d6c..53f4908bf 100644 --- a/src/Discord.Net.Rest/API/Common/GuildMember.cs +++ b/src/Discord.Net.Rest/API/Common/GuildMember.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; diff --git a/src/Discord.Net.Rest/API/Common/GuildWidget.cs b/src/Discord.Net.Rest/API/Common/GuildWidget.cs index c15ad8aac..6b1d29cce 100644 --- a/src/Discord.Net.Rest/API/Common/GuildWidget.cs +++ b/src/Discord.Net.Rest/API/Common/GuildWidget.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Integration.cs b/src/Discord.Net.Rest/API/Common/Integration.cs index 821359975..47d67e149 100644 --- a/src/Discord.Net.Rest/API/Common/Integration.cs +++ b/src/Discord.Net.Rest/API/Common/Integration.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; diff --git a/src/Discord.Net.Rest/API/Common/IntegrationAccount.cs b/src/Discord.Net.Rest/API/Common/IntegrationAccount.cs index 22831e795..a8d33931c 100644 --- a/src/Discord.Net.Rest/API/Common/IntegrationAccount.cs +++ b/src/Discord.Net.Rest/API/Common/IntegrationAccount.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Invite.cs b/src/Discord.Net.Rest/API/Common/Invite.cs index aba267f34..f9d53bad6 100644 --- a/src/Discord.Net.Rest/API/Common/Invite.cs +++ b/src/Discord.Net.Rest/API/Common/Invite.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/InviteChannel.cs b/src/Discord.Net.Rest/API/Common/InviteChannel.cs index f8f2a34f2..d601e65fe 100644 --- a/src/Discord.Net.Rest/API/Common/InviteChannel.cs +++ b/src/Discord.Net.Rest/API/Common/InviteChannel.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/InviteGuild.cs b/src/Discord.Net.Rest/API/Common/InviteGuild.cs index 3d6d7cd74..f5c634e4e 100644 --- a/src/Discord.Net.Rest/API/Common/InviteGuild.cs +++ b/src/Discord.Net.Rest/API/Common/InviteGuild.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/InviteMetadata.cs b/src/Discord.Net.Rest/API/Common/InviteMetadata.cs index f818de699..a06d06969 100644 --- a/src/Discord.Net.Rest/API/Common/InviteMetadata.cs +++ b/src/Discord.Net.Rest/API/Common/InviteMetadata.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; diff --git a/src/Discord.Net.Rest/API/Common/Message.cs b/src/Discord.Net.Rest/API/Common/Message.cs index e88a94af8..3b9e5379a 100644 --- a/src/Discord.Net.Rest/API/Common/Message.cs +++ b/src/Discord.Net.Rest/API/Common/Message.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; diff --git a/src/Discord.Net.Rest/API/Common/Overwrite.cs b/src/Discord.Net.Rest/API/Common/Overwrite.cs index 3d94b0640..a1fb534d8 100644 --- a/src/Discord.Net.Rest/API/Common/Overwrite.cs +++ b/src/Discord.Net.Rest/API/Common/Overwrite.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Presence.cs b/src/Discord.Net.Rest/API/Common/Presence.cs index b44e9185d..23f871ae6 100644 --- a/src/Discord.Net.Rest/API/Common/Presence.cs +++ b/src/Discord.Net.Rest/API/Common/Presence.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; using System.Collections.Generic; diff --git a/src/Discord.Net.Rest/API/Common/ReadState.cs b/src/Discord.Net.Rest/API/Common/ReadState.cs index 6ea6e4bd0..9a66880c6 100644 --- a/src/Discord.Net.Rest/API/Common/ReadState.cs +++ b/src/Discord.Net.Rest/API/Common/ReadState.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Relationship.cs b/src/Discord.Net.Rest/API/Common/Relationship.cs index ecbb96f80..d17f766af 100644 --- a/src/Discord.Net.Rest/API/Common/Relationship.cs +++ b/src/Discord.Net.Rest/API/Common/Relationship.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/RelationshipType.cs b/src/Discord.Net.Rest/API/Common/RelationshipType.cs index 0ed99f396..776ba156b 100644 --- a/src/Discord.Net.Rest/API/Common/RelationshipType.cs +++ b/src/Discord.Net.Rest/API/Common/RelationshipType.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 namespace Discord.API { internal enum RelationshipType diff --git a/src/Discord.Net.Rest/API/Common/Role.cs b/src/Discord.Net.Rest/API/Common/Role.cs index c655175da..4c33956af 100644 --- a/src/Discord.Net.Rest/API/Common/Role.cs +++ b/src/Discord.Net.Rest/API/Common/Role.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/RoleTags.cs b/src/Discord.Net.Rest/API/Common/RoleTags.cs index 6446f2037..9ddd39a64 100644 --- a/src/Discord.Net.Rest/API/Common/RoleTags.cs +++ b/src/Discord.Net.Rest/API/Common/RoleTags.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Sticker.cs b/src/Discord.Net.Rest/API/Common/Sticker.cs index 490c16dbe..45e6d18b3 100644 --- a/src/Discord.Net.Rest/API/Common/Sticker.cs +++ b/src/Discord.Net.Rest/API/Common/Sticker.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/Team.cs b/src/Discord.Net.Rest/API/Common/Team.cs index 852368522..b421dc18c 100644 --- a/src/Discord.Net.Rest/API/Common/Team.cs +++ b/src/Discord.Net.Rest/API/Common/Team.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/TeamMember.cs b/src/Discord.Net.Rest/API/Common/TeamMember.cs index 788f73b61..f3cba608e 100644 --- a/src/Discord.Net.Rest/API/Common/TeamMember.cs +++ b/src/Discord.Net.Rest/API/Common/TeamMember.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/User.cs b/src/Discord.Net.Rest/API/Common/User.cs index 4d1b5b2b7..08fe88cb0 100644 --- a/src/Discord.Net.Rest/API/Common/User.cs +++ b/src/Discord.Net.Rest/API/Common/User.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/UserGuild.cs b/src/Discord.Net.Rest/API/Common/UserGuild.cs index 825e9a09a..fc1fe833d 100644 --- a/src/Discord.Net.Rest/API/Common/UserGuild.cs +++ b/src/Discord.Net.Rest/API/Common/UserGuild.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/VoiceRegion.cs b/src/Discord.Net.Rest/API/Common/VoiceRegion.cs index 606af07bd..3cc66a0ef 100644 --- a/src/Discord.Net.Rest/API/Common/VoiceRegion.cs +++ b/src/Discord.Net.Rest/API/Common/VoiceRegion.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Common/VoiceState.cs b/src/Discord.Net.Rest/API/Common/VoiceState.cs index 27aacb6a4..f7cd54a72 100644 --- a/src/Discord.Net.Rest/API/Common/VoiceState.cs +++ b/src/Discord.Net.Rest/API/Common/VoiceState.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; diff --git a/src/Discord.Net.Rest/API/Common/Webhook.cs b/src/Discord.Net.Rest/API/Common/Webhook.cs index eb504a27c..23b682bd3 100644 --- a/src/Discord.Net.Rest/API/Common/Webhook.cs +++ b/src/Discord.Net.Rest/API/Common/Webhook.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Int53Attribute.cs b/src/Discord.Net.Rest/API/Int53Attribute.cs index 70ef2f185..3a21b583d 100644 --- a/src/Discord.Net.Rest/API/Int53Attribute.cs +++ b/src/Discord.Net.Rest/API/Int53Attribute.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using System; namespace Discord.API diff --git a/src/Discord.Net.Rest/API/Rest/CreateChannelInviteParams.cs b/src/Discord.Net.Rest/API/Rest/CreateChannelInviteParams.cs index 06a47f1a8..852abe301 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateChannelInviteParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateChannelInviteParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/CreateDMChannelParams.cs b/src/Discord.Net.Rest/API/Rest/CreateDMChannelParams.cs index f32796e02..0a710dd1b 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateDMChannelParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateDMChannelParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/CreateGuildBanParams.cs b/src/Discord.Net.Rest/API/Rest/CreateGuildBanParams.cs index f0432e517..fce9df11f 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateGuildBanParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateGuildBanParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 namespace Discord.API.Rest { internal class CreateGuildBanParams diff --git a/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs b/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs index aec43dbef..57816e448 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateGuildChannelParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/CreateGuildEmoteParams.cs b/src/Discord.Net.Rest/API/Rest/CreateGuildEmoteParams.cs index 308199820..c81f62f4c 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateGuildEmoteParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateGuildEmoteParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/CreateGuildIntegrationParams.cs b/src/Discord.Net.Rest/API/Rest/CreateGuildIntegrationParams.cs index 1053a0ed3..7358e5201 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateGuildIntegrationParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateGuildIntegrationParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/CreateGuildParams.cs b/src/Discord.Net.Rest/API/Rest/CreateGuildParams.cs index cda6caedf..e89c2b119 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateGuildParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateGuildParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs index 49321652f..5996c7e83 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs b/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs index 47f5bb2a9..e21cae845 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Discord.Net.Converters; using Discord.Net.Rest; using Newtonsoft.Json; diff --git a/src/Discord.Net.Rest/API/Rest/CreateWebhookParams.cs b/src/Discord.Net.Rest/API/Rest/CreateWebhookParams.cs index 0d1059fab..242f451cb 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateWebhookParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateWebhookParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/DeleteMessagesParams.cs b/src/Discord.Net.Rest/API/Rest/DeleteMessagesParams.cs index ca9d8c26e..ca6b78406 100644 --- a/src/Discord.Net.Rest/API/Rest/DeleteMessagesParams.cs +++ b/src/Discord.Net.Rest/API/Rest/DeleteMessagesParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/GetBotGatewayResponse.cs b/src/Discord.Net.Rest/API/Rest/GetBotGatewayResponse.cs index d3285051b..3f8318cd1 100644 --- a/src/Discord.Net.Rest/API/Rest/GetBotGatewayResponse.cs +++ b/src/Discord.Net.Rest/API/Rest/GetBotGatewayResponse.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/GetChannelMessagesParams.cs b/src/Discord.Net.Rest/API/Rest/GetChannelMessagesParams.cs index ea5327667..52dd84836 100644 --- a/src/Discord.Net.Rest/API/Rest/GetChannelMessagesParams.cs +++ b/src/Discord.Net.Rest/API/Rest/GetChannelMessagesParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 namespace Discord.API.Rest { internal class GetChannelMessagesParams diff --git a/src/Discord.Net.Rest/API/Rest/GetGatewayResponse.cs b/src/Discord.Net.Rest/API/Rest/GetGatewayResponse.cs index ce3630170..11207633d 100644 --- a/src/Discord.Net.Rest/API/Rest/GetGatewayResponse.cs +++ b/src/Discord.Net.Rest/API/Rest/GetGatewayResponse.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/GetGuildMembersParams.cs b/src/Discord.Net.Rest/API/Rest/GetGuildMembersParams.cs index 66023cb43..67d380035 100644 --- a/src/Discord.Net.Rest/API/Rest/GetGuildMembersParams.cs +++ b/src/Discord.Net.Rest/API/Rest/GetGuildMembersParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 namespace Discord.API.Rest { internal class GetGuildMembersParams diff --git a/src/Discord.Net.Rest/API/Rest/GetGuildPruneCountResponse.cs b/src/Discord.Net.Rest/API/Rest/GetGuildPruneCountResponse.cs index 4af85acfa..1e7fc8c7b 100644 --- a/src/Discord.Net.Rest/API/Rest/GetGuildPruneCountResponse.cs +++ b/src/Discord.Net.Rest/API/Rest/GetGuildPruneCountResponse.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/GetGuildSummariesParams.cs b/src/Discord.Net.Rest/API/Rest/GetGuildSummariesParams.cs index f770ef398..1d3f70f07 100644 --- a/src/Discord.Net.Rest/API/Rest/GetGuildSummariesParams.cs +++ b/src/Discord.Net.Rest/API/Rest/GetGuildSummariesParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 namespace Discord.API.Rest { internal class GetGuildSummariesParams diff --git a/src/Discord.Net.Rest/API/Rest/GuildPruneParams.cs b/src/Discord.Net.Rest/API/Rest/GuildPruneParams.cs index e4c9192ad..c6caa1eb1 100644 --- a/src/Discord.Net.Rest/API/Rest/GuildPruneParams.cs +++ b/src/Discord.Net.Rest/API/Rest/GuildPruneParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyChannelPermissionsParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyChannelPermissionsParams.cs index 269111a61..acb81034a 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyChannelPermissionsParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyChannelPermissionsParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyCurrentUserNickParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyCurrentUserNickParams.cs index ba44e34cf..c10f2e4ec 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyCurrentUserNickParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyCurrentUserNickParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyCurrentUserParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyCurrentUserParams.cs index 7ba27c3a5..e28deb32b 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyCurrentUserParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyCurrentUserParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs index e5e8a4632..dfe9cd980 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelsParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelsParams.cs index f97fbda0b..91567be3d 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelsParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildChannelsParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildEmbedParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildEmbedParams.cs index 487744c65..420bdbeaf 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildEmbedParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildEmbedParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildEmoteParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildEmoteParams.cs index a2295dd5d..08b196daa 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildEmoteParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildEmoteParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildIntegrationParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildIntegrationParams.cs index 0a1b4f9fa..cf869c838 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildIntegrationParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildIntegrationParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs index a381d6f8f..37625de09 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildMemberParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildParams.cs index cfb107bcd..feda24302 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildRoleParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildRoleParams.cs index 8605411c5..ce8c86fbf 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildRoleParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildRoleParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildRolesParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildRolesParams.cs index 0e816a260..eeb724523 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildRolesParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildRolesParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyGuildWidgetParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyGuildWidgetParams.cs index 506f1dfbb..2e5658d51 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyGuildWidgetParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyGuildWidgetParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyMessageParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyMessageParams.cs index 21ed1a418..3dba45a5b 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyMessageParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyTextChannelParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyTextChannelParams.cs index 94f149fc1..409d90c3f 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyTextChannelParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyTextChannelParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyVoiceChannelParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyVoiceChannelParams.cs index ce36eb11f..d55cdb637 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyVoiceChannelParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyVoiceChannelParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyWebhookMessageParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyWebhookMessageParams.cs index 8298ff19c..e73efaf36 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyWebhookMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyWebhookMessageParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/ModifyWebhookParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyWebhookParams.cs index 0f2d6e33b..2e4e6a4c4 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyWebhookParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyWebhookParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Rest diff --git a/src/Discord.Net.Rest/API/Rest/SearchGuildMembersParams.cs b/src/Discord.Net.Rest/API/Rest/SearchGuildMembersParams.cs index 7c933ff82..56b3595fa 100644 --- a/src/Discord.Net.Rest/API/Rest/SearchGuildMembersParams.cs +++ b/src/Discord.Net.Rest/API/Rest/SearchGuildMembersParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 namespace Discord.API.Rest { internal class SearchGuildMembersParams diff --git a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs index 1ee918ae7..f18da65c1 100644 --- a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs +++ b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Discord.Net.Converters; using Discord.Net.Rest; using Newtonsoft.Json; diff --git a/src/Discord.Net.Rest/API/Rest/UploadWebhookFileParams.cs b/src/Discord.Net.Rest/API/Rest/UploadWebhookFileParams.cs index 8da7681ae..d925e0108 100644 --- a/src/Discord.Net.Rest/API/Rest/UploadWebhookFileParams.cs +++ b/src/Discord.Net.Rest/API/Rest/UploadWebhookFileParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using System.Collections.Generic; using System.IO; using System.Text; diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 7d883fac6..f42d33871 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -1,5 +1,4 @@ -#pragma warning disable CS1591 using Discord.API.Rest; using Discord.Net; using Discord.Net.Converters; diff --git a/src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs b/src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs index da02b737a..203f2fd5b 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; diff --git a/src/Discord.Net.WebSocket/API/Gateway/GatewayOpCode.cs b/src/Discord.Net.WebSocket/API/Gateway/GatewayOpCode.cs index 062aec224..6f8bf48d4 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GatewayOpCode.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GatewayOpCode.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 namespace Discord.API.Gateway { internal enum GatewayOpCode : byte diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildBanEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildBanEvent.cs index 59a3304dd..a8a72e791 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildBanEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildBanEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildEmojiUpdateEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildEmojiUpdateEvent.cs index 715341dc5..33c10e648 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildEmojiUpdateEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildEmojiUpdateEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildMemberAddEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildMemberAddEvent.cs index 350652faf..dd42978fc 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildMemberAddEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildMemberAddEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildMemberRemoveEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildMemberRemoveEvent.cs index 501408a7f..ec7df8fd3 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildMemberRemoveEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildMemberRemoveEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildMemberUpdateEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildMemberUpdateEvent.cs index 744d2d502..0f6fa6f37 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildMemberUpdateEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildMemberUpdateEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildMembersChunkEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildMembersChunkEvent.cs index e401d7fa1..26114bf54 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildMembersChunkEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildMembersChunkEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildRoleCreateEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildRoleCreateEvent.cs index 3409b1c91..3b02164d5 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildRoleCreateEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildRoleCreateEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildRoleDeleteEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildRoleDeleteEvent.cs index dbdaeff67..d9bdb9892 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildRoleDeleteEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildRoleDeleteEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildRoleUpdateEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildRoleUpdateEvent.cs index b04ecb182..bb6a39620 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildRoleUpdateEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildRoleUpdateEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/GuildSyncEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/GuildSyncEvent.cs index 6b2e6c02f..ba4c1ca60 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/GuildSyncEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/GuildSyncEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/HelloEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/HelloEvent.cs index e1ed9463c..a53a96fd8 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/HelloEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/HelloEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs b/src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs index 3b7ef35d6..96c7cb32f 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/IdentifyParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System.Collections.Generic; diff --git a/src/Discord.Net.WebSocket/API/Gateway/MessageDeleteBulkEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/MessageDeleteBulkEvent.cs index a4cf7d7eb..c503e636d 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/MessageDeleteBulkEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/MessageDeleteBulkEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System.Collections.Generic; diff --git a/src/Discord.Net.WebSocket/API/Gateway/ReadyEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/ReadyEvent.cs index ab92d8c36..5cd75dbee 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/ReadyEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/ReadyEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/RecipientEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/RecipientEvent.cs index 336ffd029..778b5708c 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/RecipientEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/RecipientEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/RequestMembersParams.cs b/src/Discord.Net.WebSocket/API/Gateway/RequestMembersParams.cs index 6a8d283ed..f7a63e330 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/RequestMembersParams.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/RequestMembersParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System.Collections.Generic; diff --git a/src/Discord.Net.WebSocket/API/Gateway/ResumeParams.cs b/src/Discord.Net.WebSocket/API/Gateway/ResumeParams.cs index ffb46327b..826e8fadd 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/ResumeParams.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/ResumeParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs index d1347beae..870ae7366 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/ResumedEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/StatusUpdateParams.cs b/src/Discord.Net.WebSocket/API/Gateway/StatusUpdateParams.cs index 96897024c..cbde225d2 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/StatusUpdateParams.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/StatusUpdateParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/TypingStartEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/TypingStartEvent.cs index 5ceae4b7a..729ea176f 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/TypingStartEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/TypingStartEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/VoiceServerUpdateEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/VoiceServerUpdateEvent.cs index 29167c1cc..8df3f0108 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/VoiceServerUpdateEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/VoiceServerUpdateEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/VoiceStateUpdateParams.cs b/src/Discord.Net.WebSocket/API/Gateway/VoiceStateUpdateParams.cs index 521160126..ad21b14f1 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/VoiceStateUpdateParams.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/VoiceStateUpdateParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/Gateway/WebhookUpdateEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/WebhookUpdateEvent.cs index e5c7afe41..c1e6d5385 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/WebhookUpdateEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/WebhookUpdateEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Gateway diff --git a/src/Discord.Net.WebSocket/API/SocketFrame.cs b/src/Discord.Net.WebSocket/API/SocketFrame.cs index fae741432..11c82ec44 100644 --- a/src/Discord.Net.WebSocket/API/SocketFrame.cs +++ b/src/Discord.Net.WebSocket/API/SocketFrame.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API diff --git a/src/Discord.Net.WebSocket/API/Voice/IdentifyParams.cs b/src/Discord.Net.WebSocket/API/Voice/IdentifyParams.cs index d446867e1..508b70d70 100644 --- a/src/Discord.Net.WebSocket/API/Voice/IdentifyParams.cs +++ b/src/Discord.Net.WebSocket/API/Voice/IdentifyParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Voice diff --git a/src/Discord.Net.WebSocket/API/Voice/ReadyEvent.cs b/src/Discord.Net.WebSocket/API/Voice/ReadyEvent.cs index 7188cd8f7..10479cdb2 100644 --- a/src/Discord.Net.WebSocket/API/Voice/ReadyEvent.cs +++ b/src/Discord.Net.WebSocket/API/Voice/ReadyEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; using System; diff --git a/src/Discord.Net.WebSocket/API/Voice/SelectProtocolParams.cs b/src/Discord.Net.WebSocket/API/Voice/SelectProtocolParams.cs index 8c577e5b5..2e9bd157a 100644 --- a/src/Discord.Net.WebSocket/API/Voice/SelectProtocolParams.cs +++ b/src/Discord.Net.WebSocket/API/Voice/SelectProtocolParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Voice diff --git a/src/Discord.Net.WebSocket/API/Voice/SessionDescriptionEvent.cs b/src/Discord.Net.WebSocket/API/Voice/SessionDescriptionEvent.cs index 45befadcf..043b9fe86 100644 --- a/src/Discord.Net.WebSocket/API/Voice/SessionDescriptionEvent.cs +++ b/src/Discord.Net.WebSocket/API/Voice/SessionDescriptionEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Voice diff --git a/src/Discord.Net.WebSocket/API/Voice/SpeakingEvent.cs b/src/Discord.Net.WebSocket/API/Voice/SpeakingEvent.cs index 0272a8f53..c1746e9ce 100644 --- a/src/Discord.Net.WebSocket/API/Voice/SpeakingEvent.cs +++ b/src/Discord.Net.WebSocket/API/Voice/SpeakingEvent.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Voice diff --git a/src/Discord.Net.WebSocket/API/Voice/SpeakingParams.cs b/src/Discord.Net.WebSocket/API/Voice/SpeakingParams.cs index abdf90667..e03bfc751 100644 --- a/src/Discord.Net.WebSocket/API/Voice/SpeakingParams.cs +++ b/src/Discord.Net.WebSocket/API/Voice/SpeakingParams.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Voice diff --git a/src/Discord.Net.WebSocket/API/Voice/UdpProtocolInfo.cs b/src/Discord.Net.WebSocket/API/Voice/UdpProtocolInfo.cs index 6f4719e7e..5e69a0370 100644 --- a/src/Discord.Net.WebSocket/API/Voice/UdpProtocolInfo.cs +++ b/src/Discord.Net.WebSocket/API/Voice/UdpProtocolInfo.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Newtonsoft.Json; namespace Discord.API.Voice diff --git a/src/Discord.Net.WebSocket/API/Voice/VoiceOpCode.cs b/src/Discord.Net.WebSocket/API/Voice/VoiceOpCode.cs index 67afe6173..94006505a 100644 --- a/src/Discord.Net.WebSocket/API/Voice/VoiceOpCode.cs +++ b/src/Discord.Net.WebSocket/API/Voice/VoiceOpCode.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 namespace Discord.API.Voice { internal enum VoiceOpCode : byte diff --git a/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs b/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs index a305bb0b4..1d1b54895 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketApiClient.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Discord.API.Gateway; using Discord.Net.Queue; using Discord.Net.Rest; diff --git a/src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs b/src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs index 69894e202..62d95402a 100644 --- a/src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs +++ b/src/Discord.Net.WebSocket/DiscordVoiceApiClient.cs @@ -1,4 +1,3 @@ -#pragma warning disable CS1591 using Discord.API; using Discord.API.Voice; using Discord.Net.Converters; From dba39621cd52049bab938d05d20e1d8ac017029f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 13:58:44 +0200 Subject: [PATCH 14/27] Inlined variable declarations (#185) --- .../Extensions/MessageExtensions.cs | 3 +-- src/Discord.Net.Webhook/DiscordWebhookClient.cs | 3 +-- test/Discord.Net.Tests.Unit/MentionUtilsTests.cs | 12 +++--------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/Discord.Net.Commands/Extensions/MessageExtensions.cs b/src/Discord.Net.Commands/Extensions/MessageExtensions.cs index f880e1d98..9aa83d418 100644 --- a/src/Discord.Net.Commands/Extensions/MessageExtensions.cs +++ b/src/Discord.Net.Commands/Extensions/MessageExtensions.cs @@ -51,8 +51,7 @@ namespace Discord.Commands if (endPos == -1) return false; if (text.Length < endPos + 2 || text[endPos + 1] != ' ') return false; //Must end in "> " - ulong userId; - if (!MentionUtils.TryParseUser(text.Substring(0, endPos + 1), out userId)) return false; + if (!MentionUtils.TryParseUser(text.Substring(0, endPos + 1), out ulong userId)) return false; if (userId == user.Id) { argPos = endPos + 2; diff --git a/src/Discord.Net.Webhook/DiscordWebhookClient.cs b/src/Discord.Net.Webhook/DiscordWebhookClient.cs index d4affb08b..a4fdf9179 100644 --- a/src/Discord.Net.Webhook/DiscordWebhookClient.cs +++ b/src/Discord.Net.Webhook/DiscordWebhookClient.cs @@ -60,8 +60,7 @@ namespace Discord.Webhook /// Thrown if the is null or whitespace. public DiscordWebhookClient(string webhookUrl, DiscordRestConfig config) : this(config) { - string token; - ParseWebhookUrl(webhookUrl, out _webhookId, out token); + ParseWebhookUrl(webhookUrl, out _webhookId, out string token); ApiClient.LoginAsync(TokenType.Webhook, token).GetAwaiter().GetResult(); Webhook = WebhookClientHelper.GetWebhookAsync(this, _webhookId).GetAwaiter().GetResult(); } diff --git a/test/Discord.Net.Tests.Unit/MentionUtilsTests.cs b/test/Discord.Net.Tests.Unit/MentionUtilsTests.cs index 52f35fd9c..abd1191c8 100644 --- a/test/Discord.Net.Tests.Unit/MentionUtilsTests.cs +++ b/test/Discord.Net.Tests.Unit/MentionUtilsTests.cs @@ -47,9 +47,7 @@ namespace Discord var parsed = MentionUtils.ParseUser(user); Assert.Equal(id, parsed); - // also check tryparse - ulong result; - Assert.True(MentionUtils.TryParseUser(user, out result)); + Assert.True(MentionUtils.TryParseUser(user, out ulong result)); Assert.Equal(id, result); } [Theory] @@ -75,9 +73,7 @@ namespace Discord var parsed = MentionUtils.ParseChannel(channel); Assert.Equal(id, parsed); - // also check tryparse - ulong result; - Assert.True(MentionUtils.TryParseChannel(channel, out result)); + Assert.True(MentionUtils.TryParseChannel(channel, out ulong result)); Assert.Equal(id, result); } [Theory] @@ -103,9 +99,7 @@ namespace Discord var parsed = MentionUtils.ParseRole(role); Assert.Equal(id, parsed); - // also check tryparse - ulong result; - Assert.True(MentionUtils.TryParseRole(role, out result)); + Assert.True(MentionUtils.TryParseRole(role, out ulong result)); Assert.Equal(id, result); } [Theory] From c997ac2779491ae8c634276b6558b735cd9f95e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 14:15:12 +0200 Subject: [PATCH 15/27] Fixed some warnings (#184) * Fixed some warnings * Another fixed warning * Changed the SSendFileAsync to SendFileAsync * Removed para AlwaysAcknowledgeInteractions * Moved it back to the previous version * Added periods to the end like quin requested!! :(( Co-authored-by: MrCakeSlayer <13650699+MrCakeSlayer@users.noreply.github.com> --- .../Discord.Net.Commands.xml | 6 +- src/Discord.Net.Commands/ModuleBase.cs | 4 +- src/Discord.Net.Core/CDN.cs | 2 +- src/Discord.Net.Core/Discord.Net.Core.xml | 70 ++++++++++--------- .../Entities/Channels/IMessageChannel.cs | 8 +-- .../Entities/Channels/INestedChannel.cs | 4 +- .../Entities/Channels/IStageChannel.cs | 2 +- .../Entities/Guilds/IGuild.cs | 2 +- .../Interactions/IApplicationCommandOption.cs | 2 +- .../Interactions/IDiscordInteraction.cs | 10 +-- .../Message Components/ComponentBuilder.cs | 22 +++--- .../Slash Commands/SlashCommandBuilder.cs | 1 + .../Entities/Users/IGuildUser.cs | 2 +- .../Extensions/MessageExtensions.cs | 10 ++- .../Extensions/UserExtensions.cs | 6 +- .../Net/ApplicationCommandException.cs | 4 -- src/Discord.Net.Core/Utils/UrlValidation.cs | 2 +- src/Discord.Net.Rest/Discord.Net.Rest.xml | 10 +-- .../Entities/Channels/IRestMessageChannel.cs | 8 +-- .../Entities/Guilds/RestGuild.cs | 3 +- .../API/Gateway/ExtendedGuild.cs | 2 +- .../Discord.Net.WebSocket.xml | 40 +++++------ .../Channels/ISocketMessageChannel.cs | 8 +-- .../Entities/Guilds/SocketGuild.cs | 6 +- .../Entities/Interaction/SocketInteraction.cs | 34 ++++----- .../Helpers/CodeFixVerifier.Helper.cs | 10 +-- .../Helpers/DiagnosticVerifier.Helper.cs | 24 +++---- .../Verifiers/CodeFixVerifier.cs | 34 ++++----- .../Verifiers/DiagnosticVerifier.cs | 42 +++++------ 29 files changed, 192 insertions(+), 186 deletions(-) diff --git a/src/Discord.Net.Commands/Discord.Net.Commands.xml b/src/Discord.Net.Commands/Discord.Net.Commands.xml index cf68f8786..4ef47930e 100644 --- a/src/Discord.Net.Commands/Discord.Net.Commands.xml +++ b/src/Discord.Net.Commands/Discord.Net.Commands.xml @@ -1138,13 +1138,15 @@ Specifies if Discord should read this aloud using text-to-speech. An embed to be displayed alongside the . - A array of s to send with this response. Max 10 /// + Specifies if notifications are sent for mentioned users and roles in the . If null, all mentioned roles and users will be notified. + The request options for this async request. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + The message components to be included with this message. Used for interactions. A collection of stickers to send with the file. + A array of s to send with this response. Max 10. diff --git a/src/Discord.Net.Commands/ModuleBase.cs b/src/Discord.Net.Commands/ModuleBase.cs index a44fb26c0..eb517e65d 100644 --- a/src/Discord.Net.Commands/ModuleBase.cs +++ b/src/Discord.Net.Commands/ModuleBase.cs @@ -38,9 +38,9 @@ namespace Discord.Commands /// /// The request options for this async request. /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the file. - /// A array of s to send with this response. Max 10 + /// A array of s to send with this response. Max 10. protected virtual async Task ReplyAsync(string message = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) { return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); diff --git a/src/Discord.Net.Core/CDN.cs b/src/Discord.Net.Core/CDN.cs index a744c93fe..b48bef379 100644 --- a/src/Discord.Net.Core/CDN.cs +++ b/src/Discord.Net.Core/CDN.cs @@ -181,7 +181,7 @@ namespace Discord /// Gets a stickers url based off the id and format. /// /// The id of the sticker. - /// The format of the sticker + /// The format of the sticker. /// /// A URL to the sticker. /// diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index 9ee2ef458..695c14461 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -217,7 +217,7 @@ Gets a stickers url based off the id and format. The id of the sticker. - The format of the sticker + The format of the sticker. A URL to the sticker. @@ -1526,9 +1526,9 @@ If null, all mentioned roles and users will be notified. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + The message components to be included with this message. Used for interactions. A collection of stickers to send with the message. - A array of s to send with this response. Max 10 + A array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -1567,7 +1567,7 @@ If null, all mentioned roles and users will be notified. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + The message components to be included with this message. Used for interactions. A collection of stickers to send with the file. A task that represents an asynchronous send operation for delivering the message. The task result @@ -1604,7 +1604,7 @@ If null, all mentioned roles and users will be notified. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + The message components to be included with this message. Used for interactions. A collection of stickers to send with the file. A task that represents an asynchronous send operation for delivering the message. The task result @@ -1870,7 +1870,7 @@ await guildChannel.CreateInviteAsync(maxAge: 43200, maxUses: 3); - The id of the embedded application to open for this invite + The id of the embedded application to open for this invite. The time (in seconds) until the invite expires. Set to null to never expire. The max amount of times this invite may be used. Set to null to have unlimited uses. If true, the user accepting this invite will be kicked from the guild after closing their client. @@ -1892,7 +1892,7 @@ await guildChannel.CreateInviteAsync(maxAge: 43200, maxUses: 3); - The id of the user whose stream to display for this invite + The id of the user whose stream to display for this invite. The time (in seconds) until the invite expires. Set to null to never expire. The max amount of times this invite may be used. Set to null to have unlimited uses. If true, the user accepting this invite will be kicked from the guild after closing their client. @@ -1979,7 +1979,7 @@ Starts the stage, creating a stage instance. The topic for the stage/ - The privacy level of the stage + The privacy level of the stage. The options to be used when sending the request. A task that represents the asynchronous start operation. @@ -3996,7 +3996,7 @@ The description of the sticker. The tags of the sticker. The stream containing the file data. - The name of the file with the extension, ex: image.png + The name of the file with the extension, ex: image.png. The options to be used when sending the request. A task that represents the asynchronous creation operation. The task result contains the created sticker. @@ -5007,25 +5007,25 @@ Responds to an Interaction with type . The text of the message to be sent. - A array of embeds to send with this response. Max 10 + A array of embeds to send with this response. Max 10. if the message should be read out by a text-to-speech reader, otherwise . if the response should be hidden to everyone besides the invoker of the command, otherwise . The allowed mentions for this response. The request options for this response. - A to be sent with this response + A to be sent with this response. A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. Sends a followup message for this interaction. - The text of the message to be sent - A array of embeds to send with this response. Max 10 + The text of the message to be sent. + A array of embeds to send with this response. Max 10. if the message should be read out by a text-to-speech reader, otherwise . if the response should be hidden to everyone besides the invoker of the command, otherwise . The allowed mentions for this response. The request options for this response. - A to be sent with this response + A to be sent with this response. A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. The sent message. @@ -5414,10 +5414,10 @@ The label to use on the newly created link button. The url of this button. - The custom ID of this button - The custom ID of this button - The emote of this button - Disabled this button or not + The custom ID of this button. + The custom ID of this button. + The emote of this button. + Disabled this button or not. @@ -5430,7 +5430,7 @@ The label for this link button. The url for this link button to go to. - The emote for this link button + The emote for this link button. A builder with the newly created button. @@ -5439,7 +5439,7 @@ The label for this danger button. The custom id for this danger button. - The emote for this danger button + The emote for this danger button. A builder with the newly created button. @@ -5448,7 +5448,7 @@ The label for this primary button. The custom id for this primary button. - The emote for this primary button + The emote for this primary button. A builder with the newly created button. @@ -5457,7 +5457,7 @@ The label for this secondary button. The custom id for this secondary button. - The emote for this secondary button + The emote for this secondary button. A builder with the newly created button. @@ -5466,14 +5466,14 @@ The label for this success button. The custom id for this success button. - The emote for this success button + The emote for this success button. A builder with the newly created button. Sets the current buttons label to the specified text. - The text for the label + The text for the label. The current builder. @@ -9114,6 +9114,12 @@ If true, a user may create private threads in this guild. + + If true, a user may use public threads in this guild. + + + If true, a user may use private threads in this guild. + If true, a user may use external stickers in this guild. @@ -9129,10 +9135,10 @@ Creates a new with the provided packed value after converting to ulong. - + Creates a new structure with the provided permissions. - + Creates a new from this one, changing the provided non-null permissions. @@ -11058,7 +11064,7 @@ The message to add reactions to. - An array of reactions to add to the message + An array of reactions to add to the message. The options to be used when sending the request. A task that represents the asynchronous operation for adding a reaction to this message. @@ -11080,7 +11086,7 @@ The message to remove reactions from. - An array of reactions to remove from the message + An array of reactions to remove from the message. The options to be used when sending the request. A task that represents the asynchronous operation for removing a reaction to this message. @@ -11095,7 +11101,7 @@ The message to be sent. Determines whether the message should be read aloud by Discord or not. The to be sent. - A array of s to send with this response. Max 10 + A array of s to send with this response. Max 10. Specifies if notifications are sent for mentioned users and roles in the message . If null, all mentioned roles and users will be notified. @@ -11130,13 +11136,13 @@ The message to be sent. Whether the message should be read aloud by Discord or not. The to be sent. - A array of s to send with this response. Max 10 + A array of s to send with this response. Max 10. The options to be used when sending the request. Specifies if notifications are sent for mentioned users and roles in the message . If null, all mentioned roles and users will be notified. - The message components to be included with this message. Used for interactions + The message components to be included with this message. Used for interactions. A task that represents the asynchronous send operation. The task result contains the sent message. @@ -12782,7 +12788,7 @@ Not full URL validation right now. Just ensures protocol is present and that it's either http or https - url to validate before sending to Discord + url to validate before sending to Discord. A URL must include a protocol (http or https). true if url is valid by our standard, false if null, throws an error upon invalid diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs index 49fc5f433..9e145a630 100644 --- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs @@ -28,9 +28,9 @@ namespace Discord /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the message. - /// A array of s to send with this response. Max 10 + /// A array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. @@ -68,7 +68,7 @@ namespace Discord /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the file. /// /// A task that represents an asynchronous send operation for delivering the message. The task result @@ -104,7 +104,7 @@ namespace Discord /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the file. /// /// A task that represents an asynchronous send operation for delivering the message. The task result diff --git a/src/Discord.Net.Core/Entities/Channels/INestedChannel.cs b/src/Discord.Net.Core/Entities/Channels/INestedChannel.cs index d8072f94f..563acd4f8 100644 --- a/src/Discord.Net.Core/Entities/Channels/INestedChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/INestedChannel.cs @@ -67,7 +67,7 @@ namespace Discord /// await guildChannel.CreateInviteAsync(maxAge: 43200, maxUses: 3); /// /// - /// The id of the embedded application to open for this invite + /// The id of the embedded application to open for this invite. /// The time (in seconds) until the invite expires. Set to null to never expire. /// The max amount of times this invite may be used. Set to null to have unlimited uses. /// If true, the user accepting this invite will be kicked from the guild after closing their client. @@ -89,7 +89,7 @@ namespace Discord /// await guildChannel.CreateInviteAsync(maxAge: 43200, maxUses: 3); /// /// - /// The id of the user whose stream to display for this invite + /// The id of the user whose stream to display for this invite. /// The time (in seconds) until the invite expires. Set to null to never expire. /// The max amount of times this invite may be used. Set to null to have unlimited uses. /// If true, the user accepting this invite will be kicked from the guild after closing their client. diff --git a/src/Discord.Net.Core/Entities/Channels/IStageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IStageChannel.cs index 1461d8e50..9e417a4f1 100644 --- a/src/Discord.Net.Core/Entities/Channels/IStageChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IStageChannel.cs @@ -44,7 +44,7 @@ namespace Discord /// Starts the stage, creating a stage instance. /// /// The topic for the stage/ - /// The privacy level of the stage + /// The privacy level of the stage. /// The options to be used when sending the request. /// /// A task that represents the asynchronous start operation. diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs index 87c313700..9b5d6b23a 100644 --- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs @@ -1009,7 +1009,7 @@ namespace Discord /// The description of the sticker. /// The tags of the sticker. /// The stream containing the file data. - /// The name of the file with the extension, ex: image.png + /// The name of the file with the extension, ex: image.png. /// The options to be used when sending the request. /// /// A task that represents the asynchronous creation operation. The task result contains the created sticker. diff --git a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandOption.cs b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandOption.cs index 25e3c7dfc..0fc7fb4a3 100644 --- a/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandOption.cs +++ b/src/Discord.Net.Core/Entities/Interactions/IApplicationCommandOption.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Discord { /// - /// Options for the , see The docs. + /// Options for the , see The docs. /// public interface IApplicationCommandOption { diff --git a/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs index ae015c2a6..0dea203ef 100644 --- a/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs +++ b/src/Discord.Net.Core/Entities/Interactions/IDiscordInteraction.cs @@ -44,12 +44,12 @@ namespace Discord /// Responds to an Interaction with type . /// /// The text of the message to be sent. - /// A array of embeds to send with this response. Max 10 + /// A array of embeds to send with this response. Max 10. /// if the message should be read out by a text-to-speech reader, otherwise . /// if the response should be hidden to everyone besides the invoker of the command, otherwise . /// The allowed mentions for this response. /// The request options for this response. - /// A to be sent with this response + /// A to be sent with this response. /// A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. Task RespondAsync (string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null); @@ -57,13 +57,13 @@ namespace Discord /// /// Sends a followup message for this interaction. /// - /// The text of the message to be sent - /// A array of embeds to send with this response. Max 10 + /// The text of the message to be sent. + /// A array of embeds to send with this response. Max 10. /// if the message should be read out by a text-to-speech reader, otherwise . /// if the response should be hidden to everyone besides the invoker of the command, otherwise . /// The allowed mentions for this response. /// The request options for this response. - /// A to be sent with this response + /// A to be sent with this response. /// A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. /// /// The sent message. 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 be7f78304..8dbcb4319 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs @@ -240,7 +240,7 @@ namespace Discord /// /// Builds this builder into a used to send your components. /// - /// A that can be sent with . + /// A that can be sent with . public MessageComponent Build() { if (this._actionRows != null) @@ -427,10 +427,10 @@ namespace Discord /// /// The label to use on the newly created link button. /// The url of this button. - /// The custom ID of this button - /// The custom ID of this button - /// The emote of this button - /// Disabled this button or not + /// The custom ID of this button. + /// The custom ID of this button. + /// The emote of this button. + /// 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; @@ -459,7 +459,7 @@ namespace Discord /// /// The label for this link button. /// The url for this link button to go to. - /// The emote for this link button + /// The emote for this link button. /// A builder with the newly created button. public static ButtonBuilder CreateLinkButton(string label, string url, IEmote emote = null) => new ButtonBuilder(label, null, ButtonStyle.Link, url, emote: emote); @@ -469,7 +469,7 @@ namespace Discord /// /// The label for this danger button. /// The custom id for this danger button. - /// The emote for this danger button + /// The emote for this danger button. /// A builder with the newly created button. public static ButtonBuilder CreateDangerButton(string label, string customId, IEmote emote = null) => new ButtonBuilder(label, customId, ButtonStyle.Danger, emote: emote); @@ -479,7 +479,7 @@ namespace Discord /// /// The label for this primary button. /// The custom id for this primary button. - /// The emote for this primary button + /// The emote for this primary button. /// A builder with the newly created button. public static ButtonBuilder CreatePrimaryButton(string label, string customId, IEmote emote = null) => new ButtonBuilder(label, customId, emote: emote); @@ -489,7 +489,7 @@ namespace Discord /// /// The label for this secondary button. /// The custom id for this secondary button. - /// The emote for this secondary button + /// The emote for this secondary button. /// A builder with the newly created button. public static ButtonBuilder CreateSecondaryButton(string label, string customId, IEmote emote = null) => new ButtonBuilder(label, customId, ButtonStyle.Secondary, emote: emote); @@ -499,7 +499,7 @@ namespace Discord /// /// The label for this success button. /// The custom id for this success button. - /// The emote for this success button + /// The emote for this success button. /// A builder with the newly created button. public static ButtonBuilder CreateSuccessButton(string label, string customId, IEmote emote = null) => new ButtonBuilder(label, customId, ButtonStyle.Success, emote: emote); @@ -507,7 +507,7 @@ namespace Discord /// /// Sets the current buttons label to the specified text. /// - /// The text for the label + /// The text for the label. /// /// The current builder. public ButtonBuilder WithLabel(string label) 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 9581015d0..79afa410d 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs @@ -161,6 +161,7 @@ namespace Discord /// 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. diff --git a/src/Discord.Net.Core/Entities/Users/IGuildUser.cs b/src/Discord.Net.Core/Entities/Users/IGuildUser.cs index e131a6a61..58a797c5f 100644 --- a/src/Discord.Net.Core/Entities/Users/IGuildUser.cs +++ b/src/Discord.Net.Core/Entities/Users/IGuildUser.cs @@ -84,7 +84,7 @@ namespace Discord /// /// 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"); /// diff --git a/src/Discord.Net.Core/Extensions/MessageExtensions.cs b/src/Discord.Net.Core/Extensions/MessageExtensions.cs index be47c0587..3b21c128a 100644 --- a/src/Discord.Net.Core/Extensions/MessageExtensions.cs +++ b/src/Discord.Net.Core/Extensions/MessageExtensions.cs @@ -34,7 +34,7 @@ namespace Discord /// /// /// The message to add reactions to. - /// An array of reactions to add to the message + /// An array of reactions to add to the message. /// The options to be used when sending the request. /// /// A task that represents the asynchronous operation for adding a reaction to this message. @@ -59,7 +59,8 @@ namespace Discord /// /// /// The message to remove reactions from. - /// An array of reactions to remove from the message + /// The user who removed the reaction. + /// An array of reactions to remove from the message. /// The options to be used when sending the request. /// /// A task that represents the asynchronous operation for removing a reaction to this message. @@ -75,15 +76,18 @@ namespace Discord /// /// 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. - /// A array of s to send with this response. Max 10 + /// A array of s to send with this response. Max 10. /// /// Specifies if notifications are sent for mentioned users and roles in the message . /// 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. diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs index 3f05b6361..aa807c073 100644 --- a/src/Discord.Net.Core/Extensions/UserExtensions.cs +++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs @@ -27,13 +27,13 @@ namespace Discord /// The message to be sent. /// Whether the message should be read aloud by Discord or not. /// The to be sent. - /// A array of s to send with this response. Max 10 + /// A array of s to send with this response. Max 10. /// The options to be used when sending the request. /// /// Specifies if notifications are sent for mentioned users and roles in the message . /// If null, all mentioned roles and users will be notified. /// - /// The message components to be included with this message. Used for interactions + /// The message components to be included with this message. Used for interactions. /// /// A task that represents the asynchronous send operation. The task result contains the sent message. /// @@ -85,6 +85,7 @@ namespace Discord /// 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. @@ -142,6 +143,7 @@ namespace Discord /// 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. diff --git a/src/Discord.Net.Core/Net/ApplicationCommandException.cs b/src/Discord.Net.Core/Net/ApplicationCommandException.cs index 7e94293f4..acf19afe4 100644 --- a/src/Discord.Net.Core/Net/ApplicationCommandException.cs +++ b/src/Discord.Net.Core/Net/ApplicationCommandException.cs @@ -48,12 +48,8 @@ namespace Discord.Net /// /// 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. - /// public ApplicationCommandException(string requestJson, HttpException httpError) : base("The application command failed to be created!", httpError) { diff --git a/src/Discord.Net.Core/Utils/UrlValidation.cs b/src/Discord.Net.Core/Utils/UrlValidation.cs index 7cc9bd8bd..f5d7d4ce7 100644 --- a/src/Discord.Net.Core/Utils/UrlValidation.cs +++ b/src/Discord.Net.Core/Utils/UrlValidation.cs @@ -7,7 +7,7 @@ namespace Discord.Utils /// /// Not full URL validation right now. Just ensures protocol is present and that it's either http or https /// - /// url to validate before sending to Discord + /// url to validate before sending to Discord. /// A URL must include a protocol (http or https). /// true if url is valid by our standard, false if null, throws an error upon invalid public static bool Validate(string url) diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index 28f8ab534..af46d06ad 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -1781,9 +1781,9 @@ If null, all mentioned roles and users will be notified. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + The message components to be included with this message. Used for interactions. A collection of stickers to send with the message. - A array of s to send with this response. Max 10 + A array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -1809,7 +1809,7 @@ If null, all mentioned roles and users will be notified. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + 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 @@ -1836,7 +1836,7 @@ If null, all mentioned roles and users will be notified. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + 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 @@ -3666,7 +3666,7 @@ The description of the sticker. The tags of the sticker. The stream containing the file data. - The name of the file with the extension, ex: image.png + The name of the file with the extension, ex: image.png. The options to be used when sending the request. A task that represents the asynchronous creation operation. The task result contains the created sticker. diff --git a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs index 2b39e97d6..0198fea87 100644 --- a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs @@ -25,9 +25,9 @@ namespace Discord.Rest /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the message. - /// A array of s to send with this response. Max 10 + /// A array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. @@ -52,7 +52,7 @@ namespace Discord.Rest /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// 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 @@ -78,7 +78,7 @@ namespace Discord.Rest /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// 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 diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index a313de810..d78ff07cc 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -494,7 +494,6 @@ namespace Discord.Rest /// /// Gets a collection of all stage channels in this guild. /// - /// The that determines whether the object should be fetched from cache. /// The options to be used when sending the request. /// /// A task that represents the asynchronous get operation. The task result contains a read-only collection of @@ -1044,7 +1043,7 @@ namespace Discord.Rest /// The description of the sticker. /// The tags of the sticker. /// The stream containing the file data. - /// The name of the file with the extension, ex: image.png + /// The name of the file with the extension, ex: image.png. /// The options to be used when sending the request. /// /// A task that represents the asynchronous creation operation. The task result contains the created sticker. diff --git a/src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs b/src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs index 203f2fd5b..8470c6d8f 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/ExtendedGuild.cs @@ -27,6 +27,6 @@ namespace Discord.API.Gateway public DateTimeOffset JoinedAt { get; set; } [JsonProperty("threads")] - public Channel[] Threads { get; set; } + public new Channel[] Threads { get; set; } } } diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index ae283b4d1..c194d00ef 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -1474,9 +1474,9 @@ If null, all mentioned roles and users will be notified. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + The message components to be included with this message. Used for interactions. A collection of stickers to send with the message. - A array of s to send with this response. Max 10 + A array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -1501,7 +1501,7 @@ If null, all mentioned roles and users will be notified. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + The message components to be included with this message. Used for interactions. A collection of stickers to send with the file. A task that represents an asynchronous send operation for delivering the message. The task result @@ -1528,7 +1528,7 @@ If null, all mentioned roles and users will be notified. The message references to be included. Used to reply to specific messages. - The message components to be included with this message. Used for interactions + The message components to be included with this message. Used for interactions. A collection of stickers to send with the file. A task that represents an asynchronous send operation for delivering the message. The task result @@ -3632,7 +3632,7 @@ The description of the sticker. The tags of the sticker. The stream containing the file data. - The name of the file with the extension, ex: image.png + The name of the file with the extension, ex: image.png. The options to be used when sending the request. A task that represents the asynchronous creation operation. The task result contains the created sticker. @@ -4292,12 +4292,12 @@ The text of the message to be sent. - A array of embeds to send with this response. Max 10 + A array of embeds to send with this response. Max 10. if the message should be read out by a text-to-speech reader, otherwise . if the response should be hidden to everyone besides the invoker of the command, otherwise . The allowed mentions for this response. The request options for this response. - A to be sent with this response + A to be sent with this response. A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. Message content is too long, length must be less or equal to . The parameters provided were invalid or the token was invalid. @@ -4306,13 +4306,13 @@ Sends a followup message for this interaction. - The text of the message to be sent - A array of embeds to send with this response. Max 10 + The text of the message to be sent. + A array of embeds to send with this response. Max 10. if the message should be read out by a text-to-speech reader, otherwise . if the response should be hidden to everyone besides the invoker of the command, otherwise . The allowed mentions for this response. The request options for this response. - A to be sent with this response + A to be sent with this response. A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. The sent message. @@ -4322,15 +4322,15 @@ Sends a followup message for this interaction. - The text of the message to be sent - The file to upload - The file name of the attachment - A array of embeds to send with this response. Max 10 + The text of the message to be sent. + The file to upload. + The file name of the attachment. + A array of embeds to send with this response. Max 10. if the message should be read out by a text-to-speech reader, otherwise . if the response should be hidden to everyone besides the invoker of the command, otherwise . The allowed mentions for this response. The request options for this response. - A to be sent with this response + A to be sent with this response. A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. The sent message. @@ -4340,15 +4340,15 @@ Sends a followup message for this interaction. - The text of the message to be sent - The file to upload - The file name of the attachment - A array of embeds to send with this response. Max 10 + The text of the message to be sent. + The file to upload. + The file name of the attachment. + A array of embeds to send with this response. Max 10. if the message should be read out by a text-to-speech reader, otherwise . if the response should be hidden to everyone besides the invoker of the command, otherwise . The allowed mentions for this response. The request options for this response. - A to be sent with this response + A to be sent with this response. A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. The sent message. diff --git a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs index 8b60b18a1..5ced13628 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs @@ -34,9 +34,9 @@ namespace Discord.WebSocket /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the message. - /// A array of s to send with this response. Max 10 + /// A array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. @@ -60,7 +60,7 @@ namespace Discord.WebSocket /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the file. /// /// A task that represents an asynchronous send operation for delivering the message. The task result @@ -86,7 +86,7 @@ namespace Discord.WebSocket /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - /// The message components to be included with this message. Used for interactions + /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the file. /// /// A task that represents an asynchronous send operation for delivering the message. The task result diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index efc3ab1b4..e4a03f818 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -1376,7 +1376,7 @@ namespace Discord.WebSocket /// The description of the sticker. /// The tags of the sticker. /// The stream containing the file data. - /// The name of the file with the extension, ex: image.png + /// The name of the file with the extension, ex: image.png. /// The options to be used when sending the request. /// /// A task that represents the asynchronous creation operation. The task result contains the created sticker. @@ -1666,10 +1666,10 @@ namespace Discord.WebSocket Task IGuild.GetVoiceChannelAsync(ulong id, CacheMode mode, RequestOptions options) => Task.FromResult(GetVoiceChannel(id)); /// - Task IGuild.GetStageChannelAsync(ulong id, CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null) + Task IGuild.GetStageChannelAsync(ulong id, CacheMode mode, RequestOptions options) => Task.FromResult(GetStageChannel(id)); /// - Task> IGuild.GetStageChannelsAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null) + Task> IGuild.GetStageChannelsAsync(CacheMode mode, RequestOptions options) => Task.FromResult>(StageChannels); /// Task IGuild.GetAFKChannelAsync(CacheMode mode, RequestOptions options) diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs index d88a7f004..e98999d11 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs @@ -117,18 +117,14 @@ namespace Discord.WebSocket /// /// Responds to an Interaction with type . - /// - /// If you have set to , You should use - /// instead. - /// /// /// The text of the message to be sent. - /// A array of embeds to send with this response. Max 10 + /// A array of embeds to send with this response. Max 10. /// if the message should be read out by a text-to-speech reader, otherwise . /// if the response should be hidden to everyone besides the invoker of the command, otherwise . /// The allowed mentions for this response. /// The request options for this response. - /// A to be sent with this response + /// A to be sent with this response. /// A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. /// Message content is too long, length must be less or equal to . /// The parameters provided were invalid or the token was invalid. @@ -138,13 +134,13 @@ namespace Discord.WebSocket /// /// Sends a followup message for this interaction. /// - /// The text of the message to be sent - /// A array of embeds to send with this response. Max 10 + /// The text of the message to be sent. + /// A array of embeds to send with this response. Max 10. /// if the message should be read out by a text-to-speech reader, otherwise . /// if the response should be hidden to everyone besides the invoker of the command, otherwise . /// The allowed mentions for this response. /// The request options for this response. - /// A to be sent with this response + /// A to be sent with this response. /// A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. /// /// The sent message. @@ -155,15 +151,15 @@ namespace Discord.WebSocket /// /// Sends a followup message for this interaction. /// - /// The text of the message to be sent - /// The file to upload - /// The file name of the attachment - /// A array of embeds to send with this response. Max 10 + /// The text of the message to be sent. + /// The file to upload. + /// The file name of the attachment. + /// A array of embeds to send with this response. Max 10. /// if the message should be read out by a text-to-speech reader, otherwise . /// if the response should be hidden to everyone besides the invoker of the command, otherwise . /// The allowed mentions for this response. /// The request options for this response. - /// A to be sent with this response + /// A to be sent with this response. /// A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. /// /// The sent message. @@ -174,15 +170,15 @@ namespace Discord.WebSocket /// /// Sends a followup message for this interaction. /// - /// The text of the message to be sent - /// The file to upload - /// The file name of the attachment - /// A array of embeds to send with this response. Max 10 + /// The text of the message to be sent. + /// The file to upload. + /// The file name of the attachment. + /// A array of embeds to send with this response. Max 10. /// if the message should be read out by a text-to-speech reader, otherwise . /// if the response should be hidden to everyone besides the invoker of the command, otherwise . /// The allowed mentions for this response. /// The request options for this response. - /// A to be sent with this response + /// A to be sent with this response. /// A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. /// /// The sent message. diff --git a/test/Discord.Net.Analyzers.Tests/Helpers/CodeFixVerifier.Helper.cs b/test/Discord.Net.Analyzers.Tests/Helpers/CodeFixVerifier.Helper.cs index 0f73d0643..42f7b08c1 100644 --- a/test/Discord.Net.Analyzers.Tests/Helpers/CodeFixVerifier.Helper.cs +++ b/test/Discord.Net.Analyzers.Tests/Helpers/CodeFixVerifier.Helper.cs @@ -18,7 +18,7 @@ namespace TestHelper /// Apply the inputted CodeAction to the inputted document. /// Meant to be used to apply codefixes. /// - /// The Document to apply the fix on + /// The Document to apply the fix on. /// A CodeAction that will be applied to the Document. /// A Document with the changes from the CodeAction private static Document ApplyFix(Document document, CodeAction codeAction) @@ -33,8 +33,8 @@ namespace TestHelper /// Note: Considers Diagnostics to be the same if they have the same Ids. In the case of multiple diagnostics with the same Id in a row, /// this method may not necessarily return the new one. /// - /// The Diagnostics that existed in the code before the CodeFix was applied - /// The Diagnostics that exist in the code after the CodeFix was applied + /// The Diagnostics that existed in the code before the CodeFix was applied. + /// The Diagnostics that exist in the code after the CodeFix was applied. /// A list of Diagnostics that only surfaced in the code after the CodeFix was applied private static IEnumerable GetNewDiagnostics(IEnumerable diagnostics, IEnumerable newDiagnostics) { @@ -61,7 +61,7 @@ namespace TestHelper /// /// Get the existing compiler diagnostics on the inputted document. /// - /// The Document to run the compiler diagnostic analyzers on + /// The Document to run the compiler diagnostic analyzers on. /// The compiler diagnostics that were found in the code private static IEnumerable GetCompilerDiagnostics(Document document) { @@ -71,7 +71,7 @@ namespace TestHelper /// /// Given a document, turn it into a string based on the syntax root /// - /// The Document to be converted to a string + /// The Document to be converted to a string. /// A string containing the syntax of the Document after formatting private static string GetStringFromDocument(Document document) { diff --git a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs index 43748aa93..23bb319a6 100644 --- a/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs +++ b/test/Discord.Net.Analyzers.Tests/Helpers/DiagnosticVerifier.Helper.cs @@ -35,9 +35,9 @@ namespace TestHelper /// /// Given classes in the form of strings, their language, and an IDiagnosticAnlayzer to apply to it, return the diagnostics found in the string after converting it to a document. /// - /// Classes in the form of strings - /// The language the source classes are in - /// The analyzer to be run on the sources + /// Classes in the form of strings. + /// The language the source classes are in. + /// The analyzer to be run on the sources. /// An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location private static Diagnostic[] GetSortedDiagnostics(string[] sources, string language, DiagnosticAnalyzer analyzer) { @@ -48,8 +48,8 @@ namespace TestHelper /// Given an analyzer and a document to apply it to, run the analyzer and gather an array of diagnostics found in it. /// The returned diagnostics are then ordered by location in the source document. /// - /// The analyzer to run on the documents - /// The Documents that the analyzer will be run on + /// The analyzer to run on the documents. + /// The Documents that the analyzer will be run on. /// An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer analyzer, Document[] documents) { @@ -93,7 +93,7 @@ namespace TestHelper /// /// Sort diagnostics by location in source document /// - /// The list of Diagnostics to be sorted + /// The list of Diagnostics to be sorted. /// An IEnumerable containing the Diagnostics in order of Location private static Diagnostic[] SortDiagnostics(IEnumerable diagnostics) { @@ -106,8 +106,8 @@ namespace TestHelper /// /// Given an array of strings as sources and a language, turn them into a project and return the documents and spans of it. /// - /// Classes in the form of strings - /// The language the source code is in + /// Classes in the form of strings. + /// The language the source code is in. /// A Tuple containing the Documents produced from the sources and their TextSpans if relevant private static Document[] GetDocuments(string[] sources, string language) { @@ -130,8 +130,8 @@ namespace TestHelper /// /// Create a Document from a string through creating a project that contains it. /// - /// Classes in the form of a string - /// The language the source code is in + /// Classes in the form of a string. + /// The language the source code is in. /// A Document created from the source string protected static Document CreateDocument(string source, string language = LanguageNames.CSharp) { @@ -141,8 +141,8 @@ namespace TestHelper /// /// Create a project using the inputted strings as sources. /// - /// Classes in the form of strings - /// The language the source code is in + /// Classes in the form of strings. + /// The language the source code is in. /// A Project created out of the Documents created from the source strings private static Project CreateProject(string[] sources, string language = LanguageNames.CSharp) { diff --git a/test/Discord.Net.Analyzers.Tests/Verifiers/CodeFixVerifier.cs b/test/Discord.Net.Analyzers.Tests/Verifiers/CodeFixVerifier.cs index 5d057b610..d1cb6cd1b 100644 --- a/test/Discord.Net.Analyzers.Tests/Verifiers/CodeFixVerifier.cs +++ b/test/Discord.Net.Analyzers.Tests/Verifiers/CodeFixVerifier.cs @@ -1,4 +1,4 @@ -using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.Diagnostics; @@ -38,10 +38,10 @@ namespace TestHelper /// /// Called to test a C# codefix when applied on the inputted string as a source /// - /// A class in the form of a string before the CodeFix was applied to it - /// A class in the form of a string after the CodeFix was applied to it - /// Index determining which codefix to apply if there are multiple - /// A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied + /// A class in the form of a string before the CodeFix was applied to it. + /// A class in the form of a string after the CodeFix was applied to it. + /// Index determining which codefix to apply if there are multiple. + /// A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied. protected void VerifyCSharpFix(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false) { VerifyFix(LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), GetCSharpCodeFixProvider(), oldSource, newSource, codeFixIndex, allowNewCompilerDiagnostics); @@ -50,10 +50,10 @@ namespace TestHelper /// /// Called to test a VB codefix when applied on the inputted string as a source /// - /// A class in the form of a string before the CodeFix was applied to it - /// A class in the form of a string after the CodeFix was applied to it - /// Index determining which codefix to apply if there are multiple - /// A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied + /// A class in the form of a string before the CodeFix was applied to it. + /// A class in the form of a string after the CodeFix was applied to it. + /// Index determining which codefix to apply if there are multiple. + /// A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied. protected void VerifyBasicFix(string oldSource, string newSource, int? codeFixIndex = null, bool allowNewCompilerDiagnostics = false) { VerifyFix(LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), GetBasicCodeFixProvider(), oldSource, newSource, codeFixIndex, allowNewCompilerDiagnostics); @@ -65,13 +65,13 @@ namespace TestHelper /// Then gets the string after the codefix is applied and compares it with the expected result. /// Note: If any codefix causes new diagnostics to show up, the test fails unless allowNewCompilerDiagnostics is set to true. /// - /// The language the source code is in - /// The analyzer to be applied to the source code - /// The codefix to be applied to the code wherever the relevant Diagnostic is found - /// A class in the form of a string before the CodeFix was applied to it - /// A class in the form of a string after the CodeFix was applied to it - /// Index determining which codefix to apply if there are multiple - /// A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied + /// The language the source code is in. + /// The analyzer to be applied to the source code. + /// The codefix to be applied to the code wherever the relevant Diagnostic is found. + /// A class in the form of a string before the CodeFix was applied to it. + /// A class in the form of a string after the CodeFix was applied to it. + /// Index determining which codefix to apply if there are multiple. + /// A bool controlling whether or not the test will fail if the CodeFix introduces other warnings after being applied. private void VerifyFix(string language, DiagnosticAnalyzer analyzer, CodeFixProvider codeFixProvider, string oldSource, string newSource, int? codeFixIndex, bool allowNewCompilerDiagnostics) { var document = CreateDocument(oldSource, language); @@ -126,4 +126,4 @@ namespace TestHelper Assert.Equal(newSource, actual); } } -} \ No newline at end of file +} diff --git a/test/Discord.Net.Analyzers.Tests/Verifiers/DiagnosticVerifier.cs b/test/Discord.Net.Analyzers.Tests/Verifiers/DiagnosticVerifier.cs index 3564093f8..9b0219a63 100644 --- a/test/Discord.Net.Analyzers.Tests/Verifiers/DiagnosticVerifier.cs +++ b/test/Discord.Net.Analyzers.Tests/Verifiers/DiagnosticVerifier.cs @@ -37,8 +37,8 @@ namespace TestHelper /// Called to test a C# DiagnosticAnalyzer when applied on the single inputted string as a source /// Note: input a DiagnosticResult for each Diagnostic expected /// - /// A class in the form of a string to run the analyzer on - /// DiagnosticResults that should appear after the analyzer is run on the source + /// A class in the form of a string to run the analyzer on. + /// DiagnosticResults that should appear after the analyzer is run on the source. protected void VerifyCSharpDiagnostic(string source, params DiagnosticResult[] expected) { VerifyDiagnostics(new[] { source }, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected); @@ -48,8 +48,8 @@ namespace TestHelper /// Called to test a VB DiagnosticAnalyzer when applied on the single inputted string as a source /// Note: input a DiagnosticResult for each Diagnostic expected /// - /// A class in the form of a string to run the analyzer on - /// DiagnosticResults that should appear after the analyzer is run on the source + /// A class in the form of a string to run the analyzer on. + /// DiagnosticResults that should appear after the analyzer is run on the source. protected void VerifyBasicDiagnostic(string source, params DiagnosticResult[] expected) { VerifyDiagnostics(new[] { source }, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected); @@ -59,8 +59,8 @@ namespace TestHelper /// Called to test a C# DiagnosticAnalyzer when applied on the inputted strings as a source /// Note: input a DiagnosticResult for each Diagnostic expected /// - /// An array of strings to create source documents from to run the analyzers on - /// DiagnosticResults that should appear after the analyzer is run on the sources + /// An array of strings to create source documents from to run the analyzers on. + /// DiagnosticResults that should appear after the analyzer is run on the sources. protected void VerifyCSharpDiagnostic(string[] sources, params DiagnosticResult[] expected) { VerifyDiagnostics(sources, LanguageNames.CSharp, GetCSharpDiagnosticAnalyzer(), expected); @@ -70,8 +70,8 @@ namespace TestHelper /// Called to test a VB DiagnosticAnalyzer when applied on the inputted strings as a source /// Note: input a DiagnosticResult for each Diagnostic expected /// - /// An array of strings to create source documents from to run the analyzers on - /// DiagnosticResults that should appear after the analyzer is run on the sources + /// An array of strings to create source documents from to run the analyzers on. + /// DiagnosticResults that should appear after the analyzer is run on the sources. protected void VerifyBasicDiagnostic(string[] sources, params DiagnosticResult[] expected) { VerifyDiagnostics(sources, LanguageNames.VisualBasic, GetBasicDiagnosticAnalyzer(), expected); @@ -81,10 +81,10 @@ namespace TestHelper /// General method that gets a collection of actual diagnostics found in the source after the analyzer is run, /// then verifies each of them. /// - /// An array of strings to create source documents from to run the analyzers on - /// The language of the classes represented by the source strings - /// The analyzer to be run on the source code - /// DiagnosticResults that should appear after the analyzer is run on the sources + /// An array of strings to create source documents from to run the analyzers on. + /// The language of the classes represented by the source strings. + /// The analyzer to be run on the source code. + /// DiagnosticResults that should appear after the analyzer is run on the sources. private void VerifyDiagnostics(string[] sources, string language, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expected) { var diagnostics = GetSortedDiagnostics(sources, language, analyzer); @@ -98,9 +98,9 @@ namespace TestHelper /// Checks each of the actual Diagnostics found and compares them with the corresponding DiagnosticResult in the array of expected results. /// Diagnostics are considered equal only if the DiagnosticResultLocation, Id, Severity, and Message of the DiagnosticResult match the actual diagnostic. /// - /// The Diagnostics found by the compiler after running the analyzer on the source code - /// The analyzer that was being run on the sources - /// Diagnostic Results that should have appeared in the code + /// The Diagnostics found by the compiler after running the analyzer on the source code. + /// The analyzer that was being run on the sources. + /// Diagnostic Results that should have appeared in the code. private static void VerifyDiagnosticResults(IEnumerable actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults) { int expectedCount = expectedResults.Length; @@ -173,10 +173,10 @@ namespace TestHelper /// /// Helper method to VerifyDiagnosticResult that checks the location of a diagnostic and compares it with the location in the expected DiagnosticResult. /// - /// The analyzer that was being run on the sources - /// The diagnostic that was found in the code - /// The Location of the Diagnostic found in the code - /// The DiagnosticResultLocation that should have been found + /// The analyzer that was being run on the sources. + /// The diagnostic that was found in the code. + /// The Location of the Diagnostic found in the code. + /// The DiagnosticResultLocation that should have been found. private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Location actual, DiagnosticResultLocation expected) { var actualSpan = actual.GetLineSpan(); @@ -215,8 +215,8 @@ namespace TestHelper /// /// Helper method to format a Diagnostic into an easily readable string /// - /// The analyzer that this verifier tests - /// The Diagnostics to be formatted + /// The analyzer that this verifier tests. + /// The Diagnostics to be formatted. /// The Diagnostics formatted as a string private static string FormatDiagnostics(DiagnosticAnalyzer analyzer, params Diagnostic[] diagnostics) { From 0b47c71815ef219ab2f4d614523bb34778f3a37c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 14:33:59 +0200 Subject: [PATCH 16/27] Object initialization can be simplified fixed (#189) --- .../Slash Commands/SlashCommandBuilder.cs | 38 +++++++------- .../EmbedBuilderTests.cs | 50 ++++++++++++------- 2 files changed, 53 insertions(+), 35 deletions(-) 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 79afa410d..b41be71fa 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Slash Commands/SlashCommandBuilder.cs @@ -191,15 +191,17 @@ namespace Discord throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault)); } - SlashCommandOptionBuilder option = new SlashCommandOptionBuilder(); - option.Name = name; - option.Description = description; - option.Required = required; - option.Default = isDefault; - option.Options = options; - option.Type = type; - option.Autocomplete = isAutocomplete; - option.Choices = choices != null ? new List(choices) : null; + SlashCommandOptionBuilder option = new SlashCommandOptionBuilder + { + Name = name, + Description = description, + Required = required, + Default = isDefault, + Options = options, + Type = type, + Autocomplete = isAutocomplete, + Choices = choices != null ? new List(choices) : null + }; return AddOption(option); } @@ -421,14 +423,16 @@ namespace Discord throw new ArgumentException("There can only be one command option with default set to true!", nameof(isDefault)); } - SlashCommandOptionBuilder option = new SlashCommandOptionBuilder(); - option.Name = name; - option.Description = description; - option.Required = required; - option.Default = isDefault; - option.Options = options; - option.Type = type; - option.Choices = choices != null ? new List(choices) : null; + SlashCommandOptionBuilder option = new SlashCommandOptionBuilder + { + Name = name, + Description = description, + Required = required, + Default = isDefault, + Options = options, + Type = type, + Choices = choices != null ? new List(choices) : null + }; return AddOption(option); } diff --git a/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs b/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs index da21afee1..bfe4f9a8f 100644 --- a/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs +++ b/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs @@ -95,8 +95,10 @@ namespace Discord { Assert.Throws(() => { - var builder = new EmbedBuilder(); - builder.Title = title; + var builder = new EmbedBuilder + { + Title = title + }; }); Assert.Throws(() => { @@ -113,8 +115,10 @@ namespace Discord [InlineData("jVyLChmA7aBZozXQuZ3VDEcwW6zOq0nteOVYBZi31ny73rpXfSSBXR4Jw6FiplDKQseKskwRMuBZkUewrewqAbkBZpslHirvC5nEzRySoDIdTRnkVvTXZUXg75l3bQCjuuHxDd6DfrY8ihd6yZX1Y0XFeg239YBcYV4TpL9uQ8H3HFYxrWhLlG2PRVjUmiglP5iXkawszNwMVm1SZ5LZT4jkMZHxFegVi7170d16iaPWOovu50aDDHy087XBtLKV")] public void Tile_Valid(string title) { - var builder = new EmbedBuilder(); - builder.Title = title; + var builder = new EmbedBuilder + { + Title = title + }; new EmbedBuilder().WithTitle(title); } @@ -133,8 +137,10 @@ namespace Discord Assert.Throws(() => new EmbedBuilder().WithDescription(description)); Assert.Throws(() => { - var b = new EmbedBuilder(); - b.Description = description; + var b = new EmbedBuilder + { + Description = description + }; }); } } @@ -156,8 +162,10 @@ namespace Discord var b = new EmbedBuilder().WithDescription(description); Assert.Equal(description, b.Description); - b = new EmbedBuilder(); - b.Description = description; + b = new EmbedBuilder + { + Description = description + }; Assert.Equal(description, b.Description); } } @@ -181,10 +189,12 @@ namespace Discord Assert.Equal(result.ImageUrl, url); Assert.Equal(result.ThumbnailUrl, url); - result = new EmbedBuilder(); - result.Url = url; - result.ImageUrl = url; - result.ThumbnailUrl = url; + result = new EmbedBuilder + { + Url = url, + ImageUrl = url, + ThumbnailUrl = url + }; Assert.Equal(result.Url, url); Assert.Equal(result.ImageUrl, url); Assert.Equal(result.ThumbnailUrl, url); @@ -276,8 +286,10 @@ namespace Discord Assert.Equal(url, e.Footer.IconUrl); Assert.Equal(name, e.Footer.Text); // use the property - e = new EmbedBuilder(); - e.Footer = footer; + e = new EmbedBuilder + { + Footer = footer + }; Assert.Equal(url, e.Footer.IconUrl); Assert.Equal(name, e.Footer.Text); } @@ -375,10 +387,12 @@ namespace Discord Assert.Equal("value", e.Value); Assert.True(e.IsInline); // use the properties - e = new EmbedFieldBuilder(); - e.IsInline = true; - e.Name = "name"; - e.Value = "value"; + e = new EmbedFieldBuilder + { + IsInline = true, + Name = "name", + Value = "value" + }; Assert.Equal("name", e.Name); Assert.Equal("value", e.Value); Assert.True(e.IsInline); From a8ffa5d02c713d739447c1775e50b47ca091ac65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 14:49:30 +0200 Subject: [PATCH 17/27] Conditional-expression-simplification (#193) --- .../Message Components/ComponentBuilder.cs | 6 ++++-- src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs | 11 ++++++----- .../API/Rest/CreateWebhookMessageParams.cs | 7 ++++--- src/Discord.Net.Rest/Extensions/EntityExtensions.cs | 2 +- src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs | 2 +- src/Discord.Net.WebSocket/DiscordSocketClient.cs | 2 +- .../Entities/Stickers/SocketSticker.cs | 4 +--- 7 files changed, 18 insertions(+), 16 deletions(-) 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 8dbcb4319..7725688b8 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs @@ -207,8 +207,10 @@ namespace Discord if (_actionRows == null) { - _actionRows = new List(); - _actionRows.Add(new ActionRowBuilder().AddComponent(builtButton)); + _actionRows = new List + { + new ActionRowBuilder().AddComponent(builtButton) + }; } else { diff --git a/src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs b/src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs index 405d3e04e..225caaaae 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateStickerParams.cs @@ -19,11 +19,12 @@ namespace Discord.API.Rest public IReadOnlyDictionary ToDictionary() { - var d = new Dictionary(); - - d["name"] = $"{Name}"; - d["description"] = Description; - d["tags"] = Tags; + var d = new Dictionary + { + ["name"] = $"{Name}", + ["description"] = Description, + ["tags"] = Tags + }; string contentType = "image/png"; diff --git a/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs b/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs index e21cae845..aea4b9538 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs @@ -51,9 +51,10 @@ namespace Discord.API.Rest d["file"] = File.Value; } - var payload = new Dictionary(); - - payload["content"] = Content; + var payload = new Dictionary + { + ["content"] = Content + }; if (IsTTS.IsSpecified) payload["tts"] = IsTTS.Value.ToString(); diff --git a/src/Discord.Net.Rest/Extensions/EntityExtensions.cs b/src/Discord.Net.Rest/Extensions/EntityExtensions.cs index 0c2e0f8c2..ca36bc6d6 100644 --- a/src/Discord.Net.Rest/Extensions/EntityExtensions.cs +++ b/src/Discord.Net.Rest/Extensions/EntityExtensions.cs @@ -39,7 +39,7 @@ namespace Discord.Rest return new RoleTags( model.BotId.IsSpecified ? model.BotId.Value : null, model.IntegrationId.IsSpecified ? model.IntegrationId.Value : null, - model.IsPremiumSubscriber.IsSpecified ? true : false); + model.IsPremiumSubscriber.IsSpecified); } public static API.Embed ToModel(this Embed entity) { diff --git a/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs b/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs index d2a7cabee..52fea021b 100644 --- a/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs +++ b/src/Discord.Net.Rest/Net/Queue/RequestQueueBucket.cs @@ -377,7 +377,7 @@ namespace Discord.Net.Queue Debug.WriteLine($"[{id}] Retry-After: {info.RetryAfter.Value} ({info.RetryAfter.Value} ms)"); #endif } - else if (info.ResetAfter.HasValue && (request.Options.UseSystemClock.HasValue ? !request.Options.UseSystemClock.Value : false)) + else if (info.ResetAfter.HasValue && (request.Options.UseSystemClock.HasValue && !request.Options.UseSystemClock.Value)) { resetTick = DateTimeOffset.UtcNow.Add(info.ResetAfter.Value); #if DEBUG_LIMITS diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 3e5a6d543..72f22c9a5 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -2453,7 +2453,7 @@ namespace Discord.WebSocket SocketStageChannel before = type == "STAGE_INSTANCE_UPDATE" ? stageChannel.Clone() : null; - stageChannel.Update(data, type == "STAGE_INSTANCE_CREATE" ? true : type == "STAGE_INSTANCE_DELETE" ? false : false); + stageChannel.Update(data, type == "STAGE_INSTANCE_CREATE"); switch (type) { diff --git a/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs b/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs index eaf80f9c2..5e4e09aa8 100644 --- a/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs +++ b/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs @@ -95,9 +95,7 @@ namespace Discord.WebSocket stickerModel.Type == this.Type && stickerModel.SortValue == this.SortOrder && stickerModel.Available == this.Available && - (stickerModel.Tags.IsSpecified ? - stickerModel.Tags.Value == string.Join(", ", this.Tags) : - true); + (!stickerModel.Tags.IsSpecified || stickerModel.Tags.Value == string.Join(", ", this.Tags)); } else return base.Equals(obj); From ad34d8b7b16fea5aae6456ec5978a9264d9b99da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 14:49:59 +0200 Subject: [PATCH 18/27] Capitlazation fixes (#192) --- samples/idn/Inspector.cs | 2 +- samples/idn/Program.cs | 2 +- .../API/Gateway/InviteCreatedEvent.cs | 2 +- .../EmbedBuilderTests.cs | 90 +++++++++---------- 4 files changed, 48 insertions(+), 48 deletions(-) diff --git a/samples/idn/Inspector.cs b/samples/idn/Inspector.cs index 3806e0e79..1544c8d07 100644 --- a/samples/idn/Inspector.cs +++ b/samples/idn/Inspector.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Reflection; using System.Text; -namespace idn +namespace Idn { public static class Inspector { diff --git a/samples/idn/Program.cs b/samples/idn/Program.cs index ffd8fd1af..abc315a2d 100644 --- a/samples/idn/Program.cs +++ b/samples/idn/Program.cs @@ -13,7 +13,7 @@ using System.Threading; using System.Text; using System.Diagnostics; -namespace idn +namespace Idn { public class Program { diff --git a/src/Discord.Net.WebSocket/API/Gateway/InviteCreatedEvent.cs b/src/Discord.Net.WebSocket/API/Gateway/InviteCreatedEvent.cs index 8f8002029..1613cdfa6 100644 --- a/src/Discord.Net.WebSocket/API/Gateway/InviteCreatedEvent.cs +++ b/src/Discord.Net.WebSocket/API/Gateway/InviteCreatedEvent.cs @@ -19,7 +19,7 @@ namespace Discord.API.Gateway [JsonProperty("guild_id")] public ulong? GuildID { get; set; } [JsonProperty("inviter")] - public Optional inviter { get; set; } + public Optional Inviter { get; set; } [JsonProperty("max_age")] public int RawAge { get; set; } [JsonProperty("max_uses")] diff --git a/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs b/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs index bfe4f9a8f..319d3fb11 100644 --- a/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs +++ b/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs @@ -9,9 +9,9 @@ namespace Discord /// public class EmbedBuilderTests { - private const string name = "chrisj"; - private const string icon = "https://meowpuffygottem.fun/blob.png"; - private const string url = "https://meowpuffygottem.fun/"; + private const string Name = "chrisj"; + private const string Icon = "https://meowpuffygottem.fun/blob.png"; + private const string Url = "https://meowpuffygottem.fun/"; /// /// Tests the behavior of . @@ -24,12 +24,12 @@ namespace Discord Assert.Null(builder.Author); builder = new EmbedBuilder() - .WithAuthor(name, icon, url); + .WithAuthor(Name, Icon, Url); Assert.NotNull(builder.Author); - Assert.Equal(name, builder.Author.Name); - Assert.Equal(icon, builder.Author.IconUrl); - Assert.Equal(url, builder.Author.Url); + Assert.Equal(Name, builder.Author.Name); + Assert.Equal(Icon, builder.Author.IconUrl); + Assert.Equal(Url, builder.Author.Url); } /// @@ -39,15 +39,15 @@ namespace Discord public void WithAuthor_AuthorBuilder() { var author = new EmbedAuthorBuilder() - .WithIconUrl(icon) - .WithName(name) - .WithUrl(url); + .WithIconUrl(Icon) + .WithName(Name) + .WithUrl(Url); var builder = new EmbedBuilder() .WithAuthor(author); Assert.NotNull(builder.Author); - Assert.Equal(name, builder.Author.Name); - Assert.Equal(icon, builder.Author.IconUrl); - Assert.Equal(url, builder.Author.Url); + Assert.Equal(Name, builder.Author.Name); + Assert.Equal(Icon, builder.Author.IconUrl); + Assert.Equal(Url, builder.Author.Url); } /// @@ -58,13 +58,13 @@ namespace Discord { var builder = new EmbedBuilder() .WithAuthor((author) => - author.WithIconUrl(icon) - .WithName(name) - .WithUrl(url)); + author.WithIconUrl(Icon) + .WithName(Name) + .WithUrl(Url)); Assert.NotNull(builder.Author); - Assert.Equal(name, builder.Author.Name); - Assert.Equal(icon, builder.Author.IconUrl); - Assert.Equal(url, builder.Author.Url); + Assert.Equal(Name, builder.Author.Name); + Assert.Equal(Icon, builder.Author.IconUrl); + Assert.Equal(Url, builder.Author.Url); } /// @@ -74,12 +74,12 @@ namespace Discord public void EmbedAuthorBuilder() { var builder = new EmbedAuthorBuilder() - .WithIconUrl(icon) - .WithName(name) - .WithUrl(url); - Assert.Equal(icon, builder.IconUrl); - Assert.Equal(name, builder.Name); - Assert.Equal(url, builder.Url); + .WithIconUrl(Icon) + .WithName(Name) + .WithUrl(Url); + Assert.Equal(Icon, builder.IconUrl); + Assert.Equal(Name, builder.Name); + Assert.Equal(Url, builder.Url); } /// @@ -217,15 +217,15 @@ namespace Discord public void Length() { var e = new EmbedBuilder() - .WithAuthor(name, icon, url) + .WithAuthor(Name, Icon, Url) .WithColor(Color.Blue) .WithDescription("This is the test description.") - .WithFooter("This is the footer", url) - .WithImageUrl(url) - .WithThumbnailUrl(url) + .WithFooter("This is the footer", Url) + .WithImageUrl(Url) + .WithThumbnailUrl(Url) .WithTimestamp(DateTimeOffset.MinValue) .WithTitle("This is the title") - .WithUrl(url) + .WithUrl(Url) .AddField("Field 1", "Inline", true) .AddField("Field 2", "Not Inline", false); Assert.Equal(100, e.Length); @@ -263,11 +263,11 @@ namespace Discord var e = new EmbedBuilder() .WithFooter(x => { - x.IconUrl = url; - x.Text = name; + x.IconUrl = Url; + x.Text = Name; }); - Assert.Equal(url, e.Footer.IconUrl); - Assert.Equal(name, e.Footer.Text); + Assert.Equal(Url, e.Footer.IconUrl); + Assert.Equal(Name, e.Footer.Text); } /// @@ -278,13 +278,13 @@ namespace Discord { var footer = new EmbedFooterBuilder() { - IconUrl = url, - Text = name + IconUrl = Url, + Text = Name }; var e = new EmbedBuilder() .WithFooter(footer); - Assert.Equal(url, e.Footer.IconUrl); - Assert.Equal(name, e.Footer.Text); + Assert.Equal(Url, e.Footer.IconUrl); + Assert.Equal(Name, e.Footer.Text); // use the property e = new EmbedBuilder { @@ -301,9 +301,9 @@ namespace Discord public void WithFooter_Strings() { var e = new EmbedBuilder() - .WithFooter(name, url); - Assert.Equal(url, e.Footer.IconUrl); - Assert.Equal(name, e.Footer.Text); + .WithFooter(Name, Url); + Assert.Equal(Url, e.Footer.IconUrl); + Assert.Equal(Name, e.Footer.Text); } /// @@ -313,10 +313,10 @@ namespace Discord public void EmbedFooterBuilder() { var footer = new EmbedFooterBuilder() - .WithIconUrl(url) - .WithText(name); - Assert.Equal(url, footer.IconUrl); - Assert.Equal(name, footer.Text); + .WithIconUrl(Url) + .WithText(Name); + Assert.Equal(Url, footer.IconUrl); + Assert.Equal(Name, footer.Text); } /// /// Tests that invalid text throws an . 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 19/27] 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; } From a4c024aa13fd042d45520d1f54fd3563b77e04e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 14:51:33 +0200 Subject: [PATCH 20/27] Use 'switch' expression (#187) * Use 'switch' expression * Reverted it to the old switch case --- src/Discord.Net.Core/CDN.cs | 35 +++++++------------ .../Interactions/AutocompleteResult.cs | 20 ++++------- .../Permissions/ChannelPermissions.cs | 16 ++++----- .../API/Common/ActionRowComponent.cs | 13 +++---- src/Discord.Net.Rest/DiscordRestApiClient.cs | 35 +++++++------------ .../Entities/Channels/RestChannel.cs | 32 ++++++----------- .../Entities/Channels/RestGuildChannel.cs | 25 +++++-------- .../Interactions/InteractionHelper.cs | 2 +- .../Net/Converters/EmbedTypeConverter.cs | 33 +++++++---------- .../Net/Converters/UserStatusConverter.cs | 24 +++++-------- src/Discord.Net.Rest/Net/DefaultRestClient.cs | 16 ++++----- .../Entities/Channels/SocketChannel.cs | 13 +++---- .../Entities/Channels/SocketChannelHelper.cs | 12 +++---- .../Entities/Channels/SocketGuildChannel.cs | 25 +++++-------- .../Entities/Interaction/SocketInteraction.cs | 15 ++++---- .../Entities/Invites/SocketInvite.cs | 18 +++++----- 16 files changed, 128 insertions(+), 206 deletions(-) diff --git a/src/Discord.Net.Core/CDN.cs b/src/Discord.Net.Core/CDN.cs index b48bef379..78fba574f 100644 --- a/src/Discord.Net.Core/CDN.cs +++ b/src/Discord.Net.Core/CDN.cs @@ -190,37 +190,26 @@ namespace Discord private static string FormatToExtension(StickerFormatType format) { - switch (format) + return format switch { - case StickerFormatType.None: - case StickerFormatType.Png: - case StickerFormatType.Apng: // In the case of the Sticker endpoint, the sticker will be available as PNG if its format_type is PNG or APNG, and as Lottie if its format_type is LOTTIE. - return "png"; - case StickerFormatType.Lottie: - return "lottie"; - default: - throw new ArgumentException(nameof(format)); - - } + StickerFormatType.None or StickerFormatType.Png or StickerFormatType.Apng => "png", // In the case of the Sticker endpoint, the sticker will be available as PNG if its format_type is PNG or APNG, and as Lottie if its format_type is LOTTIE. + StickerFormatType.Lottie => "lottie", + _ => throw new ArgumentException(nameof(format)), + }; } private static string FormatToExtension(ImageFormat format, string imageId) { if (format == ImageFormat.Auto) format = imageId.StartsWith("a_") ? ImageFormat.Gif : ImageFormat.Png; - switch (format) + return format switch { - case ImageFormat.Gif: - return "gif"; - case ImageFormat.Jpeg: - return "jpeg"; - case ImageFormat.Png: - return "png"; - case ImageFormat.WebP: - return "webp"; - default: - throw new ArgumentException(nameof(format)); - } + ImageFormat.Gif => "gif", + ImageFormat.Jpeg => "jpeg", + ImageFormat.Png => "png", + ImageFormat.WebP => "webp", + _ => throw new ArgumentException(nameof(format)), + }; } } } diff --git a/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs index 2536c3c51..c152c1f27 100644 --- a/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs +++ b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs @@ -53,21 +53,13 @@ namespace Discord if (value == null) throw new ArgumentNullException("Value cannot be null"); - switch (value) + _value = value switch { - case string str: - _value = str; - break; - case int integer: - _value = integer; - break; - case double number: - _value = number; - break; - - default: - throw new ArgumentException($"Type {value.GetType().Name} cannot be set as a value! Only string, int, and double allowed!"); - } + string str => str, + int integer => integer, + double number => number, + _ => throw new ArgumentException($"Type {value.GetType().Name} cannot be set as a value! Only string, int, and double allowed!"), + }; } } diff --git a/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs index d774cc51d..287e69783 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs @@ -24,15 +24,15 @@ namespace Discord /// Unknown channel type. public static ChannelPermissions All(IChannel channel) { - switch (channel) + return channel switch { - case ITextChannel _: return Text; - case IVoiceChannel _: return Voice; - case ICategoryChannel _: return Category; - case IDMChannel _: return DM; - case IGroupChannel _: return Group; - default: throw new ArgumentException(message: "Unknown channel type.", paramName: nameof(channel)); - } + ITextChannel _ => Text, + IVoiceChannel _ => Voice, + ICategoryChannel _ => Category, + IDMChannel _ => DM, + IGroupChannel _ => Group, + _ => throw new ArgumentException(message: "Unknown channel type.", paramName: nameof(channel)), + }; } /// Gets a packed value representing all the permissions in this . diff --git a/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs b/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs index 417fb1b98..92778849c 100644 --- a/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs +++ b/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs @@ -22,15 +22,12 @@ namespace Discord.API Type = c.Type; Components = c.Components?.Select(x => { - switch (x.Type) + return x.Type switch { - case ComponentType.Button: - return new ButtonComponent(x as Discord.ButtonComponent); - case ComponentType.SelectMenu: - return new SelectMenuComponent(x as Discord.SelectMenuComponent); - default: return null; - - } + ComponentType.Button => new ButtonComponent(x as Discord.ButtonComponent), + ComponentType.SelectMenu => new SelectMenuComponent(x as Discord.SelectMenuComponent), + _ => null, + }; }).ToArray(); } diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index dfe003f53..461981e28 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -715,22 +715,12 @@ namespace Discord.API int limit = args.Limit.GetValueOrDefault(DiscordConfig.MaxMessagesPerBatch); ulong? relativeId = args.RelativeMessageId.IsSpecified ? args.RelativeMessageId.Value : (ulong?)null; - string relativeDir; - - switch (args.RelativeDirection.GetValueOrDefault(Direction.Before)) + var relativeDir = args.RelativeDirection.GetValueOrDefault(Direction.Before) switch { - case Direction.Before: - default: - relativeDir = "before"; - break; - case Direction.After: - relativeDir = "after"; - break; - case Direction.Around: - relativeDir = "around"; - break; - } - + Direction.After => "after", + Direction.Around => "around", + _ => "before", + }; var ids = new BucketIds(channelId: channelId); Expression> endpoint; if (relativeId != null) @@ -2181,15 +2171,14 @@ namespace Discord.API internal static int? GetIndex(string name) { - switch (name) + return name switch { - case "httpMethod": return 0; - case "guildId": return 1; - case "channelId": return 2; - case "webhookId": return 3; - default: - return null; - } + "httpMethod" => 0, + "guildId" => 1, + "channelId" => 2, + "webhookId" => 3, + _ => null, + }; } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs index b653a2db4..ea7988155 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs @@ -22,33 +22,23 @@ namespace Discord.Rest /// Unexpected channel type. internal static RestChannel Create(BaseDiscordClient discord, Model model) { - switch (model.Type) + return model.Type switch { - case ChannelType.News: - case ChannelType.Text: - case ChannelType.Voice: - return RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model); - case ChannelType.DM: - case ChannelType.Group: - return CreatePrivate(discord, model) as RestChannel; - case ChannelType.Category: - return RestCategoryChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model); - default: - return new RestChannel(discord, model.Id); - } + ChannelType.News or ChannelType.Text or ChannelType.Voice => RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model), + ChannelType.DM or ChannelType.Group => CreatePrivate(discord, model) as RestChannel, + ChannelType.Category => RestCategoryChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model), + _ => new RestChannel(discord, model.Id), + }; } /// Unexpected channel type. internal static IRestPrivateChannel CreatePrivate(BaseDiscordClient discord, Model model) { - switch (model.Type) + return model.Type switch { - case ChannelType.DM: - return RestDMChannel.Create(discord, model); - case ChannelType.Group: - return RestGroupChannel.Create(discord, model); - default: - throw new InvalidOperationException($"Unexpected channel type: {model.Type}"); - } + ChannelType.DM => RestDMChannel.Create(discord, model), + ChannelType.Group => RestGroupChannel.Create(discord, model), + _ => throw new InvalidOperationException($"Unexpected channel type: {model.Type}"), + }; } internal virtual void Update(Model model) { } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs index 549a4ba31..70267bf73 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs @@ -33,23 +33,16 @@ namespace Discord.Rest } internal static RestGuildChannel Create(BaseDiscordClient discord, IGuild guild, Model model) { - switch (model.Type) + return model.Type switch { - case ChannelType.News: - return RestNewsChannel.Create(discord, guild, model); - case ChannelType.Text: - return RestTextChannel.Create(discord, guild, model); - case ChannelType.Voice: - return RestVoiceChannel.Create(discord, guild, model); - case ChannelType.Stage: - return RestStageChannel.Create(discord, guild, model); - case ChannelType.Category: - return RestCategoryChannel.Create(discord, guild, model); - case ChannelType.PublicThread or ChannelType.PrivateThread or ChannelType.NewsThread: - return RestThreadChannel.Create(discord, guild, model); - default: - return new RestGuildChannel(discord, guild, model.Id); - } + ChannelType.News => RestNewsChannel.Create(discord, guild, model), + ChannelType.Text => RestTextChannel.Create(discord, guild, model), + ChannelType.Voice => RestVoiceChannel.Create(discord, guild, model), + ChannelType.Stage => RestStageChannel.Create(discord, guild, model), + ChannelType.Category => RestCategoryChannel.Create(discord, guild, model), + ChannelType.PublicThread or ChannelType.PrivateThread or ChannelType.NewsThread => RestThreadChannel.Create(discord, guild, model), + _ => new RestGuildChannel(discord, guild, model.Id), + }; } internal override void Update(Model model) { diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs index 52449a121..8f9163692 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs @@ -43,7 +43,7 @@ namespace Discord.Rest RestFollowupMessage entity = RestFollowupMessage.Create(client, model, token, channel); return entity; } -#endregion + #endregion #region Global commands public static async Task GetGlobalCommandAsync(BaseDiscordClient client, ulong id, diff --git a/src/Discord.Net.Rest/Net/Converters/EmbedTypeConverter.cs b/src/Discord.Net.Rest/Net/Converters/EmbedTypeConverter.cs index 1e03fb698..cacd2e2e1 100644 --- a/src/Discord.Net.Rest/Net/Converters/EmbedTypeConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/EmbedTypeConverter.cs @@ -13,28 +13,19 @@ namespace Discord.Net.Converters public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - switch ((string)reader.Value) + return (string)reader.Value switch { - case "rich": - return EmbedType.Rich; - case "link": - return EmbedType.Link; - case "video": - return EmbedType.Video; - case "image": - return EmbedType.Image; - case "gifv": - return EmbedType.Gifv; - case "article": - return EmbedType.Article; - case "tweet": - return EmbedType.Tweet; - case "html": - return EmbedType.Html; - case "application_news": // TODO 2.2 EmbedType.News - default: - return EmbedType.Unknown; - } + "rich" => EmbedType.Rich, + "link" => EmbedType.Link, + "video" => EmbedType.Video, + "image" => EmbedType.Image, + "gifv" => EmbedType.Gifv, + "article" => EmbedType.Article, + "tweet" => EmbedType.Tweet, + "html" => EmbedType.Html, + // TODO 2.2 EmbedType.News + _ => EmbedType.Unknown, + }; } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) diff --git a/src/Discord.Net.Rest/Net/Converters/UserStatusConverter.cs b/src/Discord.Net.Rest/Net/Converters/UserStatusConverter.cs index c0a287c16..8a13e79a5 100644 --- a/src/Discord.Net.Rest/Net/Converters/UserStatusConverter.cs +++ b/src/Discord.Net.Rest/Net/Converters/UserStatusConverter.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; namespace Discord.Net.Converters @@ -13,21 +13,15 @@ namespace Discord.Net.Converters public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - switch ((string)reader.Value) + return (string)reader.Value switch { - case "online": - return UserStatus.Online; - case "idle": - return UserStatus.Idle; - case "dnd": - return UserStatus.DoNotDisturb; - case "invisible": - return UserStatus.Invisible; //Should never happen - case "offline": - return UserStatus.Offline; - default: - throw new JsonSerializationException("Unknown user status"); - } + "online" => UserStatus.Online, + "idle" => UserStatus.Idle, + "dnd" => UserStatus.DoNotDisturb, + "invisible" => UserStatus.Invisible,//Should never happen + "offline" => UserStatus.Offline, + _ => throw new JsonSerializationException("Unknown user status"), + }; } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) diff --git a/src/Discord.Net.Rest/Net/DefaultRestClient.cs b/src/Discord.Net.Rest/Net/DefaultRestClient.cs index 62ebd6d78..1db743609 100644 --- a/src/Discord.Net.Rest/Net/DefaultRestClient.cs +++ b/src/Discord.Net.Rest/Net/DefaultRestClient.cs @@ -157,15 +157,15 @@ namespace Discord.Net.Rest private static readonly HttpMethod Patch = new HttpMethod("PATCH"); private HttpMethod GetMethod(string method) { - switch (method) + return method switch { - case "DELETE": return HttpMethod.Delete; - case "GET": return HttpMethod.Get; - case "PATCH": return Patch; - case "POST": return HttpMethod.Post; - case "PUT": return HttpMethod.Put; - default: throw new ArgumentOutOfRangeException(nameof(method), $"Unknown HttpMethod: {method}"); - } + "DELETE" => HttpMethod.Delete, + "GET" => HttpMethod.Get, + "PATCH" => Patch, + "POST" => HttpMethod.Post, + "PUT" => HttpMethod.Put, + _ => throw new ArgumentOutOfRangeException(nameof(method), $"Unknown HttpMethod: {method}"), + }; } } } diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketChannel.cs index 80c43a0c3..758ee9271 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketChannel.cs @@ -31,15 +31,12 @@ namespace Discord.WebSocket /// Unexpected channel type is created. internal static ISocketPrivateChannel CreatePrivate(DiscordSocketClient discord, ClientState state, Model model) { - switch (model.Type) + return model.Type switch { - case ChannelType.DM: - return SocketDMChannel.Create(discord, state, model); - case ChannelType.Group: - return SocketGroupChannel.Create(discord, state, model); - default: - throw new InvalidOperationException($"Unexpected channel type: {model.Type}"); - } + ChannelType.DM => SocketDMChannel.Create(discord, state, model), + ChannelType.Group => SocketGroupChannel.Create(discord, state, model), + _ => throw new InvalidOperationException($"Unexpected channel type: {model.Type}"), + }; } internal abstract void Update(ClientState state, Model model); #endregion diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketChannelHelper.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketChannelHelper.cs index 4a1dc45c7..ccbf9b2b6 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketChannelHelper.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketChannelHelper.cs @@ -79,13 +79,13 @@ namespace Discord.WebSocket public static SocketMessage RemoveMessage(ISocketMessageChannel channel, DiscordSocketClient discord, ulong id) { - switch (channel) + return channel switch { - case SocketDMChannel dmChannel: return dmChannel.RemoveMessage(id); - case SocketGroupChannel groupChannel: return groupChannel.RemoveMessage(id); - case SocketTextChannel textChannel: return textChannel.RemoveMessage(id); - default: throw new NotSupportedException($"Unexpected {nameof(ISocketMessageChannel)} type."); - } + SocketDMChannel dmChannel => dmChannel.RemoveMessage(id), + SocketGroupChannel groupChannel => groupChannel.RemoveMessage(id), + SocketTextChannel textChannel => textChannel.RemoveMessage(id), + _ => throw new NotSupportedException($"Unexpected {nameof(ISocketMessageChannel)} type."), + }; } } } diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs index a504a2a94..d38a8975b 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGuildChannel.cs @@ -47,23 +47,16 @@ namespace Discord.WebSocket } internal static SocketGuildChannel Create(SocketGuild guild, ClientState state, Model model) { - switch (model.Type) + return model.Type switch { - case ChannelType.News: - return SocketNewsChannel.Create(guild, state, model); - case ChannelType.Text: - return SocketTextChannel.Create(guild, state, model); - case ChannelType.Voice: - return SocketVoiceChannel.Create(guild, state, model); - case ChannelType.Category: - return SocketCategoryChannel.Create(guild, state, model); - case ChannelType.PrivateThread or ChannelType.PublicThread or ChannelType.NewsThread: - return SocketThreadChannel.Create(guild, state, model); - case ChannelType.Stage: - return SocketStageChannel.Create(guild, state, model); - default: - return new SocketGuildChannel(guild.Discord, model.Id, guild); - } + ChannelType.News => SocketNewsChannel.Create(guild, state, model), + ChannelType.Text => SocketTextChannel.Create(guild, state, model), + ChannelType.Voice => SocketVoiceChannel.Create(guild, state, model), + ChannelType.Category => SocketCategoryChannel.Create(guild, state, model), + ChannelType.PrivateThread or ChannelType.PublicThread or ChannelType.NewsThread => SocketThreadChannel.Create(guild, state, model), + ChannelType.Stage => SocketStageChannel.Create(guild, state, model), + _ => new SocketGuildChannel(guild.Discord, model.Id, guild), + }; } /// internal override void Update(ClientState state, Model model) diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs index 6a721907a..c8e07bf97 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs @@ -72,16 +72,13 @@ namespace Discord.WebSocket if (dataModel == null) return null; - switch (dataModel.Type) + return dataModel.Type switch { - case ApplicationCommandType.Slash: - return SocketSlashCommand.Create(client, model, channel); - case ApplicationCommandType.Message: - return SocketMessageCommand.Create(client, model, channel); - case ApplicationCommandType.User: - return SocketUserCommand.Create(client, model, channel); - default: return null; - } + ApplicationCommandType.Slash => SocketSlashCommand.Create(client, model, channel), + ApplicationCommandType.Message => SocketMessageCommand.Create(client, model, channel), + ApplicationCommandType.User => SocketUserCommand.Create(client, model, channel), + _ => null, + }; } else if (model.Type == InteractionType.MessageComponent) return SocketMessageComponent.Create(client, model, channel); diff --git a/src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs b/src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs index acc9c4978..abc418d86 100644 --- a/src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs +++ b/src/Discord.Net.WebSocket/Entities/Invites/SocketInvite.cs @@ -31,16 +31,16 @@ namespace Discord.WebSocket { get { - switch (Channel) + return Channel switch { - case IVoiceChannel voiceChannel: return ChannelType.Voice; - case ICategoryChannel categoryChannel: return ChannelType.Category; - case IDMChannel dmChannel: return ChannelType.DM; - case IGroupChannel groupChannel: return ChannelType.Group; - case INewsChannel newsChannel: return ChannelType.News; - case ITextChannel textChannel: return ChannelType.Text; - default: throw new InvalidOperationException("Invalid channel type."); - } + IVoiceChannel voiceChannel => ChannelType.Voice, + ICategoryChannel categoryChannel => ChannelType.Category, + IDMChannel dmChannel => ChannelType.DM, + IGroupChannel groupChannel => ChannelType.Group, + INewsChannel newsChannel => ChannelType.News, + ITextChannel textChannel => ChannelType.Text, + _ => throw new InvalidOperationException("Invalid channel type."), + }; } } /// From 788d654215131495579da22919ea883ee1c1e12f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Fri, 24 Sep 2021 15:04:26 +0200 Subject: [PATCH 21/27] Fixed-compiler-error (#194) --- test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs b/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs index 319d3fb11..4d0cc8a55 100644 --- a/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs +++ b/test/Discord.Net.Tests.Unit/EmbedBuilderTests.cs @@ -290,8 +290,8 @@ namespace Discord { Footer = footer }; - Assert.Equal(url, e.Footer.IconUrl); - Assert.Equal(name, e.Footer.Text); + Assert.Equal(Url, e.Footer.IconUrl); + Assert.Equal(Name, e.Footer.Text); } /// From 6457add1b176651ed2c00f81700404003f0b14dc Mon Sep 17 00:00:00 2001 From: drobbins329 Date: Sat, 25 Sep 2021 12:26:46 -0400 Subject: [PATCH 22/27] Submitting updates to include new permissions. (#195) * Submitting updates to include new permissions. * Make old permissions obsolete and update tests Co-authored-by: quin lynch --- src/Discord.Net.Core/Discord.Net.Core.xml | 178 +++++++++++++----- .../Entities/Permissions/ChannelPermission.cs | 32 +++- .../Permissions/ChannelPermissions.cs | 143 ++++++++++---- .../Entities/Permissions/GuildPermission.cs | 9 +- .../Entities/Permissions/GuildPermissions.cs | 32 +--- .../Permissions/OverwritePermissions.cs | 72 ++++++- src/Discord.Net.Rest/Discord.Net.Rest.xml | 1 - .../Discord.Net.WebSocket.xml | 4 - .../ChannelPermissionsTests.cs | 4 + test/Discord.Net.Tests.Unit/ColorTests.cs | 2 +- .../GuildPermissionsTests.cs | 4 +- 11 files changed, 351 insertions(+), 130 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index d72a1cac2..b759c8e13 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -8267,7 +8267,7 @@ - Gets a value that indicates whether the current user has reacted to + Gets a value that indicates whether the current user has reacted to this. true if the user has reacted to the message; otherwise false. @@ -8604,7 +8604,12 @@ Allows members to use slash commands in text channels. - + + + Allows members to use slash commands in text channels. + + + Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.) @@ -8624,106 +8629,158 @@ Allows for creating and participating in private threads + + + Allows for creating public threads. + + + + + Allows for creating private threads. + + + + + Allows the usage of custom stickers from other servers. + + + + + Allows for sending messages in threads. + + + + + Allows for launching activities (applications with the EMBEDDED flag) in a voice channel. + + - Gets a blank that grants no permissions. - A structure that does not contain any set permissions. + Gets a blank that grants no permissions. + A structure that does not contain any set permissions. - Gets a that grants all permissions for text channels. + Gets a that grants all permissions for text channels. - Gets a that grants all permissions for voice channels. + Gets a that grants all permissions for voice channels. + + + Gets a that grants all permissions for stage channels. - Gets a that grants all permissions for category channels. + Gets a that grants all permissions for category channels. - Gets a that grants all permissions for direct message channels. + Gets a that grants all permissions for direct message channels. - Gets a that grants all permissions for group channels. + Gets a that grants all permissions for group channels. - Gets a that grants all permissions for a given channel type. + Gets a that grants all permissions for a given channel type. Unknown channel type. - Gets a packed value representing all the permissions in this . + Gets a packed value representing all the permissions in this . - If true, a user may create invites. + If true, a user may create invites. - If true, a user may create, delete and modify this channel. + If true, a user may create, delete and modify this channel. - If true, a user may add reactions. + If true, a user may add reactions. - If true, a user may view channels. + If true, a user may view channels. - If true, a user may send messages. + If true, a user may send messages. - If true, a user may send text-to-speech messages. + If true, a user may send text-to-speech messages. - If true, a user may delete messages. + If true, a user may delete messages. - If true, Discord will auto-embed links sent by this user. + If true, Discord will auto-embed links sent by this user. - If true, a user may send files. + If true, a user may send files. - If true, a user may read previous messages. + If true, a user may read previous messages. - If true, a user may mention @everyone. + If true, a user may mention @everyone. - If true, a user may use custom emoji from other guilds. + If true, a user may use custom emoji from other guilds. - If true, a user may connect to a voice channel. + If true, a user may connect to a voice channel. - If true, a user may speak in a voice channel. + If true, a user may speak in a voice channel. - If true, a user may mute users. + If true, a user may mute users. - If true, a user may deafen users. + If true, a user may deafen users. - If true, a user may move other users between voice channels. + If true, a user may move other users between voice channels. - If true, a user may use voice-activity-detection rather than push-to-talk. + If true, a user may use voice-activity-detection rather than push-to-talk. - If true, a user may use priority speaker in a voice channel. + If true, a user may use priority speaker in a voice channel. - If true, a user may stream video in a voice channel. + If true, a user may stream video in a voice channel. - If true, a user may adjust role permissions. This also implictly grants all other permissions. + If true, a user may adjust role permissions. This also implictly grants all other permissions. - If true, a user may edit the webhooks for this channel. + If true, a user may edit the webhooks for this channel. + + + If true, a user may use application commands in this guild. + + + If true, a user may request to speak in stage channels. + + + If true, a user may manage threads in this guild. + + + If true, a user may create public threads in this guild. + + + If true, a user may create private threads in this guild. + + + If true, a user may use external stickers in this guild. + + + If true, a user may send messages in threads in this guild. + + + If true, a user launch application activites in voice channels in this guild. - Creates a new with the provided packed value. + Creates a new with the provided packed value. - - Creates a new with the provided permissions. + + Creates a new with the provided permissions. - - Creates a new from this one, changing the provided non-null permissions. + + Creates a new from this one, changing the provided non-null permissions. @@ -8950,6 +9007,11 @@ Allows members to use slash commands in text channels. + + + Allows members to use application commands like slash commands and context menus in text channels. + + Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.). @@ -9104,7 +9166,7 @@ If true, a user may edit the emojis and stickers for this guild. - + If true, a user may use slash commands in this guild. @@ -9119,12 +9181,6 @@ If true, a user may create private threads in this guild. - - If true, a user may use public threads in this guild. - - - If true, a user may use private threads in this guild. - If true, a user may use external stickers in this guild. @@ -9140,10 +9196,10 @@ Creates a new with the provided packed value after converting to ulong. - + Creates a new structure with the provided permissions. - + Creates a new from this one, changing the provided non-null permissions. @@ -9284,18 +9340,42 @@ If True, a user may edit the webhooks for this channel. + + If true, a user may use slash commands in this guild. + + + If true, a user may request to speak in stage channels. + + + If true, a user may manage threads in this guild. + + + If true, a user may create public threads in this guild. + + + If true, a user may create private threads in this guild. + + + If true, a user may use external stickers in this guild. + + + If true, a user may send messages in threads in this guild. + + + If true, a user launch application activites in voice channels in this guild. + Creates a new OverwritePermissions with the provided allow and deny packed values. Creates a new OverwritePermissions with the provided allow and deny packed values after converting to ulong. - + Initializes a new struct with the provided permissions. - + Initializes a new from the current one, changing the provided non-null permissions. diff --git a/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs b/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs index 99e74bd48..d76a579d9 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ChannelPermission.cs @@ -113,12 +113,18 @@ namespace Discord /// /// Allows members to use slash commands in text channels. /// + [Obsolete("UseSlashCommands has been replaced by UseApplicationCommands", true)] UseSlashCommands = 0x00_80_00_00_00, + /// + /// Allows members to use slash commands in text channels. + /// + UseApplicationCommands = 0x00_80_00_00_00, + /// /// Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.) /// - RequesToSpeak = 0x01_00_00_00_00, + RequestToSpeak = 0x01_00_00_00_00, /// /// Allows for deleting and archiving threads, and viewing all private threads @@ -128,12 +134,34 @@ namespace Discord /// /// Allows for creating and participating in threads /// - UsePublicThreads = 0x08_00_00_00_00, + [Obsolete("UsePublicThreads has been replaced by CreatePublicThreads and SendMessagesInThreads", true)] + UsePublicThreads = 0x08_00_00_00_00, /// /// Allows for creating and participating in private threads /// + [Obsolete("UsePrivateThreads has been replaced by CreatePrivateThreads and SendMessagesInThreads", true)] UsePrivateThreads = 0x10_00_00_00_00, + /// + /// Allows for creating public threads. + /// + CreatePublicThreads = 0x08_00_00_00_00, + /// + /// Allows for creating private threads. + /// + CreatePrivateThreads = 0x10_00_00_00_00, + /// + /// Allows the usage of custom stickers from other servers. + /// + UseExternalStickers = 0x20_00_00_00_00, + /// + /// Allows for sending messages in threads. + /// + SendMessagesInThreads = 0x40_00_00_00_00, + /// + /// Allows for launching activities (applications with the EMBEDDED flag) in a voice channel. + /// + StartEmbeddedActivities = 0x80_00_00_00_00 } } diff --git a/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs index 287e69783..11130731e 100644 --- a/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/ChannelPermissions.cs @@ -7,26 +7,29 @@ namespace Discord [DebuggerDisplay("{DebuggerDisplay,nq}")] public struct ChannelPermissions { - /// Gets a blank that grants no permissions. - /// A structure that does not contain any set permissions. + /// Gets a blank that grants no permissions. + /// A structure that does not contain any set permissions. public static readonly ChannelPermissions None = new ChannelPermissions(); - /// Gets a that grants all permissions for text channels. - public static readonly ChannelPermissions Text = new ChannelPermissions(0b01100_0000000_1111111110001_010001); - /// Gets a that grants all permissions for voice channels. - public static readonly ChannelPermissions Voice = new ChannelPermissions(0b00100_1111110_0000000011100_010001); - /// Gets a that grants all permissions for category channels. + /// Gets a that grants all permissions for text channels. + public static readonly ChannelPermissions Text = new ChannelPermissions(0b0_11111_0101100_0000000_1111111110001_010001); + /// Gets a that grants all permissions for voice channels. + public static readonly ChannelPermissions Voice = new ChannelPermissions(0b1_00000_0000100_1111110_0000000011100_010001); + /// Gets a that grants all permissions for stage channels. + public static readonly ChannelPermissions Stage = new ChannelPermissions(0b0_00000_1000100_0111010_0000000010000_010001); + /// Gets a that grants all permissions for category channels. public static readonly ChannelPermissions Category = new ChannelPermissions(0b01100_1111110_1111111110001_010001); - /// Gets a that grants all permissions for direct message channels. + /// Gets a that grants all permissions for direct message channels. public static readonly ChannelPermissions DM = new ChannelPermissions(0b00000_1000110_1011100110001_000000); - /// Gets a that grants all permissions for group channels. + /// Gets a that grants all permissions for group channels. public static readonly ChannelPermissions Group = new ChannelPermissions(0b00000_1000110_0001101100000_000000); - /// Gets a that grants all permissions for a given channel type. + /// Gets a that grants all permissions for a given channel type. /// Unknown channel type. public static ChannelPermissions All(IChannel channel) { return channel switch { ITextChannel _ => Text, + IStageChannel _ => Stage, IVoiceChannel _ => Voice, ICategoryChannel _ => Category, IDMChannel _ => DM, @@ -35,59 +38,75 @@ namespace Discord }; } - /// Gets a packed value representing all the permissions in this . + /// Gets a packed value representing all the permissions in this . public ulong RawValue { get; } - /// If true, a user may create invites. + /// If true, a user may create invites. public bool CreateInstantInvite => Permissions.GetValue(RawValue, ChannelPermission.CreateInstantInvite); - /// If true, a user may create, delete and modify this channel. + /// If true, a user may create, delete and modify this channel. public bool ManageChannel => Permissions.GetValue(RawValue, ChannelPermission.ManageChannels); - /// If true, a user may add reactions. + /// If true, a user may add reactions. public bool AddReactions => Permissions.GetValue(RawValue, ChannelPermission.AddReactions); - /// If true, a user may view channels. + /// If true, a user may view channels. public bool ViewChannel => Permissions.GetValue(RawValue, ChannelPermission.ViewChannel); - /// If true, a user may send messages. + /// If true, a user may send messages. public bool SendMessages => Permissions.GetValue(RawValue, ChannelPermission.SendMessages); - /// If true, a user may send text-to-speech messages. + /// If true, a user may send text-to-speech messages. public bool SendTTSMessages => Permissions.GetValue(RawValue, ChannelPermission.SendTTSMessages); - /// If true, a user may delete messages. + /// If true, a user may delete messages. public bool ManageMessages => Permissions.GetValue(RawValue, ChannelPermission.ManageMessages); - /// If true, Discord will auto-embed links sent by this user. + /// If true, Discord will auto-embed links sent by this user. public bool EmbedLinks => Permissions.GetValue(RawValue, ChannelPermission.EmbedLinks); - /// If true, a user may send files. + /// If true, a user may send files. public bool AttachFiles => Permissions.GetValue(RawValue, ChannelPermission.AttachFiles); - /// If true, a user may read previous messages. + /// If true, a user may read previous messages. public bool ReadMessageHistory => Permissions.GetValue(RawValue, ChannelPermission.ReadMessageHistory); - /// If true, a user may mention @everyone. + /// If true, a user may mention @everyone. public bool MentionEveryone => Permissions.GetValue(RawValue, ChannelPermission.MentionEveryone); - /// If true, a user may use custom emoji from other guilds. + /// If true, a user may use custom emoji from other guilds. public bool UseExternalEmojis => Permissions.GetValue(RawValue, ChannelPermission.UseExternalEmojis); - /// If true, a user may connect to a voice channel. + /// If true, a user may connect to a voice channel. public bool Connect => Permissions.GetValue(RawValue, ChannelPermission.Connect); - /// If true, a user may speak in a voice channel. + /// If true, a user may speak in a voice channel. public bool Speak => Permissions.GetValue(RawValue, ChannelPermission.Speak); - /// If true, a user may mute users. + /// If true, a user may mute users. public bool MuteMembers => Permissions.GetValue(RawValue, ChannelPermission.MuteMembers); - /// If true, a user may deafen users. + /// If true, a user may deafen users. public bool DeafenMembers => Permissions.GetValue(RawValue, ChannelPermission.DeafenMembers); - /// If true, a user may move other users between voice channels. + /// If true, a user may move other users between voice channels. public bool MoveMembers => Permissions.GetValue(RawValue, ChannelPermission.MoveMembers); - /// If true, a user may use voice-activity-detection rather than push-to-talk. + /// If true, a user may use voice-activity-detection rather than push-to-talk. public bool UseVAD => Permissions.GetValue(RawValue, ChannelPermission.UseVAD); - /// If true, a user may use priority speaker in a voice channel. + /// If true, a user may use priority speaker in a voice channel. public bool PrioritySpeaker => Permissions.GetValue(RawValue, ChannelPermission.PrioritySpeaker); - /// If true, a user may stream video in a voice channel. + /// If true, a user may stream video in a voice channel. public bool Stream => Permissions.GetValue(RawValue, ChannelPermission.Stream); - /// If true, a user may adjust role permissions. This also implictly grants all other permissions. + /// If true, a user may adjust role permissions. This also implictly grants all other permissions. public bool ManageRoles => Permissions.GetValue(RawValue, ChannelPermission.ManageRoles); - /// If true, a user may edit the webhooks for this channel. + /// If true, a user may edit the webhooks for this channel. public bool ManageWebhooks => Permissions.GetValue(RawValue, ChannelPermission.ManageWebhooks); + /// If true, a user may use application commands in this guild. + public bool UseApplicationCommands => Permissions.GetValue(RawValue, ChannelPermission.UseApplicationCommands); + /// If true, a user may request to speak in stage channels. + public bool RequestToSpeak => Permissions.GetValue(RawValue, ChannelPermission.RequestToSpeak); + /// If true, a user may manage threads in this guild. + public bool ManageThreads => Permissions.GetValue(RawValue, ChannelPermission.ManageThreads); + /// If true, a user may create public threads in this guild. + public bool CreatePublicThreads => Permissions.GetValue(RawValue, ChannelPermission.CreatePublicThreads); + /// If true, a user may create private threads in this guild. + public bool CreatePrivateThreads => Permissions.GetValue(RawValue, ChannelPermission.CreatePrivateThreads); + /// If true, a user may use external stickers in this guild. + public bool UseExternalStickers => Permissions.GetValue(RawValue, ChannelPermission.UseExternalStickers); + /// If true, a user may send messages in threads in this guild. + public bool SendMessagesInThreads => Permissions.GetValue(RawValue, ChannelPermission.SendMessagesInThreads); + /// If true, a user launch application activites in voice channels in this guild. + public bool StartEmbeddedActivities => Permissions.GetValue(RawValue, ChannelPermission.StartEmbeddedActivities); - /// Creates a new with the provided packed value. + /// Creates a new with the provided packed value. public ChannelPermissions(ulong rawValue) { RawValue = rawValue; } private ChannelPermissions(ulong initialValue, @@ -112,7 +131,15 @@ namespace Discord bool? prioritySpeaker = null, bool? stream = null, bool? manageRoles = null, - bool? manageWebhooks = null) + bool? manageWebhooks = null, + bool? useApplicationCommands = null, + bool? requestToSpeak = null, + bool? manageThreads = null, + bool? createPublicThreads = null, + bool? createPrivateThreads = null, + bool? useExternalStickers = null, + bool? sendMessagesInThreads = null, + bool? startEmbeddedActivities = null) { ulong value = initialValue; @@ -138,11 +165,19 @@ namespace Discord Permissions.SetValue(ref value, stream, ChannelPermission.Stream); Permissions.SetValue(ref value, manageRoles, ChannelPermission.ManageRoles); Permissions.SetValue(ref value, manageWebhooks, ChannelPermission.ManageWebhooks); + Permissions.SetValue(ref value, useApplicationCommands, ChannelPermission.UseApplicationCommands); + Permissions.SetValue(ref value, requestToSpeak, ChannelPermission.RequestToSpeak); + Permissions.SetValue(ref value, manageThreads, ChannelPermission.ManageThreads); + Permissions.SetValue(ref value, createPublicThreads, ChannelPermission.CreatePublicThreads); + Permissions.SetValue(ref value, createPrivateThreads, ChannelPermission.CreatePrivateThreads); + Permissions.SetValue(ref value, useExternalStickers, ChannelPermission.UseExternalStickers); + Permissions.SetValue(ref value, sendMessagesInThreads, ChannelPermission.SendMessagesInThreads); + Permissions.SetValue(ref value, startEmbeddedActivities, ChannelPermission.StartEmbeddedActivities); RawValue = value; } - /// Creates a new with the provided permissions. + /// Creates a new with the provided permissions. public ChannelPermissions( bool createInstantInvite = false, bool manageChannel = false, @@ -165,13 +200,23 @@ namespace Discord bool prioritySpeaker = false, bool stream = false, bool manageRoles = false, - bool manageWebhooks = false) + bool manageWebhooks = false, + bool useApplicationCommands = false, + bool requestToSpeak = false, + bool manageThreads = false, + bool createPublicThreads = false, + bool createPrivateThreads = false, + bool useExternalStickers = false, + bool sendMessagesInThreads = false, + bool startEmbeddedActivities = false) : this(0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, - speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, manageRoles, manageWebhooks) + speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, manageRoles, manageWebhooks, + useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, + startEmbeddedActivities) { } - /// Creates a new from this one, changing the provided non-null permissions. + /// Creates a new from this one, changing the provided non-null permissions. public ChannelPermissions Modify( bool? createInstantInvite = null, bool? manageChannel = null, @@ -194,7 +239,15 @@ namespace Discord bool? prioritySpeaker = null, bool? stream = null, bool? manageRoles = null, - bool? manageWebhooks = null) + bool? manageWebhooks = null, + bool? useApplicationCommands = null, + bool? requestToSpeak = null, + bool? manageThreads = null, + bool? createPublicThreads = null, + bool? createPrivateThreads = null, + bool? useExternalStickers = null, + bool? sendMessagesInThreads = null, + bool? startEmbeddedActivities = null) => new ChannelPermissions(RawValue, createInstantInvite, manageChannel, @@ -217,7 +270,15 @@ namespace Discord prioritySpeaker, stream, manageRoles, - manageWebhooks); + manageWebhooks, + useApplicationCommands, + requestToSpeak, + manageThreads, + createPublicThreads, + createPrivateThreads, + useExternalStickers, + sendMessagesInThreads, + startEmbeddedActivities); public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission); diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs index 53b666b1a..746981c6e 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermission.cs @@ -178,8 +178,13 @@ namespace Discord /// /// Allows members to use slash commands in text channels. /// + [Obsolete("UseSlashCommands has been replaced by UseApplicationCommands", true)] UseSlashCommands = 0x80_00_00_00, /// + /// Allows members to use application commands like slash commands and context menus in text channels. + /// + UseApplicationCommands = 0x80_00_00_00, + /// /// Allows for requesting to speak in stage channels. (This permission is under active development and may be changed or removed.). /// RequestToSpeak = 0x01_00_00_00_00, @@ -202,12 +207,12 @@ namespace Discord /// /// Allows for creating public threads. /// - [Obsolete("UsePublicThreads has been replaced by CreatePublicThreads and SendMessagesInThreads")] + [Obsolete("UsePublicThreads has been replaced by CreatePublicThreads and SendMessagesInThreads", true)] UsePublicThreads = 0x08_00_00_00_00, /// /// Allows for creating private threads. /// - [Obsolete("UsePrivateThreads has been replaced by CreatePrivateThreads and SendMessagesInThreads")] + [Obsolete("UsePrivateThreads has been replaced by CreatePrivateThreads and SendMessagesInThreads", true)] UsePrivateThreads = 0x10_00_00_00_00, /// /// Allows the usage of custom stickers from other servers. diff --git a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs index f909b6381..8924936a0 100644 --- a/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/GuildPermissions.cs @@ -10,9 +10,9 @@ namespace Discord /// Gets a blank that grants no permissions. public static readonly GuildPermissions None = new GuildPermissions(); /// Gets a that grants all guild permissions for webhook users. - public static readonly GuildPermissions Webhook = new GuildPermissions(0b00000_0000000_0001101100000_000000); + public static readonly GuildPermissions Webhook = new GuildPermissions(0b0_00000_0000000_0000000_0001101100000_000000); /// Gets a that grants all guild permissions. - public static readonly GuildPermissions All = new GuildPermissions(0b1111111111_11111_1111111_1111111111111_11111); + public static readonly GuildPermissions All = new GuildPermissions(0b1_11111_1111111_1111111_1111111111111_111111); /// Gets a packed value representing all the permissions in this . public ulong RawValue { get; } @@ -84,7 +84,7 @@ namespace Discord /// If true, a user may edit the emojis and stickers for this guild. public bool ManageEmojisAndStickers => Permissions.GetValue(RawValue, GuildPermission.ManageEmojisAndStickers); /// If true, a user may use slash commands in this guild. - public bool UseSlashCommands => Permissions.GetValue(RawValue, GuildPermission.UseSlashCommands); + public bool UseApplicationCommands => Permissions.GetValue(RawValue, GuildPermission.UseApplicationCommands); /// If true, a user may request to speak in stage channels. public bool RequestToSpeak => Permissions.GetValue(RawValue, GuildPermission.RequestToSpeak); /// If true, a user may manage threads in this guild. @@ -93,10 +93,6 @@ namespace Discord public bool CreatePublicThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePublicThreads); /// If true, a user may create private threads in this guild. public bool CreatePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.CreatePrivateThreads); - /// If true, a user may use public threads in this guild. - public bool UsePublicThreads => Permissions.GetValue(RawValue, GuildPermission.UsePublicThreads); - /// If true, a user may use private threads in this guild. - public bool UsePrivateThreads => Permissions.GetValue(RawValue, GuildPermission.UsePrivateThreads); /// If true, a user may use external stickers in this guild. public bool UseExternalStickers => Permissions.GetValue(RawValue, GuildPermission.UseExternalStickers); /// If true, a user may send messages in threads in this guild. @@ -142,13 +138,11 @@ namespace Discord bool? manageRoles = null, bool? manageWebhooks = null, bool? manageEmojisAndStickers = null, - bool? useSlashCommands = null, + bool? useApplicationCommands = null, bool? requestToSpeak = null, bool? manageThreads = null, bool? createPublicThreads = null, bool? createPrivateThreads = null, - bool? usePublicThreads = null, - bool? usePrivateThreads = null, bool? useExternalStickers = null, bool? sendMessagesInThreads = null, bool? startEmbeddedActivities = null) @@ -186,13 +180,11 @@ namespace Discord Permissions.SetValue(ref value, manageRoles, GuildPermission.ManageRoles); Permissions.SetValue(ref value, manageWebhooks, GuildPermission.ManageWebhooks); Permissions.SetValue(ref value, manageEmojisAndStickers, GuildPermission.ManageEmojisAndStickers); - Permissions.SetValue(ref value, useSlashCommands, GuildPermission.UseSlashCommands); + Permissions.SetValue(ref value, useApplicationCommands, GuildPermission.UseApplicationCommands); Permissions.SetValue(ref value, requestToSpeak, GuildPermission.RequestToSpeak); Permissions.SetValue(ref value, manageThreads, GuildPermission.ManageThreads); Permissions.SetValue(ref value, createPublicThreads, GuildPermission.CreatePublicThreads); Permissions.SetValue(ref value, createPrivateThreads, GuildPermission.CreatePrivateThreads); - Permissions.SetValue(ref value, usePublicThreads, GuildPermission.UsePublicThreads); - Permissions.SetValue(ref value, usePrivateThreads, GuildPermission.UsePrivateThreads); Permissions.SetValue(ref value, useExternalStickers, GuildPermission.UseExternalStickers); Permissions.SetValue(ref value, sendMessagesInThreads, GuildPermission.SendMessagesInThreads); Permissions.SetValue(ref value, startEmbeddedActivities, GuildPermission.StartEmbeddedActivities); @@ -233,13 +225,11 @@ namespace Discord bool manageRoles = false, bool manageWebhooks = false, bool manageEmojisAndStickers = false, - bool useSlashCommands = false, + bool useApplicationCommands = false, bool requestToSpeak = false, bool manageThreads = false, bool createPublicThreads = false, bool createPrivateThreads = false, - bool usePublicThreads = false, - bool usePrivateThreads = false, bool useExternalStickers = false, bool sendMessagesInThreads = false, bool startEmbeddedActivities = false) @@ -275,13 +265,11 @@ namespace Discord manageNicknames: manageNicknames, manageWebhooks: manageWebhooks, manageEmojisAndStickers: manageEmojisAndStickers, - useSlashCommands: useSlashCommands, + useApplicationCommands: useApplicationCommands, requestToSpeak: requestToSpeak, manageThreads: manageThreads, createPublicThreads: createPublicThreads, createPrivateThreads: createPrivateThreads, - usePublicThreads: usePublicThreads, - usePrivateThreads: usePrivateThreads, useExternalStickers: useExternalStickers, sendMessagesInThreads: sendMessagesInThreads, startEmbeddedActivities: startEmbeddedActivities) @@ -320,13 +308,11 @@ namespace Discord bool? manageRoles = null, bool? manageWebhooks = null, bool? manageEmojisAndStickers = null, - bool? useSlashCommands = null, + bool? useApplicationCommands = null, bool? requestToSpeak = null, bool? manageThreads = null, bool? createPublicThreads = null, bool? createPrivateThreads = null, - bool? usePublicThreads = null, - bool? usePrivateThreads = null, bool? useExternalStickers = null, bool? sendMessagesInThreads = null, bool? startEmbeddedActivities = null) @@ -334,7 +320,7 @@ namespace Discord viewAuditLog, viewGuildInsights, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, prioritySpeaker, stream, changeNickname, manageNicknames, manageRoles, manageWebhooks, manageEmojisAndStickers, - useSlashCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, usePublicThreads, usePrivateThreads, useExternalStickers, sendMessagesInThreads, + useApplicationCommands, requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, useExternalStickers, sendMessagesInThreads, startEmbeddedActivities); /// diff --git a/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs b/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs index 4f144c74b..cff938465 100644 --- a/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs +++ b/src/Discord.Net.Core/Entities/Permissions/OverwritePermissions.cs @@ -1,3 +1,4 @@ +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Diagnostics; @@ -82,6 +83,22 @@ namespace Discord public PermValue ManageRoles => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.ManageRoles); /// If True, a user may edit the webhooks for this channel. public PermValue ManageWebhooks => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.ManageWebhooks); + /// If true, a user may use slash commands in this guild. + public PermValue UseApplicationCommands => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.UseApplicationCommands); + /// If true, a user may request to speak in stage channels. + public PermValue RequestToSpeak => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.RequestToSpeak); + /// If true, a user may manage threads in this guild. + public PermValue ManageThreads => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.ManageThreads); + /// If true, a user may create public threads in this guild. + public PermValue CreatePublicThreads => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.CreatePublicThreads); + /// If true, a user may create private threads in this guild. + public PermValue CreatePrivateThreads => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.CreatePrivateThreads); + /// If true, a user may use external stickers in this guild. + public PermValue UseExternalStickers => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.UseExternalStickers); + /// If true, a user may send messages in threads in this guild. + public PermValue SendMessagesInThreads => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.SendMessagesInThreads); + /// If true, a user launch application activites in voice channels in this guild. + public PermValue StartEmbeddedActivities => Permissions.GetValue(AllowValue, DenyValue, ChannelPermission.StartEmbeddedActivities); /// Creates a new OverwritePermissions with the provided allow and deny packed values. public OverwritePermissions(ulong allowValue, ulong denyValue) @@ -119,7 +136,18 @@ namespace Discord PermValue? manageRoles = null, PermValue? manageWebhooks = null, PermValue? prioritySpeaker = null, - PermValue? stream = null) + PermValue? stream = null, + PermValue? useSlashCommands = null, + PermValue? useApplicationCommands = null, + PermValue? requestToSpeak = null, + PermValue? manageThreads = null, + PermValue? createPublicThreads = null, + PermValue? createPrivateThreads = null, + PermValue? usePublicThreads = null, + PermValue? usePrivateThreads = null, + PermValue? useExternalStickers = null, + PermValue? sendMessagesInThreads = null, + PermValue? startEmbeddedActivities = null) { Permissions.SetValue(ref allowValue, ref denyValue, createInstantInvite, ChannelPermission.CreateInstantInvite); Permissions.SetValue(ref allowValue, ref denyValue, manageChannel, ChannelPermission.ManageChannels); @@ -143,6 +171,14 @@ namespace Discord Permissions.SetValue(ref allowValue, ref denyValue, stream, ChannelPermission.Stream); Permissions.SetValue(ref allowValue, ref denyValue, manageRoles, ChannelPermission.ManageRoles); Permissions.SetValue(ref allowValue, ref denyValue, manageWebhooks, ChannelPermission.ManageWebhooks); + Permissions.SetValue(ref allowValue, ref denyValue, useApplicationCommands, ChannelPermission.UseApplicationCommands); + Permissions.SetValue(ref allowValue, ref denyValue, requestToSpeak, ChannelPermission.RequestToSpeak); + Permissions.SetValue(ref allowValue, ref denyValue, manageThreads, ChannelPermission.ManageThreads); + Permissions.SetValue(ref allowValue, ref denyValue, createPublicThreads, ChannelPermission.CreatePublicThreads); + Permissions.SetValue(ref allowValue, ref denyValue, createPrivateThreads, ChannelPermission.CreatePrivateThreads); + Permissions.SetValue(ref allowValue, ref denyValue, useExternalStickers, ChannelPermission.UseExternalStickers); + Permissions.SetValue(ref allowValue, ref denyValue, sendMessagesInThreads, ChannelPermission.SendMessagesInThreads); + Permissions.SetValue(ref allowValue, ref denyValue, startEmbeddedActivities, ChannelPermission.StartEmbeddedActivities); AllowValue = allowValue; DenyValue = denyValue; @@ -173,10 +209,23 @@ namespace Discord PermValue manageRoles = PermValue.Inherit, PermValue manageWebhooks = PermValue.Inherit, PermValue prioritySpeaker = PermValue.Inherit, - PermValue stream = PermValue.Inherit) + PermValue stream = PermValue.Inherit, + PermValue useSlashCommands = PermValue.Inherit, + PermValue useApplicationCommands = PermValue.Inherit, + PermValue requestToSpeak = PermValue.Inherit, + PermValue manageThreads = PermValue.Inherit, + PermValue createPublicThreads = PermValue.Inherit, + PermValue createPrivateThreads = PermValue.Inherit, + PermValue usePublicThreads = PermValue.Inherit, + PermValue usePrivateThreads = PermValue.Inherit, + PermValue useExternalStickers = PermValue.Inherit, + PermValue sendMessagesInThreads = PermValue.Inherit, + PermValue startEmbeddedActivities = PermValue.Inherit) : this(0, 0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, - moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream) { } + moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream, useSlashCommands, useApplicationCommands, + requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, usePublicThreads, usePrivateThreads, useExternalStickers, + sendMessagesInThreads, startEmbeddedActivities) { } /// /// Initializes a new from the current one, changing the provided @@ -204,10 +253,23 @@ namespace Discord PermValue? manageRoles = null, PermValue? manageWebhooks = null, PermValue? prioritySpeaker = null, - PermValue? stream = null) + PermValue? stream = null, + PermValue? useSlashCommands = null, + PermValue? useApplicationCommands = null, + PermValue? requestToSpeak = null, + PermValue? manageThreads = null, + PermValue? createPublicThreads = null, + PermValue? createPrivateThreads = null, + PermValue? usePublicThreads = null, + PermValue? usePrivateThreads = null, + PermValue? useExternalStickers = null, + PermValue? sendMessagesInThreads = null, + PermValue? startEmbeddedActivities = null) => new OverwritePermissions(AllowValue, DenyValue, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, - moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream); + moveMembers, useVoiceActivation, manageRoles, manageWebhooks, prioritySpeaker, stream, useSlashCommands, useApplicationCommands, + requestToSpeak, manageThreads, createPublicThreads, createPrivateThreads, usePublicThreads, usePrivateThreads, useExternalStickers, + sendMessagesInThreads, startEmbeddedActivities); /// /// Creates a of all the values that are allowed. diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index af46d06ad..f6ce59739 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -3243,7 +3243,6 @@ Gets a collection of all stage channels in this guild. - The that determines whether the object should be fetched from cache. The options to be used when sending the request. A task that represents the asynchronous get operation. The task result contains a read-only collection of diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index c194d00ef..b2b80b2eb 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -4286,10 +4286,6 @@ Responds to an Interaction with type . - - If you have set to , You should use - instead. - The text of the message to be sent. A array of embeds to send with this response. Max 10. diff --git a/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs b/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs index a3566590a..2cab8fa21 100644 --- a/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs +++ b/test/Discord.Net.Tests.Unit/ChannelPermissionsTests.cs @@ -85,6 +85,10 @@ namespace Discord AssertFlag(() => new ChannelPermissions(stream: true), ChannelPermission.Stream); AssertFlag(() => new ChannelPermissions(manageRoles: true), ChannelPermission.ManageRoles); AssertFlag(() => new ChannelPermissions(manageWebhooks: true), ChannelPermission.ManageWebhooks); + AssertFlag(() => new ChannelPermissions(useApplicationCommands: true), ChannelPermission.UseApplicationCommands); + AssertFlag(() => new ChannelPermissions(createPrivateThreads: true), ChannelPermission.CreatePrivateThreads); + AssertFlag(() => new ChannelPermissions(createPublicThreads: true), ChannelPermission.CreatePublicThreads); + AssertFlag(() => new ChannelPermissions(sendMessagesInThreads: true), ChannelPermission.SendMessagesInThreads); } /// diff --git a/test/Discord.Net.Tests.Unit/ColorTests.cs b/test/Discord.Net.Tests.Unit/ColorTests.cs index 87c76e4e2..48a6041e5 100644 --- a/test/Discord.Net.Tests.Unit/ColorTests.cs +++ b/test/Discord.Net.Tests.Unit/ColorTests.cs @@ -15,7 +15,7 @@ namespace Discord { Assert.Equal(0u, new Color().RawValue); Assert.Equal(uint.MinValue, new Color(uint.MinValue).RawValue); - Assert.Equal(uint.MaxValue, new Color(uint.MaxValue).RawValue); + Assert.Throws(() => new Color(uint.MaxValue)); } [Fact] public void Color_Default() diff --git a/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs b/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs index 68a685fdb..00ca05504 100644 --- a/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs +++ b/test/Discord.Net.Tests.Unit/GuildPermissionsTests.cs @@ -92,7 +92,7 @@ namespace Discord AssertFlag(() => new GuildPermissions(manageRoles: true), GuildPermission.ManageRoles); AssertFlag(() => new GuildPermissions(manageWebhooks: true), GuildPermission.ManageWebhooks); AssertFlag(() => new GuildPermissions(manageEmojisAndStickers: true), GuildPermission.ManageEmojisAndStickers); - AssertFlag(() => new GuildPermissions(useSlashCommands: true), GuildPermission.UseSlashCommands); + AssertFlag(() => new GuildPermissions(useApplicationCommands: true), GuildPermission.UseApplicationCommands); AssertFlag(() => new GuildPermissions(requestToSpeak: true), GuildPermission.RequestToSpeak); AssertFlag(() => new GuildPermissions(manageThreads: true), GuildPermission.ManageThreads); AssertFlag(() => new GuildPermissions(createPublicThreads: true), GuildPermission.CreatePublicThreads); @@ -168,7 +168,7 @@ namespace Discord AssertUtil(GuildPermission.ManageRoles, x => x.ManageRoles, (p, enable) => p.Modify(manageRoles: enable)); AssertUtil(GuildPermission.ManageWebhooks, x => x.ManageWebhooks, (p, enable) => p.Modify(manageWebhooks: enable)); AssertUtil(GuildPermission.ManageEmojisAndStickers, x => x.ManageEmojisAndStickers, (p, enable) => p.Modify(manageEmojisAndStickers: enable)); - AssertUtil(GuildPermission.UseSlashCommands, x => x.UseSlashCommands, (p, enable) => p.Modify(useSlashCommands: enable)); + AssertUtil(GuildPermission.UseApplicationCommands, x => x.UseApplicationCommands, (p, enable) => p.Modify(useApplicationCommands: enable)); AssertUtil(GuildPermission.RequestToSpeak, x => x.RequestToSpeak, (p, enable) => p.Modify(requestToSpeak: enable)); AssertUtil(GuildPermission.ManageThreads, x => x.ManageThreads, (p, enable) => p.Modify(manageThreads: enable)); AssertUtil(GuildPermission.CreatePublicThreads, x => x.CreatePublicThreads, (p, enable) => p.Modify(createPublicThreads: enable)); From bdcc508c3b5bd018324c0a0d28d8087744ac2492 Mon Sep 17 00:00:00 2001 From: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Sat, 25 Sep 2021 14:58:04 -0300 Subject: [PATCH 23/27] Update azure-pipelines.yml --- azure-pipelines.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9aa0e5788..4f68b05ac 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,8 +13,7 @@ trigger: jobs: - job: Linux - pool: - vmImage: 'ubuntu-latest' + pool: default steps: - template: azure/build.yml From b1e9c73d88f55d390129dc6261689f3e8fb74391 Mon Sep 17 00:00:00 2001 From: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Sat, 25 Sep 2021 15:14:30 -0300 Subject: [PATCH 24/27] Update azure-pipelines.yml --- azure-pipelines.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4f68b05ac..68a0b8421 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -16,22 +16,15 @@ jobs: pool: default steps: - template: azure/build.yml + - template: azure/deploy.yml -- job: Windows_build - pool: - vmImage: 'windows-latest' - condition: ne(variables['Build.SourceBranch'], 'refs/heads/dev') - steps: - - template: azure/build.yml - -- job: Windows_deploy - pool: - vmImage: 'windows-latest' +- job: Linux_deploy + pool: default condition: | and ( succeeded(), or ( - eq(variables['Build.SourceBranch'], 'refs/heads/dev'), + eq(variables['Build.SourceBranch'], 'refs/heads/release/3.x'), eq(variables['buildTag'], True) ) ) From 3ba69169e37e080bfe328f7a01c3571ba1870698 Mon Sep 17 00:00:00 2001 From: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Sat, 25 Sep 2021 15:18:54 -0300 Subject: [PATCH 25/27] Update azure-pipelines.yml --- azure-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 68a0b8421..e8d30a365 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -16,7 +16,6 @@ jobs: pool: default steps: - template: azure/build.yml - - template: azure/deploy.yml - job: Linux_deploy pool: default From 98845b96fa213e1d63509b95d2e70105e18003ed Mon Sep 17 00:00:00 2001 From: quin lynch Date: Sat, 25 Sep 2021 16:53:25 -0300 Subject: [PATCH 26/27] Add support for long in autocomplete option --- src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs index c152c1f27..a0992fd00 100644 --- a/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs +++ b/src/Discord.Net.Core/Entities/Interactions/AutocompleteResult.cs @@ -57,6 +57,7 @@ namespace Discord { string str => str, int integer => integer, + long lng => lng, double number => number, _ => throw new ArgumentException($"Type {value.GetType().Name} cannot be set as a value! Only string, int, and double allowed!"), }; From bc8c960e5a64c6ad96d1b7355449c4effbf42d43 Mon Sep 17 00:00:00 2001 From: d4n3436 Date: Sat, 25 Sep 2021 15:23:22 -0500 Subject: [PATCH 27/27] Add support for sending files with multiple embeds (#196) * Add support for sending files with multiple embeds * Simplify prepending single embed to embed array --- src/Discord.Net.Core/Discord.Net.Core.xml | 16 +++++---- .../Entities/Channels/IMessageChannel.cs | 6 ++-- .../Extensions/UserExtensions.cs | 18 ++++++---- .../API/Rest/UploadFileParams.cs | 6 ++-- src/Discord.Net.Rest/Discord.Net.Rest.xml | 36 ++++++++++--------- .../Entities/Channels/ChannelHelper.cs | 28 +++++++-------- .../Entities/Channels/IRestMessageChannel.cs | 12 ++++--- .../Entities/Channels/RestDMChannel.cs | 16 ++++----- .../Entities/Channels/RestGroupChannel.cs | 16 ++++----- .../Entities/Channels/RestTextChannel.cs | 16 ++++----- .../Discord.Net.WebSocket.xml | 34 +++++++++--------- .../Channels/ISocketMessageChannel.cs | 10 +++--- .../Entities/Channels/SocketDMChannel.cs | 16 ++++----- .../Entities/Channels/SocketGroupChannel.cs | 16 ++++----- .../Entities/Channels/SocketTextChannel.cs | 16 ++++----- .../MockedEntities/MockedDMChannel.cs | 4 +-- .../MockedEntities/MockedGroupChannel.cs | 4 +-- .../MockedEntities/MockedTextChannel.cs | 4 +-- 18 files changed, 145 insertions(+), 129 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index b759c8e13..a046da6fb 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -1534,7 +1534,7 @@ contains the sent message. - + Sends a file to this message channel with an optional caption. @@ -1569,12 +1569,13 @@ The message references to be included. Used to reply to specific messages. The message components to be included with this message. Used for interactions. A collection of stickers to send with the file. + A array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. - + Sends a file to this message channel with an optional caption. @@ -1606,6 +1607,7 @@ The message references to be included. Used to reply to specific messages. The message components to be included with this message. Used for interactions. A collection of stickers to send with the file. + A array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -11204,7 +11206,7 @@ An extension class for various Discord user objects. - + Sends a message via DM. @@ -11225,18 +11227,18 @@ The message to be sent. Whether the message should be read aloud by Discord or not. The to be sent. - A array of s to send with this response. Max 10. The options to be used when sending the request. Specifies if notifications are sent for mentioned users and roles in the message . If null, all mentioned roles and users will be notified. The message components to be included with this message. Used for interactions. + A array of s to send with this response. Max 10. A task that represents the asynchronous send operation. The task result contains the sent message. - + Sends a file to this message channel with an optional caption. @@ -11274,12 +11276,13 @@ 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 array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. - + Sends a file via DM with an optional caption. @@ -11322,6 +11325,7 @@ 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 array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs index 9e145a630..95507d297 100644 --- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs @@ -70,11 +70,12 @@ namespace Discord /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the file. + /// A array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null); + Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null); /// /// Sends a file to this message channel with an optional caption. /// @@ -106,11 +107,12 @@ namespace Discord /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the file. + /// A array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null); + Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null); /// /// Gets a message from this message channel. diff --git a/src/Discord.Net.Core/Extensions/UserExtensions.cs b/src/Discord.Net.Core/Extensions/UserExtensions.cs index aa807c073..e268eae84 100644 --- a/src/Discord.Net.Core/Extensions/UserExtensions.cs +++ b/src/Discord.Net.Core/Extensions/UserExtensions.cs @@ -27,13 +27,13 @@ namespace Discord /// The message to be sent. /// Whether the message should be read aloud by Discord or not. /// The to be sent. - /// A array of s to send with this response. Max 10. /// The options to be used when sending the request. /// /// Specifies if notifications are sent for mentioned users and roles in the message . /// If null, all mentioned roles and users will be notified. /// /// The message components to be included with this message. Used for interactions. + /// A array of s to send with this response. Max 10. /// /// A task that represents the asynchronous send operation. The task result contains the sent message. /// @@ -41,10 +41,10 @@ namespace Discord string text = null, bool isTTS = false, Embed embed = null, - Embed[] embeds = null, RequestOptions options = null, AllowedMentions allowedMentions = null, - MessageComponent component = null) + MessageComponent component = null, + Embed[] embeds = null) { return await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(text, isTTS, embed, options, allowedMentions, component: component, embeds: embeds).ConfigureAwait(false); } @@ -86,6 +86,7 @@ namespace Discord /// 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 array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. @@ -97,9 +98,10 @@ namespace Discord bool isTTS = false, Embed embed = null, RequestOptions options = null, - MessageComponent component = null) + MessageComponent component = null, + Embed[] embeds = null) { - return await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(stream, filename, text, isTTS, embed, options, component: component).ConfigureAwait(false); + return await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(stream, filename, text, isTTS, embed, options, component: component, embeds: embeds).ConfigureAwait(false); } /// @@ -144,6 +146,7 @@ namespace Discord /// 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 array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. @@ -154,9 +157,10 @@ namespace Discord bool isTTS = false, Embed embed = null, RequestOptions options = null, - MessageComponent component = null) + MessageComponent component = null, + Embed[] embeds = null) { - return await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(filePath, text, isTTS, embed, options, component: component).ConfigureAwait(false); + return await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendFileAsync(filePath, text, isTTS, embed, options, component: component, embeds: embeds).ConfigureAwait(false); } /// diff --git a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs index f18da65c1..98fb0e7ca 100644 --- a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs +++ b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs @@ -17,7 +17,7 @@ namespace Discord.API.Rest public Optional Content { get; set; } public Optional Nonce { get; set; } public Optional IsTTS { get; set; } - public Optional Embed { get; set; } + public Optional Embeds { get; set; } public Optional AllowedMentions { get; set; } public Optional MessageReference { get; set; } public Optional MessageComponent { get; set; } @@ -44,8 +44,8 @@ namespace Discord.API.Rest payload["tts"] = IsTTS.Value.ToString(); if (Nonce.IsSpecified) payload["nonce"] = Nonce.Value; - if (Embed.IsSpecified) - payload["embed"] = Embed.Value; + if (Embeds.IsSpecified) + payload["embeds"] = Embeds.Value; if (AllowedMentions.IsSpecified) payload["allowed_mentions"] = AllowedMentions.Value; if (MessageComponent.IsSpecified) diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index f6ce59739..91727936d 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -1721,7 +1721,7 @@ Message content is too long, length must be less or equal to . - + is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . @@ -1747,7 +1747,7 @@ An I/O error occurred while opening the file. Message content is too long, length must be less or equal to . - + Message content is too long, length must be less or equal to . @@ -1789,13 +1789,13 @@ contains the sent message. - + Sends a file to this message channel with an optional caption. - This method follows the same behavior as described in - . Please visit + This method follows the same behavior as described in + . Please visit its documentation for more details on this method. The file path of the file. @@ -1811,17 +1811,18 @@ The message references to be included. Used to reply to specific messages. The message components to be included with this message. Used for interactions. A collection of stickers to send with the message. + A array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. - + Sends a file to this message channel with an optional caption. - This method follows the same behavior as described in . + This method follows the same behavior as described in . Please visit its documentation for more details on this method. The of the file to be sent. @@ -1838,6 +1839,7 @@ The message references to be included. Used to reply to specific messages. The message components to be included with this message. Used for interactions. A collection of stickers to send with the message. + A array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -2021,7 +2023,7 @@ Message content is too long, length must be less or equal to . - + is a zero-length string, contains only white space, or contains one or more @@ -2048,7 +2050,7 @@ An I/O error occurred while opening the file. Message content is too long, length must be less or equal to . - + Message content is too long, length must be less or equal to . @@ -2099,10 +2101,10 @@ - + - + @@ -2159,7 +2161,7 @@ Message content is too long, length must be less or equal to . - + is a zero-length string, contains only white space, or contains one or more @@ -2186,7 +2188,7 @@ An I/O error occurred while opening the file. Message content is too long, length must be less or equal to . - + Message content is too long, length must be less or equal to . @@ -2449,7 +2451,7 @@ Message content is too long, length must be less or equal to . - + is a zero-length string, contains only white space, or contains one or more @@ -2476,7 +2478,7 @@ An I/O error occurred while opening the file. Message content is too long, length must be less or equal to . - + Message content is too long, length must be less or equal to . @@ -2609,10 +2611,10 @@ - + - + diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs index 273ffab93..c5d264ade 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs @@ -268,20 +268,13 @@ namespace Discord.Rest public static async Task SendMessageAsync(IMessageChannel channel, BaseDiscordClient client, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, RequestOptions options, Embed[] embeds) { + embeds ??= Array.Empty(); if (embed != null) - { - if (embeds == null) - embeds = new[] { embed }; - else - { - List listEmbeds = embeds.ToList(); - listEmbeds.Insert(0, embed); - } - } + embeds = new[] { embed }.Concat(embeds).ToArray(); Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); - Preconditions.AtMost(embeds?.Length ?? 0, 10, nameof(embeds), "A max of 10 embeds are allowed."); + Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed."); // check that user flag and user Id list are exclusive, same with role flag and role Id list if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue) @@ -307,7 +300,7 @@ namespace Discord.Rest var args = new CreateMessageParams(text) { IsTTS = isTTS, - Embeds = embeds?.Select(x => x.ToModel()).ToArray() ?? Optional.Unspecified, + Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional.Unspecified, AllowedMentions = allowedMentions?.ToModel(), MessageReference = messageReference?.ToModel(), Components = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, @@ -342,19 +335,24 @@ namespace Discord.Rest /// An I/O error occurred while opening the file. /// Message content is too long, length must be less or equal to . public static async Task SendFileAsync(IMessageChannel channel, BaseDiscordClient client, - string filePath, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, RequestOptions options, bool isSpoiler) + string filePath, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, RequestOptions options, bool isSpoiler, Embed[] embeds) { string filename = Path.GetFileName(filePath); using (var file = File.OpenRead(filePath)) - return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler).ConfigureAwait(false); + return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds).ConfigureAwait(false); } /// Message content is too long, length must be less or equal to . public static async Task SendFileAsync(IMessageChannel channel, BaseDiscordClient client, - Stream stream, string filename, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, RequestOptions options, bool isSpoiler) + Stream stream, string filename, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, RequestOptions options, bool isSpoiler, Embed[] embeds) { + embeds ??= Array.Empty(); + if (embed != null) + embeds = new[] { embed }.Concat(embeds).ToArray(); + Preconditions.AtMost(allowedMentions?.RoleIds?.Count ?? 0, 100, nameof(allowedMentions.RoleIds), "A max of 100 role Ids are allowed."); Preconditions.AtMost(allowedMentions?.UserIds?.Count ?? 0, 100, nameof(allowedMentions.UserIds), "A max of 100 user Ids are allowed."); + Preconditions.AtMost(embeds.Length, 10, nameof(embeds), "A max of 10 embeds are allowed."); // check that user flag and user Id list are exclusive, same with role flag and role Id list if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue) @@ -377,7 +375,7 @@ namespace Discord.Rest Preconditions.AtMost(stickers.Length, 3, nameof(stickers), "A max of 3 stickers are allowed."); } - var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS, Embed = embed?.ToModel() ?? Optional.Unspecified, AllowedMentions = allowedMentions?.ToModel() ?? Optional.Unspecified, MessageReference = messageReference?.ToModel() ?? Optional.Unspecified, MessageComponent = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, IsSpoiler = isSpoiler, Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional.Unspecified }; + var args = new UploadFileParams(stream) { Filename = filename, Content = text, IsTTS = isTTS, Embeds = embeds.Any() ? embeds.Select(x => x.ToModel()).ToArray() : Optional.Unspecified, AllowedMentions = allowedMentions?.ToModel() ?? Optional.Unspecified, MessageReference = messageReference?.ToModel() ?? Optional.Unspecified, MessageComponent = component?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() ?? Optional.Unspecified, IsSpoiler = isSpoiler, Stickers = stickers?.Any() ?? false ? stickers.Select(x => x.Id).ToArray() : Optional.Unspecified }; var model = await client.ApiClient.UploadFileAsync(channel.Id, args, options).ConfigureAwait(false); return RestUserMessage.Create(client, channel, client.CurrentUser, model); } diff --git a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs index 0198fea87..159735798 100644 --- a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs @@ -37,8 +37,8 @@ namespace Discord.Rest /// Sends a file to this message channel with an optional caption. /// /// - /// This method follows the same behavior as described in - /// . Please visit + /// This method follows the same behavior as described in + /// . Please visit /// its documentation for more details on this method. /// /// The file path of the file. @@ -54,16 +54,17 @@ namespace Discord.Rest /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the message. + /// A array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null); + new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null); /// /// Sends a file to this message channel with an optional caption. /// /// - /// This method follows the same behavior as described in . + /// This method follows the same behavior as described in . /// Please visit its documentation for more details on this method. /// /// The of the file to be sent. @@ -80,11 +81,12 @@ namespace Discord.Rest /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the message. + /// A array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - new Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null); + new Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null); /// /// Gets a message from this message channel. diff --git a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs index 3f296f441..922f128b9 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs @@ -122,12 +122,12 @@ namespace Discord.Rest /// is in an invalid format. /// An I/O error occurred while opening the file. /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) @@ -209,11 +209,11 @@ namespace Discord.Rest async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) => await GetPinnedMessagesAsync(options).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs index c575a0997..aa7291ca6 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs @@ -128,12 +128,12 @@ namespace Discord.Rest /// is in an invalid format. /// An I/O error occurred while opening the file. /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// public Task TriggerTypingAsync(RequestOptions options = null) @@ -186,11 +186,11 @@ namespace Discord.Rest async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) => await GetPinnedMessagesAsync(options).ConfigureAwait(false); - async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); - async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index 05980ac7a..6fb7de984 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -131,13 +131,13 @@ namespace Discord.Rest /// is in an invalid format. /// An I/O error occurred while opening the file. /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) @@ -319,12 +319,12 @@ namespace Discord.Rest => await GetPinnedMessagesAsync(options).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index b2b80b2eb..abf0c1bb2 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -1482,12 +1482,12 @@ contains the sent message. - + Sends a file to this message channel with an optional caption. - This method follows the same behavior as described in . + This method follows the same behavior as described in . Please visit its documentation for more details on this method. The file path of the file. @@ -1503,17 +1503,18 @@ The message references to be included. Used to reply to specific messages. The message components to be included with this message. Used for interactions. A collection of stickers to send with the file. + A array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. - + Sends a file to this message channel with an optional caption. - This method follows the same behavior as described in . + This method follows the same behavior as described in . Please visit its documentation for more details on this method. The of the file to be sent. @@ -1530,6 +1531,7 @@ The message references to be included. Used to reply to specific messages. The message components to be included with this message. Used for interactions. A collection of stickers to send with the file. + A array of s to send with this response. Max 10. A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -1816,10 +1818,10 @@ Message content is too long, length must be less or equal to . - + - + Message content is too long, length must be less or equal to . @@ -1882,10 +1884,10 @@ - + - + @@ -2007,10 +2009,10 @@ Message content is too long, length must be less or equal to . - + - + Message content is too long, length must be less or equal to . @@ -2070,10 +2072,10 @@ - + - + @@ -2464,10 +2466,10 @@ Message content is too long, length must be less or equal to . - + - + Message content is too long, length must be less or equal to . @@ -2573,10 +2575,10 @@ - + - + diff --git a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs index 5ced13628..1103f8feb 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs @@ -46,7 +46,7 @@ namespace Discord.WebSocket /// Sends a file to this message channel with an optional caption. /// /// - /// This method follows the same behavior as described in . + /// This method follows the same behavior as described in . /// Please visit its documentation for more details on this method. /// /// The file path of the file. @@ -62,16 +62,17 @@ namespace Discord.WebSocket /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the file. + /// A array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null); + new Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null); /// /// Sends a file to this message channel with an optional caption. /// /// - /// This method follows the same behavior as described in . + /// This method follows the same behavior as described in . /// Please visit its documentation for more details on this method. /// /// The of the file to be sent. @@ -88,11 +89,12 @@ namespace Discord.WebSocket /// The message references to be included. Used to reply to specific messages. /// The message components to be included with this message. Used for interactions. /// A collection of stickers to send with the file. + /// A array of s to send with this response. Max 10. /// /// A task that represents an asynchronous send operation for delivering the message. The task result /// contains the sent message. /// - new Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null); + new Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null); /// /// Gets a cached message from this channel. diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs index a6f487cca..a298d352a 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs @@ -143,12 +143,12 @@ namespace Discord.WebSocket => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, embeds); /// - public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); @@ -246,11 +246,11 @@ namespace Discord.WebSocket async Task> IMessageChannel.GetPinnedMessagesAsync(RequestOptions options) => await GetPinnedMessagesAsync(options).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs index 3f758a93e..2fd748faa 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs @@ -177,12 +177,12 @@ namespace Discord.WebSocket => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, embeds); /// - public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) @@ -314,11 +314,11 @@ namespace Discord.WebSocket => await GetPinnedMessagesAsync(options).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs index 63ada8592..dd94e7788 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs @@ -215,13 +215,13 @@ namespace Discord.WebSocket => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, embeds); /// - public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(string filePath, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// /// Message content is too long, length must be less or equal to . - public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); + public Task SendFileAsync(Stream stream, string filename, string text, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler, embeds); /// public Task DeleteMessagesAsync(IEnumerable messages, RequestOptions options = null) @@ -371,11 +371,11 @@ namespace Discord.WebSocket => await GetPinnedMessagesAsync(options).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(string filePath, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// - async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers).ConfigureAwait(false); + async Task IMessageChannel.SendFileAsync(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) + => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); /// async Task IMessageChannel.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, Embed[] embeds) => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component, stickers, embeds).ConfigureAwait(false); diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs index a7451ddd2..c581867a3 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs @@ -84,7 +84,7 @@ namespace Discord } public Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException(); - public Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) => throw new NotImplementedException(); - public Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) => throw new NotImplementedException(); + public Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException(); + public Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) => throw new NotImplementedException(); } } diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs index fc9a16338..1c7c5544c 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs @@ -86,12 +86,12 @@ namespace Discord throw new NotImplementedException(); } - public Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) + public Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) { throw new NotImplementedException(); } - public Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) + public Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) { throw new NotImplementedException(); } diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs index 06d0d9811..459b5a69e 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs @@ -176,12 +176,12 @@ namespace Discord throw new NotImplementedException(); } - public Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) + public Task SendFileAsync(string filePath, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) { throw new NotImplementedException(); } - public Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null) + public Task SendFileAsync(Stream stream, string filename, string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, bool isSpoiler = false, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = null, ISticker[] stickers = null, Embed[] embeds = null) { throw new NotImplementedException(); }