From 97d3b0ee63cfd1122e35d63587d7eb32cbc6d309 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Sun, 19 Sep 2021 12:04:45 -0300 Subject: [PATCH 01/14] Renamed SelectMenu to SelectMenuComponent --- .../Message Components/ComponentBuilder.cs | 22 +++++++++---------- .../{SelectMenu.cs => SelectMenuComponent.cs} | 4 ++-- .../Message Components/SelectMenuOption.cs | 2 +- .../API/Common/SelectMenuComponent.cs | 2 +- .../Entities/Messages/RestMessage.cs | 2 +- .../SocketMessageComponentData.cs | 2 +- .../Entities/Messages/SocketMessage.cs | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) rename src/Discord.Net.Core/Entities/Interactions/Message Components/{SelectMenu.cs => SelectMenuComponent.cs} (91%) 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 f91bdba36..07cc0b6ab 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs @@ -80,7 +80,7 @@ namespace Discord foreach (var cmp in actionRow.Components) AddComponent(cmp, row); break; - case SelectMenu menu: + 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); break; } @@ -595,22 +595,22 @@ namespace Discord } /// - /// Represents a class used to build 's. + /// Represents a class used to build 's. /// public class SelectMenuBuilder { /// - /// The max length of a . + /// The max length of a . /// public const int MaxPlaceholderLength = 100; /// - /// The maximum number of values for the and properties. + /// The maximum number of values for the and properties. /// public const int MaxValuesCount = 25; /// - /// The maximum number of options a can have. + /// The maximum number of options a can have. /// public const int MaxOptionCount = 25; @@ -709,9 +709,9 @@ namespace Discord public SelectMenuBuilder() { } /// - /// Creates a new instance of a from instance of . + /// Creates a new instance of a from instance of . /// - public SelectMenuBuilder(SelectMenu selectMenu) + public SelectMenuBuilder(SelectMenuComponent selectMenu) { this.Placeholder = selectMenu.Placeholder; this.CustomId = selectMenu.Placeholder; @@ -861,14 +861,14 @@ namespace Discord } /// - /// Builds a + /// Builds a /// - /// The newly built - public SelectMenu Build() + /// The newly built + public SelectMenuComponent Build() { var options = this.Options?.Select(x => x.Build()).ToList(); - return new SelectMenu(this.CustomId, options, this.Placeholder, this.MinValues, this.MaxValues, this.Disabled); + return new SelectMenuComponent(this.CustomId, options, this.Placeholder, this.MinValues, this.MaxValues, this.Disabled); } } diff --git a/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenu.cs b/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuComponent.cs similarity index 91% rename from src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenu.cs rename to src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuComponent.cs index 46e53e470..6ea4c07fe 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenu.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuComponent.cs @@ -9,7 +9,7 @@ namespace Discord /// /// Represents a select menu component defined at /// - public class SelectMenu : IMessageComponent + public class SelectMenuComponent : IMessageComponent { /// public ComponentType Type => ComponentType.SelectMenu; @@ -59,7 +59,7 @@ namespace Discord this.MinValues, this.Disabled); - internal SelectMenu(string customId, List options, string placeholder, int minValues, int maxValues, bool disabled) + internal SelectMenuComponent(string customId, List options, string placeholder, int minValues, int maxValues, bool disabled) { this.CustomId = customId; this.Options = options; 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 74da89cae..e5425971a 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuOption.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/SelectMenuOption.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Discord { /// - /// Represents a choice for a . + /// Represents a choice for a . /// public class SelectMenuOption { diff --git a/src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs b/src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs index 6de1d4a4d..f99b8aa7d 100644 --- a/src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs +++ b/src/Discord.Net.Rest/API/Common/SelectMenuComponent.cs @@ -32,7 +32,7 @@ namespace Discord.API public SelectMenuComponent() { } - public SelectMenuComponent(Discord.SelectMenu component) + public SelectMenuComponent(Discord.SelectMenuComponent component) { this.Type = component.Type; this.CustomId = component.CustomId; diff --git a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs index c13d72a75..09e262f00 100644 --- a/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs +++ b/src/Discord.Net.Rest/Entities/Messages/RestMessage.cs @@ -163,7 +163,7 @@ namespace Discord.Rest case ComponentType.SelectMenu: { var parsed = (API.SelectMenuComponent)y; - return new SelectMenu( + return new SelectMenuComponent( parsed.CustomId, parsed.Options.Select(z => new SelectMenuOption( z.Label, 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 45e688266..a24fd59ac 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponentData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponentData.cs @@ -23,7 +23,7 @@ namespace Discord.WebSocket public ComponentType Type { get; } /// - /// The value(s) of a interaction response. + /// The value(s) of a interaction response. /// public IReadOnlyCollection Values { get; } diff --git a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs index 167440069..20df3446e 100644 --- a/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs +++ b/src/Discord.Net.WebSocket/Entities/Messages/SocketMessage.cs @@ -198,7 +198,7 @@ namespace Discord.WebSocket case ComponentType.SelectMenu: { var parsed = (API.SelectMenuComponent)y; - return new SelectMenu( + return new SelectMenuComponent( parsed.CustomId, parsed.Options.Select(z => new SelectMenuOption( z.Label, From 0ca6f506a813e00b486417577f2d4bc6a4698088 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Sun, 19 Sep 2021 12:12:29 -0300 Subject: [PATCH 02/14] Update refs to selects --- src/Discord.Net.Rest/API/Common/ActionRowComponent.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs b/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs index 43b48f01a..270532a18 100644 --- a/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs +++ b/src/Discord.Net.Rest/API/Common/ActionRowComponent.cs @@ -27,7 +27,7 @@ namespace Discord.API case ComponentType.Button: return new ButtonComponent(x as Discord.ButtonComponent); case ComponentType.SelectMenu: - return new SelectMenuComponent(x as Discord.SelectMenu); + return new SelectMenuComponent(x as Discord.SelectMenuComponent); default: return null; } From 3cd351f2bfd71ba9f29d1545c2a9a39b0d546000 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Mon, 20 Sep 2021 02:27:44 -0300 Subject: [PATCH 03/14] Create stage channels --- src/Discord.Net.Core/Discord.Net.Core.xml | 73 +++++++++++++------ .../Entities/Guilds/IGuild.cs | 11 +++ .../Entities/Guilds/GuildHelper.cs | 28 +++++++ .../Entities/Guilds/RestGuild.cs | 15 ++++ .../Entities/Guilds/SocketGuild.cs | 16 ++++ 5 files changed, 120 insertions(+), 23 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index 5ace1922d..6d415630e 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -4524,6 +4524,9 @@ The value of this choice. + + Discord only accepts int and string as the input. + @@ -4591,6 +4594,11 @@ Gets or sets the name of this command. + + + Whether the command is enabled by default when the app is added to a guild. Default is + + ApplicationCommandType is enum of current valid Application Command Types: Slash, User, Message @@ -4626,6 +4634,11 @@ The name of this Message command. + + + Whether the command is enabled by default when the app is added to a guild + + Build the current builder into a class. @@ -4643,6 +4656,13 @@ The current builder. + + + Sets the default permission of the current command. + + The default permission value to set. + The current builder. + A class used to create message commands. @@ -4663,6 +4683,11 @@ The name of this User command. + + + Whether the command is enabled by default when the app is added to a guild + + Build the current builder into a class. @@ -4678,6 +4703,13 @@ The current builder. + + + Sets the default permission of the current command. + + The default permission value to set. + The current builder. + A class used to create User commands. @@ -5379,22 +5411,22 @@ - Represents a class used to build 's. + Represents a class used to build 's. - The max length of a . + The max length of a . - The maximum number of values for the and properties. + The maximum number of values for the and properties. - The maximum number of options a can have. + The maximum number of options a can have. @@ -5438,9 +5470,9 @@ Creates a new instance of a . - + - Creates a new instance of a from instance of . + Creates a new instance of a from instance of . @@ -5539,9 +5571,9 @@ - Builds a + Builds a - The newly built + The newly built @@ -5715,45 +5747,45 @@ Returns a empty . - + Represents a select menu component defined at - + - + The custom id of this Select menu that will be sent with a . - + The menus options to select from. - + A custom placeholder text if nothing is selected, max 100 characters. - + The minimum number of items that must be chosen; default 1, min 0, max 25 - + The maximum number of items that can be chosen; default 1, max 25 - + Whether this menu is disabled or not. - + Turns this select menu into a builder. @@ -5763,7 +5795,7 @@ - Represents a choice for a . + Represents a choice for a . @@ -6038,11 +6070,6 @@ Gets or sets the options for this command. - - - Whether the command is enabled by default when the app is added to a guild. Default is - - Represents a generic invite object. diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs index 83efb158b..76ff9eb4f 100644 --- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs @@ -667,6 +667,17 @@ namespace Discord /// Task CreateVoiceChannelAsync(string name, Action func = null, RequestOptions options = null); /// + /// Creates a new stage channel in this guild. + /// + /// The new name for the stage channel. + /// The delegate containing the properties to be applied to the channel upon its creation. + /// The options to be used when sending the request. + /// + /// A task that represents the asynchronous creation operation. The task result contains the newly created + /// stage channel. + /// + Task CreateStageChannelAsync(string name, Action func = null, RequestOptions options = null); + /// /// Creates a new channel category in this guild. /// /// The new name for the category. diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs index b1fb2f044..73f59b566 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs @@ -221,6 +221,34 @@ namespace Discord.Rest var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return RestVoiceChannel.Create(client, guild, model); } + public static async Task CreateStageChannelAsync(IGuild guild, BaseDiscordClient client, + string name, RequestOptions options, Action func = null) + { + if (name == null) + throw new ArgumentNullException(paramName: nameof(name)); + + var props = new VoiceChannelProperties(); + func?.Invoke(props); + + var args = new CreateGuildChannelParams(name, ChannelType.Stage) + { + CategoryId = props.CategoryId, + Bitrate = props.Bitrate, + UserLimit = props.UserLimit, + Position = props.Position, + Overwrites = props.PermissionOverwrites.IsSpecified + ? props.PermissionOverwrites.Value.Select(overwrite => new API.Overwrite + { + TargetId = overwrite.TargetId, + TargetType = overwrite.TargetType, + Allow = overwrite.Permissions.AllowValue.ToString(), + Deny = overwrite.Permissions.DenyValue.ToString() + }).ToArray() + : Optional.Create(), + }; + var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); + return RestStageChannel.Create(client, guild, model); + } /// is null. public static async Task CreateCategoryChannelAsync(IGuild guild, BaseDiscordClient client, string name, RequestOptions options, Action func = null) diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index 5b9436970..3608c2d8b 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -663,6 +663,18 @@ namespace Discord.Rest public Task CreateVoiceChannelAsync(string name, Action func = null, RequestOptions options = null) => GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options, func); /// + /// Creates a new stage channel in this guild. + /// + /// The new name for the stage channel. + /// The delegate containing the properties to be applied to the channel upon its creation. + /// The options to be used when sending the request. + /// + /// A task that represents the asynchronous creation operation. The task result contains the newly created + /// stage channel. + /// + public Task CreateStageChannelAsync(string name, Action func = null, RequestOptions options = null) + => GuildHelper.CreateStageChannelAsync(this, Discord, name, options, func); + /// /// Creates a category channel with the provided name. /// /// The name of the new channel. @@ -1241,6 +1253,9 @@ namespace Discord.Rest async Task IGuild.CreateVoiceChannelAsync(string name, Action func, RequestOptions options) => await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false); /// + async Task IGuild.CreateStageChannelAsync(string name, Action func, RequestOptions options) + => await CreateStageChannelAsync(name, func, options).ConfigureAwait(false); + /// async Task IGuild.CreateCategoryAsync(string name, Action func, RequestOptions options) => await CreateCategoryChannelAsync(name, func, options).ConfigureAwait(false); diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index 1d1175f52..0c211f394 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -746,6 +746,19 @@ namespace Discord.WebSocket /// public Task CreateVoiceChannelAsync(string name, Action func = null, RequestOptions options = null) => GuildHelper.CreateVoiceChannelAsync(this, Discord, name, options, func); + + /// + /// Creates a new stage channel in this guild. + /// + /// The new name for the stage channel. + /// The delegate containing the properties to be applied to the channel upon its creation. + /// The options to be used when sending the request. + /// + /// A task that represents the asynchronous creation operation. The task result contains the newly created + /// stage channel. + /// + public Task CreateStageChannelAsync(string name, Action func = null, RequestOptions options = null) + => GuildHelper.CreateStageChannelAsync(this, Discord, name, options, func); /// /// Creates a new channel category in this guild. /// @@ -1650,6 +1663,9 @@ namespace Discord.WebSocket async Task IGuild.CreateVoiceChannelAsync(string name, Action func, RequestOptions options) => await CreateVoiceChannelAsync(name, func, options).ConfigureAwait(false); /// + async Task IGuild.CreateStageChannelAsync(string name, Action func, RequestOptions options) + => await CreateStageChannelAsync(name, func, options).ConfigureAwait(false); + /// async Task IGuild.CreateCategoryAsync(string name, Action func, RequestOptions options) => await CreateCategoryChannelAsync(name, func, options).ConfigureAwait(false); From 895ce0a9f2877dd945f62789ca83468a81e0b18c Mon Sep 17 00:00:00 2001 From: quin lynch Date: Mon, 20 Sep 2021 03:39:57 -0300 Subject: [PATCH 04/14] Add sticker param to send message functions --- src/Discord.Net.Commands/ModuleBase.cs | 6 +- src/Discord.Net.Core/Discord.Net.Core.xml | 63 ++++++++---- .../Entities/Channels/IMessageChannel.cs | 9 +- .../Entities/Stickers/ISticker.cs | 29 +++--- .../Entities/Stickers/StickerType.cs | 24 +++++ src/Discord.Net.Rest/API/Common/Sticker.cs | 10 +- .../API/Rest/CreateMessageParams.cs | 4 + .../API/Rest/UploadFileParams.cs | 3 + src/Discord.Net.Rest/Discord.Net.Rest.xml | 76 +++++++++----- .../Entities/Channels/ChannelHelper.cs | 22 +++-- .../Entities/Channels/IRestMessageChannel.cs | 16 ++- .../Entities/Channels/RestDMChannel.cs | 24 ++--- .../Entities/Channels/RestGroupChannel.cs | 24 ++--- .../Entities/Channels/RestTextChannel.cs | 24 ++--- .../Entities/Messages/Sticker.cs | 21 ++-- .../Discord.Net.WebSocket.xml | 99 +++++++++++-------- .../Channels/ISocketMessageChannel.cs | 13 ++- .../Entities/Channels/SocketDMChannel.cs | 24 ++--- .../Entities/Channels/SocketGroupChannel.cs | 25 ++--- .../Entities/Channels/SocketTextChannel.cs | 24 ++--- .../Entities/Stickers/SocketCustomSticker.cs | 2 +- .../Entities/Stickers/SocketSticker.cs | 21 ++-- .../Entities/Stickers/SocketUnknownSticker.cs | 15 +-- .../MockedEntities/MockedDMChannel.cs | 19 +--- .../MockedEntities/MockedGroupChannel.cs | 6 +- .../MockedEntities/MockedTextChannel.cs | 6 +- 26 files changed, 368 insertions(+), 241 deletions(-) create mode 100644 src/Discord.Net.Core/Entities/Stickers/StickerType.cs diff --git a/src/Discord.Net.Commands/ModuleBase.cs b/src/Discord.Net.Commands/ModuleBase.cs index 366cab450..159b44fb8 100644 --- a/src/Discord.Net.Commands/ModuleBase.cs +++ b/src/Discord.Net.Commands/ModuleBase.cs @@ -36,9 +36,11 @@ namespace Discord.Commands /// If null, all mentioned roles and users will be notified. /// /// The message references to be included. Used to reply to specific messages. - 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) + /// 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) { - return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions, messageReference, component).ConfigureAwait(false); + return await Context.Channel.SendMessageAsync(message, isTTS, embed, options, allowedMentions, messageReference, component, stickers).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 6d415630e..220f3fae4 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. @@ -1527,12 +1527,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 message. 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. @@ -1566,12 +1567,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 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. @@ -1602,6 +1604,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 task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -3639,6 +3642,18 @@ voice channel. + + + Creates a new stage channel in this guild. + + The new name for the stage channel. + The delegate containing the properties to be applied to the channel upon its creation. + The options to be used when sending the request. + + A task that represents the asynchronous creation operation. The task result contains the newly created + stage channel. + + Creates a new channel category in this guild. @@ -5205,7 +5220,7 @@ Builds this builder into a used to send your components. - A that can be sent with . + A that can be sent with . @@ -9652,21 +9667,10 @@ A read-only list with the tags of this sticker. - + - Gets the asset hash of this sticker. + Gets the type of this sticker. - - A with the asset hash of this sticker. - - - - - Gets the preview asset hash of this sticker. - - - A with the preview asset hash of this sticker. - @@ -9676,6 +9680,16 @@ A with the format type of this sticker. + + + Gets whether this guild sticker can be used, may be false due to loss of Server Boosts + + + + + Gets the standard sticker's sort order within its pack + + Gets the image url for this sticker. @@ -9762,6 +9776,21 @@ Gets or sets the tags of the sticker. + + + Represents a type of sticker + + + + + Represents a discord standard sticker, this type of sticker cannot be modified by an application. + + + + + Represents a sticker that was created within a guild. + + Represents a Discord Team. diff --git a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs index 11998c28b..1fffea6e9 100644 --- a/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs +++ b/src/Discord.Net.Core/Entities/Channels/IMessageChannel.cs @@ -29,11 +29,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 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); + 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); /// /// Sends a file to this message channel with an optional caption. /// @@ -67,11 +68,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 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); + 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); /// /// Sends a file to this message channel with an optional caption. /// @@ -102,11 +104,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 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); + 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); /// /// Gets a message from this message channel. diff --git a/src/Discord.Net.Core/Entities/Stickers/ISticker.cs b/src/Discord.Net.Core/Entities/Stickers/ISticker.cs index e16e03990..6d0eee1b4 100644 --- a/src/Discord.Net.Core/Entities/Stickers/ISticker.cs +++ b/src/Discord.Net.Core/Entities/Stickers/ISticker.cs @@ -15,7 +15,7 @@ namespace Discord /// /// A snowflake ID associated with this sticker. /// - ulong Id { get; } + new ulong Id { get; } /// /// Gets the ID of the pack of this sticker. /// @@ -29,7 +29,7 @@ namespace Discord /// /// A with the name of this sticker. /// - string Name { get; } + new string Name { get; } /// /// Gets the description of this sticker. /// @@ -45,27 +45,26 @@ namespace Discord /// IReadOnlyCollection Tags { get; } /// - /// Gets the asset hash of this sticker. + /// Gets the type of this sticker. /// - /// - /// A with the asset hash of this sticker. - /// - string Asset { get; } - /// - /// Gets the preview asset hash of this sticker. - /// - /// - /// A with the preview asset hash of this sticker. - /// - string PreviewAsset { get; } + StickerType Type { get; } /// /// Gets the format type of this sticker. /// /// /// A with the format type of this sticker. /// - StickerFormatType Format { get; } + new StickerFormatType Format { get; } + /// + /// Gets whether this guild sticker can be used, may be false due to loss of Server Boosts + /// + bool? Available { get; } + + /// + /// Gets the standard sticker's sort order within its pack + /// + int? SortOrder { get; } /// /// Gets the image url for this sticker. /// diff --git a/src/Discord.Net.Core/Entities/Stickers/StickerType.cs b/src/Discord.Net.Core/Entities/Stickers/StickerType.cs new file mode 100644 index 000000000..35946df7a --- /dev/null +++ b/src/Discord.Net.Core/Entities/Stickers/StickerType.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Discord +{ + /// + /// Represents a type of sticker + /// + public enum StickerType + { + /// + /// Represents a discord standard sticker, this type of sticker cannot be modified by an application. + /// + Standard = 1, + + /// + /// Represents a sticker that was created within a guild. + /// + Guild = 2, + } +} diff --git a/src/Discord.Net.Rest/API/Common/Sticker.cs b/src/Discord.Net.Rest/API/Common/Sticker.cs index da171a802..490c16dbe 100644 --- a/src/Discord.Net.Rest/API/Common/Sticker.cs +++ b/src/Discord.Net.Rest/API/Common/Sticker.cs @@ -15,15 +15,17 @@ namespace Discord.API public string Desription { get; set; } [JsonProperty("tags")] public Optional Tags { get; set; } - [JsonProperty("asset")] - public string Asset { get; set; } - [JsonProperty("preview_asset")] - public string PreviewAsset { get; set; } + [JsonProperty("type")] + public StickerType Type { get; set; } [JsonProperty("format_type")] public StickerFormatType FormatType { get; set; } + [JsonProperty("available")] + public bool? Available { get; set; } [JsonProperty("guild_id")] public Optional GuildId { get; set; } [JsonProperty("user")] public Optional User { get; set; } + [JsonProperty("sort_value")] + public int? SortValue { get; set; } } } diff --git a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs index 0d6710a03..b8ee153c9 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateMessageParams.cs @@ -26,6 +26,10 @@ namespace Discord.API.Rest [JsonProperty("components")] public Optional Components { get; set; } + + [JsonProperty("sticker_ids")] + public Optional Stickers { get; set; } + public CreateMessageParams(string content) { Content = content; diff --git a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs index 31a975aab..1ee918ae7 100644 --- a/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs +++ b/src/Discord.Net.Rest/API/Rest/UploadFileParams.cs @@ -22,6 +22,7 @@ namespace Discord.API.Rest public Optional AllowedMentions { get; set; } public Optional MessageReference { get; set; } public Optional MessageComponent { get; set; } + public Optional Stickers { get; set; } public bool IsSpoiler { get; set; } = false; public UploadFileParams(Stream file) @@ -54,6 +55,8 @@ namespace Discord.API.Rest payload["hasSpoiler"] = IsSpoiler.ToString(); if (MessageReference.IsSpecified) payload["message_reference"] = MessageReference.Value; + if (Stickers.IsSpecified) + payload["sticker_ids"] = Stickers.Value; var json = new StringBuilder(); using (var text = new StringWriter(json)) diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index 4e2846c9e..43c2a05bc 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -1718,10 +1718,10 @@ must be lesser than 86400. - + 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 . @@ -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. @@ -1781,18 +1781,20 @@ 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 + 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. - + Sends a file to this message channel with an optional caption. This method follows the same behavior as described in - . Please visit + . Please visit its documentation for more details on this method. The file path of the file. @@ -1806,17 +1808,19 @@ 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 + 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. - + 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. @@ -1831,6 +1835,8 @@ 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 + 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. @@ -2010,11 +2016,11 @@ - + 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 @@ -2041,7 +2047,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 . @@ -2092,13 +2098,13 @@ - + - + - + @@ -2148,11 +2154,11 @@ - + 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 @@ -2179,7 +2185,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 . @@ -2438,11 +2444,11 @@ - + 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 @@ -2469,7 +2475,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 . @@ -2602,13 +2608,13 @@ - + - + - + @@ -3347,6 +3353,18 @@ The created voice channel. + + + Creates a new stage channel in this guild. + + The new name for the stage channel. + The delegate containing the properties to be applied to the channel upon its creation. + The options to be used when sending the request. + + A task that represents the asynchronous creation operation. The task result contains the newly created + stage channel. + + Creates a category channel with the provided name. @@ -3751,6 +3769,9 @@ + + + @@ -4472,10 +4493,13 @@ - + + + + - + diff --git a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs index 98715bfce..bf95cfa6d 100644 --- a/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs +++ b/src/Discord.Net.Rest/Entities/Channels/ChannelHelper.cs @@ -264,7 +264,7 @@ 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, RequestOptions options) + string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, RequestOptions options) { 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."); @@ -285,7 +285,12 @@ namespace Discord.Rest } } - 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 }; + if(stickers != null) + { + 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 model = await client.ApiClient.CreateMessageAsync(channel.Id, args, options).ConfigureAwait(false); return RestUserMessage.Create(client, channel, client.CurrentUser, model); } @@ -315,16 +320,16 @@ 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, RequestOptions options, bool isSpoiler) + string filePath, string text, bool isTTS, Embed embed, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component, ISticker[] stickers, RequestOptions options, bool isSpoiler) { string filename = Path.GetFileName(filePath); using (var file = File.OpenRead(filePath)) - return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions, messageReference, component, options, isSpoiler).ConfigureAwait(false); + return await SendFileAsync(channel, client, file, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler).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, 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) { 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."); @@ -345,7 +350,12 @@ namespace Discord.Rest } } - 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 }; + if (stickers != null) + { + 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 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 919360ce8..b7f494055 100644 --- a/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/IRestMessageChannel.cs @@ -25,17 +25,19 @@ 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 + /// 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. /// - new Task SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = 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); /// /// Sends a file to this message channel with an optional caption. /// /// /// This method follows the same behavior as described in - /// . Please visit + /// . Please visit /// its documentation for more details on this method. /// /// The file path of the file. @@ -49,16 +51,18 @@ 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 + /// 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. /// - 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); + 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); /// /// 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. @@ -73,11 +77,13 @@ 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 + /// 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. /// - 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); + 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); /// /// 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 7bfd73ee6..6fe2c862c 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestDMChannel.cs @@ -93,8 +93,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) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); /// /// @@ -121,12 +121,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) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// /// 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) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) @@ -204,14 +204,14 @@ 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) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component).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); //IChannel /// diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs index fb7a7a215..25d34cd0b 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestGroupChannel.cs @@ -99,8 +99,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) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); /// /// @@ -127,12 +127,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) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// /// 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) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers,options, isSpoiler); /// public Task TriggerTypingAsync(RequestOptions options = null) @@ -182,14 +182,14 @@ 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) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component).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); //IAudioChannel /// diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index 6343aed03..ffe989dbf 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -102,8 +102,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) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); /// /// @@ -130,13 +130,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) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// /// 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) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) @@ -315,15 +315,15 @@ 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) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component).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); //IGuildChannel /// diff --git a/src/Discord.Net.Rest/Entities/Messages/Sticker.cs b/src/Discord.Net.Rest/Entities/Messages/Sticker.cs index 6a5d35a3b..46dbc3418 100644 --- a/src/Discord.Net.Rest/Entities/Messages/Sticker.cs +++ b/src/Discord.Net.Rest/Entities/Messages/Sticker.cs @@ -10,19 +10,21 @@ namespace Discord.Rest public class Sticker : RestEntity, ISticker { /// - public ulong PackId { get; internal set; } + public ulong PackId { get; protected set; } /// - public string Name { get; internal set; } + public string Name { get; protected set; } /// - public string Description { get; internal set; } + public string Description { get; protected set; } /// - public IReadOnlyCollection Tags { get; internal set; } + public IReadOnlyCollection Tags { get; protected set; } /// - public string Asset { get; internal set; } + public StickerType Type { get; protected set; } /// - public string PreviewAsset { get; internal set; } + public bool? Available { get; protected set; } /// - public StickerFormatType Format { get; internal set; } + public int? SortOrder { get; protected set; } + /// + public StickerFormatType Format { get; protected set; } /// public string GetStickerUrl() @@ -43,8 +45,9 @@ namespace Discord.Rest Name = model.Name; Description = model.Desription; Tags = model.Tags.IsSpecified ? model.Tags.Value.Split(',').Select(x => x.Trim()).ToArray() : new string[0]; - Asset = model.Asset; - PreviewAsset = model.PreviewAsset; + Type = model.Type; + SortOrder = model.SortValue; + Available = model.Available; Format = model.FormatType; } diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index 6c83a737a..610555b61 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -1480,12 +1480,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. @@ -1498,17 +1498,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 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 file path of the file. @@ -1523,17 +1524,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 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. @@ -1549,6 +1551,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 task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. @@ -1831,14 +1834,14 @@ - + Message content is too long, length must be less or equal to . - + - + Message content is too long, length must be less or equal to . @@ -1901,13 +1904,13 @@ - + - + - + @@ -2022,15 +2025,16 @@ - + Message content is too long, length must be less or equal to . - + - + + Message content is too long, length must be less or equal to . @@ -2088,13 +2092,13 @@ - + - + - + @@ -2478,14 +2482,14 @@ - + Message content is too long, length must be less or equal to . - + - + Message content is too long, length must be less or equal to . @@ -2591,13 +2595,13 @@ - + - + - + @@ -3328,6 +3332,18 @@ voice channel. + + + Creates a new stage channel in this guild. + + The new name for the stage channel. + The delegate containing the properties to be applied to the channel upon its creation. + The options to be used when sending the request. + + A task that represents the asynchronous creation operation. The task result contains the newly created + stage channel. + + Creates a new channel category in this guild. @@ -3746,6 +3762,9 @@ + + + @@ -3947,7 +3966,7 @@ - The value(s) of a interaction response. + The value(s) of a interaction response. @@ -4252,14 +4271,6 @@ The request options for this async request. A that represents the initial response. - - - Acknowledges this interaction. - - - A task that represents the asynchronous operation of acknowledging the interaction. - - Acknowledges this interaction. @@ -4805,7 +4816,7 @@ - Gets the guild the sticker lives in. + Gets the guild the sticker was created in. @@ -4834,13 +4845,16 @@ - + - + - + + + + @@ -4854,9 +4868,6 @@ Represents an unknown sticker received over the gateway. - - - @@ -4866,7 +4877,13 @@ - + + + + + + + diff --git a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs index fb25ddbd7..7a82b2c3f 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/ISocketMessageChannel.cs @@ -35,16 +35,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 message. /// /// 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); + 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); /// /// 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. @@ -59,16 +60,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 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); + 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); /// /// 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. @@ -84,11 +86,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 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); + 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); /// /// 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 fd3fd1002..27e720669 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketDMChannel.cs @@ -137,16 +137,16 @@ 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) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); /// - 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) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// /// 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) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// public Task DeleteMessageAsync(ulong messageId, RequestOptions options = null) => ChannelHelper.DeleteMessageAsync(this, messageId, Discord, options); @@ -238,14 +238,14 @@ 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) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component).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); //IChannel /// diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs index c7adc994e..a97806be8 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketGroupChannel.cs @@ -171,15 +171,16 @@ 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) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); /// - 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) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, filePath, 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) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, options, isSpoiler); + /// 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 DeleteMessageAsync(ulong messageId, RequestOptions options = null) @@ -305,14 +306,14 @@ 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) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component).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); //IAudioChannel /// diff --git a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs index a0d14fdab..0bc62168f 100644 --- a/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs +++ b/src/Discord.Net.WebSocket/Entities/Channels/SocketTextChannel.cs @@ -209,17 +209,17 @@ 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) - => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendMessageAsync(this, Discord, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options); /// - 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) - => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, filePath, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// /// 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) - => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, 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) + => ChannelHelper.SendFileAsync(this, Discord, stream, filename, text, isTTS, embed, allowedMentions, messageReference, component, stickers, options, isSpoiler); /// public Task DeleteMessagesAsync(IEnumerable messages, RequestOptions options = null) @@ -363,14 +363,14 @@ 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) - => await SendFileAsync(filePath, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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(Stream stream, string filename, string text, bool isTTS, Embed embed, RequestOptions options, bool isSpoiler, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendFileAsync(stream, filename, text, isTTS, embed, options, isSpoiler, allowedMentions, messageReference, component).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.SendMessageAsync(string text, bool isTTS, Embed embed, RequestOptions options, AllowedMentions allowedMentions, MessageReference messageReference, MessageComponent component) - => await SendMessageAsync(text, isTTS, embed, options, allowedMentions, messageReference, component).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); // INestedChannel /// diff --git a/src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs b/src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs index b9c10f4c2..e7bff2ff0 100644 --- a/src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs +++ b/src/Discord.Net.WebSocket/Entities/Stickers/SocketCustomSticker.cs @@ -29,7 +29,7 @@ namespace Discord.WebSocket => this.AuthorId.HasValue ? Guild.GetUser(this.AuthorId.Value) : null; /// - /// Gets the guild the sticker lives in. + /// Gets the guild the sticker was created in. /// public SocketGuild Guild { get; } diff --git a/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs b/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs index ce0d3f4fa..eaf80f9c2 100644 --- a/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs +++ b/src/Discord.Net.WebSocket/Entities/Stickers/SocketSticker.cs @@ -20,7 +20,7 @@ namespace Discord.WebSocket public virtual ulong PackId { get; private set; } /// - public string Name { get; internal set; } + public string Name { get; protected set; } /// public virtual string Description { get; private set; } @@ -29,13 +29,16 @@ namespace Discord.WebSocket public virtual IReadOnlyCollection Tags { get; private set; } /// - public virtual string Asset { get; private set; } + public virtual StickerType Type { get; private set; } /// - public virtual string PreviewAsset { get; private set; } + public StickerFormatType Format { get; protected set; } /// - public StickerFormatType Format { get; internal set; } + public virtual bool? Available { get; protected set; } + + /// + public virtual int? SortOrder { get; private set; } /// public string GetStickerUrl() @@ -62,9 +65,10 @@ namespace Discord.WebSocket this.Name = model.Name; this.Description = model.Desription; this.PackId = model.PackId; - this.Asset = model.Asset; - this.PreviewAsset = model.PreviewAsset; + this.Available = model.Available; this.Format = model.FormatType; + this.Type = model.Type; + this.SortOrder = model.SortValue; if (model.Tags.IsSpecified) { @@ -88,8 +92,9 @@ namespace Discord.WebSocket stickerModel.FormatType == this.Format && stickerModel.Id == this.Id && stickerModel.PackId == this.PackId && - stickerModel.Asset == this.Asset && - stickerModel.PreviewAsset == this.PreviewAsset && + stickerModel.Type == this.Type && + stickerModel.SortValue == this.SortOrder && + stickerModel.Available == this.Available && (stickerModel.Tags.IsSpecified ? stickerModel.Tags.Value == string.Join(", ", this.Tags) : true); diff --git a/src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs b/src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs index 771a4c413..da8199c4c 100644 --- a/src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs +++ b/src/Discord.Net.WebSocket/Entities/Stickers/SocketUnknownSticker.cs @@ -14,10 +14,6 @@ namespace Discord.WebSocket [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class SocketUnknownSticker : SocketSticker { - /// - public override string Asset - => null; - /// public override IReadOnlyCollection Tags => null; @@ -29,9 +25,16 @@ namespace Discord.WebSocket /// public override ulong PackId => 0; + /// + public override bool? Available + => null; + + /// + public override int? SortOrder + => null; /// - public override string PreviewAsset + public new StickerType? Type => null; internal SocketUnknownSticker(DiscordSocketClient client, ulong id) @@ -59,6 +62,6 @@ namespace Discord.WebSocket public Task ResolveAsync(CacheMode mode = CacheMode.AllowDownload, RequestOptions options = null) => Discord.GetStickerAsync(this.Id, mode, options); - private string DebuggerDisplay => $"{Name} ({Id})"; + private new string DebuggerDisplay => $"{Name} ({Id})"; } } diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs index 2cc46d3d3..52eed6bc9 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedDMChannel.cs @@ -78,24 +78,13 @@ 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) - { - 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) - { - 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) - { - throw new NotImplementedException(); - } - public Task TriggerTypingAsync(RequestOptions options = 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) => 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 e124bc923..bc4f66ed4 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedGroupChannel.cs @@ -86,17 +86,17 @@ 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) + 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) + 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 SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = 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) { throw new NotImplementedException(); } diff --git a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs index 18ff3b3ed..fc39a2b07 100644 --- a/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs +++ b/test/Discord.Net.Tests.Unit/MockedEntities/MockedTextChannel.cs @@ -176,17 +176,17 @@ 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) + 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) + 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 SendMessageAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent component = 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) { throw new NotImplementedException(); } From 057ad644edd79dd8d3e3b6d347a256c339af9b99 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Mon, 20 Sep 2021 03:45:07 -0300 Subject: [PATCH 05/14] Fix CDN format for sticker --- src/Discord.Net.Core/CDN.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Discord.Net.Core/CDN.cs b/src/Discord.Net.Core/CDN.cs index 1e8fd624d..a744c93fe 100644 --- a/src/Discord.Net.Core/CDN.cs +++ b/src/Discord.Net.Core/CDN.cs @@ -194,11 +194,10 @@ namespace Discord { 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"; - case StickerFormatType.Apng: - return "apng"; default: throw new ArgumentException(nameof(format)); From 428e8f57abccf9055b369a683d17f4db068b4c07 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Mon, 20 Sep 2021 04:25:06 -0300 Subject: [PATCH 06/14] Remove unused model --- .../API/Common/InteractionFollowupMessage.cs | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 src/Discord.Net.Rest/API/Common/InteractionFollowupMessage.cs diff --git a/src/Discord.Net.Rest/API/Common/InteractionFollowupMessage.cs b/src/Discord.Net.Rest/API/Common/InteractionFollowupMessage.cs deleted file mode 100644 index 28de67ee6..000000000 --- a/src/Discord.Net.Rest/API/Common/InteractionFollowupMessage.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Discord.API -{ - internal class InteractionFollowupMessage - { - public string Content { get; set; } - public Optional Username { get; set; } - public Optional AvatarUrl { get; set; } - public Optional TTS { get; set; } - public Optional File { get; set; } - public Embed[] Embeds { get; set; } - - } -} From 6ab38537febaf82c38f850fdcf65809a9199c2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Tue, 21 Sep 2021 10:59:31 +0200 Subject: [PATCH 07/14] Move and disconnect (#165) * Changed comments to regions * More regions * regions * Added DisconnectAsync and MoveAsync --- .../Entities/Guilds/IGuild.cs | 15 ++++++ .../Entities/Guilds/RestGuild.cs | 24 +++++++-- .../Entities/Guilds/SocketGuild.cs | 54 ++++++++++++++----- 3 files changed, 76 insertions(+), 17 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs index 76ff9eb4f..87c313700 100644 --- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs +++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs @@ -771,6 +771,12 @@ namespace Discord /// A guild user associated with the specified ; if the user is already in the guild. Task AddGuildUserAsync(ulong userId, string accessToken, Action func = null, RequestOptions options = null); /// + /// Disconnects the user from its current voice channel + /// + /// The user to disconnect. + /// A task that represents the asynchronous operation for disconnecting a user. + Task DisconnectAsync(IGuildUser user); + /// /// Gets a collection of all users in this guild. /// /// @@ -951,6 +957,15 @@ namespace Discord /// emote. /// Task ModifyEmoteAsync(GuildEmote emote, Action func, RequestOptions options = null); + + /// + /// Moves the user to the voice channel. + /// + /// The user to move. + /// the channel where the user gets moved to. + /// A task that represents the asynchronous operation for moving a user. + Task MoveAsync(IGuildUser user, IVoiceChannel targetChannel); + /// /// Deletes an existing from this guild. /// diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index 3608c2d8b..d566afc81 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -962,7 +962,7 @@ namespace Discord.Rest public override string ToString() => Name; private string DebuggerDisplay => $"{Name} ({Id})"; - //Emotes + #region Emotes /// public Task> GetEmotesAsync(RequestOptions options = null) => GuildHelper.GetEmotesAsync(this, Discord, options); @@ -976,11 +976,20 @@ namespace Discord.Rest /// is . public Task ModifyEmoteAsync(GuildEmote emote, Action func, RequestOptions options = null) => GuildHelper.ModifyEmoteAsync(this, Discord, emote.Id, func, options); + /// + /// Moves the user to the voice channel. + /// + /// The user to move. + /// the channel where the user gets moved to. + /// A task that represents the asynchronous operation for moving a user. + public Task MoveAsync(IGuildUser user, IVoiceChannel targetChannel) + => user.ModifyAsync(x => x.Channel = new Optional(targetChannel)); /// public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) => GuildHelper.DeleteEmoteAsync(this, Discord, emote.Id, options); + #endregion - //Stickers + #region Stickers /// /// Creates a new sticker in this guild. /// @@ -1087,8 +1096,9 @@ namespace Discord.Rest /// public Task DeleteStickerAsync(CustomSticker sticker, RequestOptions options = null) => sticker.DeleteAsync(options); + #endregion - //IGuild + #region IGuild /// bool IGuild.Available => Available; /// @@ -1291,6 +1301,13 @@ namespace Discord.Rest async Task IGuild.AddGuildUserAsync(ulong userId, string accessToken, Action func, RequestOptions options) => await AddGuildUserAsync(userId, accessToken, func, options); + /// + /// Disconnects the user from its current voice channel + /// + /// The user to disconnect. + /// A task that represents the asynchronous operation for disconnecting a user. + async Task IGuild.DisconnectAsync(IGuildUser user) => await user.ModifyAsync(x => x.Channel = new Optional()); + /// async Task IGuild.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) { @@ -1399,5 +1416,6 @@ namespace Discord.Rest else return null; } + #endregion } } diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs index 0c211f394..1cdefcdb7 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs @@ -572,7 +572,7 @@ namespace Discord.WebSocket _emotes = emotes.ToImmutable(); } - //General + #region General /// public Task DeleteAsync(RequestOptions options = null) => GuildHelper.DeleteAsync(this, Discord, options); @@ -596,8 +596,9 @@ namespace Discord.WebSocket /// public Task LeaveAsync(RequestOptions options = null) => GuildHelper.LeaveAsync(this, Discord, options); + #endregion - //Bans + #region Bans /// /// Gets a collection of all users banned in this guild. /// @@ -645,8 +646,9 @@ namespace Discord.WebSocket /// public Task RemoveBanAsync(ulong userId, RequestOptions options = null) => GuildHelper.RemoveBanAsync(this, Discord, userId, options); + #endregion - //Channels + #region Channels /// /// Gets a channel in this guild. /// @@ -807,8 +809,9 @@ namespace Discord.WebSocket _channels.Clear(); } + #endregion - //Voice Regions + #region Voice Regions /// /// Gets a collection of all the voice regions this guild can access. /// @@ -819,14 +822,16 @@ namespace Discord.WebSocket /// public Task> GetVoiceRegionsAsync(RequestOptions options = null) => GuildHelper.GetVoiceRegionsAsync(this, Discord, options); + #endregion - //Integrations + #region Integrations public Task> GetIntegrationsAsync(RequestOptions options = null) => GuildHelper.GetIntegrationsAsync(this, Discord, options); public Task CreateIntegrationAsync(ulong id, string type, RequestOptions options = null) => GuildHelper.CreateIntegrationAsync(this, Discord, id, type, options); + #endregion - //Interactions + #region Interactions /// /// Deletes all application commands in the current guild. /// @@ -932,8 +937,9 @@ namespace Discord.WebSocket return entities.ToImmutableArray(); } + #endregion - //Invites + #region Invites /// /// Gets a collection of all invites in this guild. /// @@ -1040,8 +1046,9 @@ namespace Discord.WebSocket return sticker; return null; } + #endregion - //Users + #region Users /// public Task AddGuildUserAsync(ulong id, string accessToken, Action func = null, RequestOptions options = null) => GuildHelper.AddGuildUserAsync(this, Discord, id, accessToken, func, options); @@ -1240,7 +1247,24 @@ namespace Discord.WebSocket public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) => GuildHelper.DeleteEmoteAsync(this, Discord, emote.Id, options); - //Stickers + /// + /// Moves the user to the voice channel. + /// + /// The user to move. + /// the channel where the user gets moved to. + /// A task that represents the asynchronous operation for moving a user. + public Task MoveAsync(IGuildUser user, IVoiceChannel targetChannel) + => user.ModifyAsync(x => x.Channel = new Optional(targetChannel)); + + /// + /// Disconnects the user from its current voice channel + /// + /// The user to disconnect. + /// A task that represents the asynchronous operation for disconnecting a user. + async Task IGuild.DisconnectAsync(IGuildUser user) => await user.ModifyAsync(x => x.Channel = new Optional()); + #endregion + + #region Stickers /// /// Gets a specific sticker within this guild. /// @@ -1368,8 +1392,9 @@ namespace Discord.WebSocket /// public Task DeleteStickerAsync(SocketCustomSticker sticker, RequestOptions options = null) => sticker.DeleteAsync(options); + #endregion - //Voice States + #region Voice States internal async Task AddOrUpdateVoiceStateAsync(ClientState state, VoiceStateModel model) { var voiceChannel = state.GetChannel(model.ChannelId.Value) as SocketVoiceChannel; @@ -1413,8 +1438,9 @@ namespace Discord.WebSocket } return null; } + #endregion - //Audio + #region Audio internal AudioInStream GetAudioStream(ulong userId) { return _audioClient?.GetInputStream(userId); @@ -1568,8 +1594,9 @@ namespace Discord.WebSocket public override string ToString() => Name; private string DebuggerDisplay => $"{Name} ({Id})"; internal SocketGuild Clone() => MemberwiseClone() as SocketGuild; + #endregion - //IGuild + #region IGuild /// ulong? IGuild.AFKChannelId => AFKChannelId; /// @@ -1781,7 +1808,6 @@ namespace Discord.WebSocket _audioLock?.Dispose(); _audioClient?.Dispose(); } - - + #endregion } } From 75179e2b267361ebaa4f05213a1f8db13bb0e693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Tue, 21 Sep 2021 10:59:44 +0200 Subject: [PATCH 08/14] Fixed Placement of Obsolete (#164) Missing XML comment for publicly visible type or member 'InteractionResponseType.Acknowledge' --- .../Entities/Interactions/InteractionResponseType.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Interactions/InteractionResponseType.cs b/src/Discord.Net.Core/Entities/Interactions/InteractionResponseType.cs index 1b103f491..d34c282ef 100644 --- a/src/Discord.Net.Core/Entities/Interactions/InteractionResponseType.cs +++ b/src/Discord.Net.Core/Entities/Interactions/InteractionResponseType.cs @@ -22,16 +22,16 @@ namespace Discord /// Pong = 1, - [Obsolete("This response type has been depricated by discord. Either use ChannelMessageWithSource or DeferredChannelMessageWithSource", true)] /// /// ACK a command without sending a message, eating the user's input. /// + [Obsolete("This response type has been depricated by discord. Either use ChannelMessageWithSource or DeferredChannelMessageWithSource", true)] Acknowledge = 2, - [Obsolete("This response type has been depricated by discord. Either use ChannelMessageWithSource or DeferredChannelMessageWithSource", true)] /// /// Respond with a message, showing the user's input. /// + [Obsolete("This response type has been depricated by discord. Either use ChannelMessageWithSource or DeferredChannelMessageWithSource", true)] ChannelMessage = 3, /// From 0d811601b73f10e88b119622555d5812bd8ec383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Tue, 21 Sep 2021 11:00:04 +0200 Subject: [PATCH 09/14] Added warning for Select Menu duplicates values (#163) Added a warning if it happens that the Select Menu if there is duplicates values --- .../Interactions/Message Components/ComponentBuilder.cs | 2 ++ 1 file changed, 2 insertions(+) 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 07cc0b6ab..a174dcd54 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs @@ -124,6 +124,8 @@ namespace Discord public ComponentBuilder WithSelectMenu(SelectMenuBuilder menu, int row = 0) { Preconditions.LessThan(row, MaxActionRowCount, nameof(row)); + if (menu.Options.Distinct().Count() != menu.Options.Count()) + throw new InvalidOperationException("Please make sure that there is no duplicates values."); var builtMenu = menu.Build(); From 535df436778838af23e283e0bc9da0762005efd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Tue, 21 Sep 2021 13:43:05 +0200 Subject: [PATCH 10/14] More argument corrections (#166) * Changed and corrected the MaxCustomIdLength to MaxSelectValueLength * Added more error messages for users. * added too * corrected MaxLabelLength to MaxButtonLabelLength * Added more detailed error messages --- .../Message Components/ComponentBuilder.cs | 101 +++++++++++++----- 1 file changed, 76 insertions(+), 25 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 a174dcd54..5dcf8f22c 100644 --- a/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs +++ b/src/Discord.Net.Core/Entities/Interactions/Message Components/ComponentBuilder.cs @@ -10,11 +10,6 @@ namespace Discord /// public class ComponentBuilder { - /// - /// The max length of a . - /// - public const int MaxButtonLabelLength = 80; - /// /// The max length of a . /// @@ -353,19 +348,27 @@ namespace Discord /// /// The max length of a . /// - public const int MaxLabelLength = 80; + public const int MaxButtonLabelLength = 80; /// /// Gets or sets the label of the current button. /// - /// length exceeds . + /// length exceeds . + /// length exceeds . public string Label { get => _label; set { - if (value != null && value.Length > ComponentBuilder.MaxButtonLabelLength) - throw new ArgumentException(message: $"Button label must be {ComponentBuilder.MaxButtonLabelLength} characters or less!", paramName: nameof(Label)); + if (value != null) + { + if (value.Length > MaxButtonLabelLength) + throw new ArgumentException($"Button label must be {MaxButtonLabelLength} characters or less!", paramName: nameof(Label)); + if (value.Length < 1) + throw new ArgumentException("Button label must be 1 character or more!", paramName: nameof(Label)); + } + else + throw new ArgumentException("Button label must not be null or empty!", paramName: nameof(Label)); _label = value; } @@ -375,13 +378,21 @@ namespace Discord /// Gets or sets the custom id of the current button. /// /// length exceeds + /// length subceeds 1. public string CustomId { get => _customId; set { - if (value != null && value.Length > ComponentBuilder.MaxCustomIdLength) - throw new ArgumentException(message: $"Custom Id must be {ComponentBuilder.MaxCustomIdLength} characters or less!", paramName: nameof(CustomId)); + if (value != null) + { + if (value.Length > ComponentBuilder.MaxCustomIdLength) + throw new ArgumentException($"Custom Id must be {ComponentBuilder.MaxCustomIdLength} characters or less!", paramName: nameof(CustomId)); + if (value.Length < 1) + throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId)); + } + else + throw new ArgumentException("Custom Id must not be null or empty!", paramName: nameof(CustomId)); _customId = value; } } @@ -619,14 +630,22 @@ namespace Discord /// /// Gets or sets the custom id of the current select menu. /// - /// length exceeds . + /// length exceeds + /// length subceeds 1. public string CustomId { get => _customId; set { - if (value != null && value.Length > ComponentBuilder.MaxCustomIdLength) - throw new ArgumentException(message: $"Custom Id must be {ComponentBuilder.MaxCustomIdLength} characters or less!", paramName: nameof(CustomId)); + if (value != null) + { + if (value.Length > ComponentBuilder.MaxCustomIdLength) + throw new ArgumentException($"Custom Id must be {ComponentBuilder.MaxCustomIdLength} characters or less!", paramName: nameof(CustomId)); + if (value.Length < 1) + throw new ArgumentException("Custom Id must be 1 character or more!", paramName: nameof(CustomId)); + } + else + throw new ArgumentException("Custom Id must not be null or empty!", paramName: nameof(CustomId)); _customId = value; } } @@ -635,13 +654,21 @@ namespace Discord /// Gets or sets the placeholder text of the current select menu. /// /// length exceeds . + /// length subceeds 1. public string Placeholder { get => _placeholder; set { - if (value?.Length > MaxPlaceholderLength) - throw new ArgumentException(message: $"Placeholder must be {MaxPlaceholderLength} characters or less!", paramName: nameof(Placeholder)); + if (value != null) + { + if (value.Length > MaxPlaceholderLength) + throw new ArgumentException($"The placeholder must be {MaxPlaceholderLength} characters or less!", paramName: nameof(Placeholder)); + if (value.Length < 1) + throw new ArgumentException("The placeholder must be 1 character or more!", paramName: nameof(Placeholder)); + } + else + throw new ArgumentException("The placeholder must not be null or empty!", paramName: nameof(Placeholder)); _placeholder = value; } @@ -882,7 +909,7 @@ namespace Discord /// /// The maximum length of a . /// - public const int MaxLabelLength = 100; + public const int MaxSelectLabelLength = 100; /// /// The maximum length of a . @@ -890,22 +917,29 @@ namespace Discord public const int MaxDescriptionLength = 100; /// - /// The maximum length of a . + /// The maximum length of a . /// - public const int MaxSelectLabelLength = 100; + public const int MaxSelectValueLength = 100; /// /// Gets or sets the label of the current select menu. /// /// length exceeds + /// length subceeds 1. public string Label { get => _label; set { if (value != null) + { if (value.Length > MaxSelectLabelLength) - throw new ArgumentException(message: $"Button label must be {MaxSelectLabelLength} characters or less!", paramName: nameof(Label)); + throw new ArgumentException($"Select option label must be {MaxSelectLabelLength} characters or less!", paramName: nameof(Label)); + if (value.Length < 1) + throw new ArgumentException("Select option label must be 1 character or more!", paramName: nameof(Label)); + } + else + throw new ArgumentException("Select option label must not be null or empty!", paramName: nameof(Label)); _label = value; } @@ -914,14 +948,23 @@ namespace Discord /// /// Gets or sets the custom id of the current select menu. /// - /// length exceeds . + /// length exceeds . + /// length subceeds 1. public string Value { get => _value; set { - if (value != null && value.Length > ComponentBuilder.MaxCustomIdLength) - throw new ArgumentException(message: $"Value must be {ComponentBuilder.MaxCustomIdLength} characters or less!", paramName: nameof(Value)); + if (value != null) + { + if (value.Length > MaxSelectValueLength) + throw new ArgumentException($"Select option value must be {MaxSelectValueLength} characters or less!", paramName: nameof(Label)); + if (value.Length < 1) + throw new ArgumentException("Select option value must be 1 character or more!", paramName: nameof(Label)); + } + else + throw new ArgumentException("Select option value must not be null or empty!", paramName: nameof(Label)); + _value = value; } } @@ -930,13 +973,21 @@ namespace Discord /// Gets or sets this menu options description. /// /// length exceeds . + /// length subceeds 1. public string Description { get => _description; set { - if (value != null && value.Length > MaxDescriptionLength) - throw new ArgumentException($"Description must be {MaxDescriptionLength} characters or less!", nameof(Description)); + if (value != null) + { + if (value.Length > MaxDescriptionLength) + throw new ArgumentException($"The description must be {MaxDescriptionLength} characters or less!", paramName: nameof(Label)); + if (value.Length < 1) + throw new ArgumentException("The description must be 1 character or more!", paramName: nameof(Label)); + } + else + throw new ArgumentException("The description must not be null or empty!", paramName: nameof(Label)); _description = value; } From 97e9a4fc81410ec0c46f86f97f935932a9659ba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Tue, 21 Sep 2021 14:41:48 +0200 Subject: [PATCH 11/14] Regions discord.net.commands (#167) * RestGuildChannel regions * RestChannel * RestTextChannel * RestCategoryChannel * RestVoiceChannel * RestTextChannel * CommandService * ModuleBase * CommandBuilder * ModuleBuilder * ParameterBuilder --- .../Builders/CommandBuilder.cs | 11 +++++++--- .../Builders/ModuleBuilder.cs | 9 +++++++-- .../Builders/ParameterBuilder.cs | 9 +++++++-- src/Discord.Net.Commands/CommandService.cs | 13 +++++++++--- src/Discord.Net.Commands/ModuleBase.cs | 5 ++++- .../Entities/Channels/RestCategoryChannel.cs | 5 ++++- .../Entities/Channels/RestChannel.cs | 5 ++++- .../Entities/Channels/RestGuildChannel.cs | 8 ++++++-- .../Entities/Channels/RestTextChannel.cs | 20 +++++++++++++------ .../Entities/Channels/RestVoiceChannel.cs | 14 +++++++++---- 10 files changed, 74 insertions(+), 25 deletions(-) diff --git a/src/Discord.Net.Commands/Builders/CommandBuilder.cs b/src/Discord.Net.Commands/Builders/CommandBuilder.cs index 3f1ca883a..1d946a33d 100644 --- a/src/Discord.Net.Commands/Builders/CommandBuilder.cs +++ b/src/Discord.Net.Commands/Builders/CommandBuilder.cs @@ -7,6 +7,7 @@ namespace Discord.Commands.Builders { public class CommandBuilder { + #region CommandBuilder private readonly List _preconditions; private readonly List _parameters; private readonly List _attributes; @@ -27,8 +28,9 @@ namespace Discord.Commands.Builders public IReadOnlyList Parameters => _parameters; public IReadOnlyList Attributes => _attributes; public IReadOnlyList Aliases => _aliases; + #endregion - //Automatic + #region Automatic internal CommandBuilder(ModuleBuilder module) { Module = module; @@ -38,7 +40,9 @@ namespace Discord.Commands.Builders _attributes = new List(); _aliases = new List(); } - //User-defined + #endregion + + #region User-defined internal CommandBuilder(ModuleBuilder module, string primaryAlias, Func callback) : this(module) { @@ -132,7 +136,7 @@ namespace Discord.Commands.Builders var firstMultipleParam = _parameters.FirstOrDefault(x => x.IsMultiple); if ((firstMultipleParam != null) && (firstMultipleParam != lastParam)) throw new InvalidOperationException($"Only the last parameter in a command may have the Multiple flag. Parameter: {firstMultipleParam.Name} in {PrimaryAlias}"); - + var firstRemainderParam = _parameters.FirstOrDefault(x => x.IsRemainder); if ((firstRemainderParam != null) && (firstRemainderParam != lastParam)) throw new InvalidOperationException($"Only the last parameter in a command may have the Remainder flag. Parameter: {firstRemainderParam.Name} in {PrimaryAlias}"); @@ -140,5 +144,6 @@ namespace Discord.Commands.Builders return new CommandInfo(this, info, service); } + #endregion } } diff --git a/src/Discord.Net.Commands/Builders/ModuleBuilder.cs b/src/Discord.Net.Commands/Builders/ModuleBuilder.cs index 6dc50db31..ddb62e797 100644 --- a/src/Discord.Net.Commands/Builders/ModuleBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ModuleBuilder.cs @@ -7,6 +7,7 @@ namespace Discord.Commands.Builders { public class ModuleBuilder { + #region ModuleBuilder private readonly List _commands; private readonly List _submodules; private readonly List _preconditions; @@ -27,8 +28,9 @@ namespace Discord.Commands.Builders public IReadOnlyList Aliases => _aliases; internal TypeInfo TypeInfo { get; set; } + #endregion - //Automatic + #region Automatic internal ModuleBuilder(CommandService service, ModuleBuilder parent) { Service = service; @@ -40,7 +42,9 @@ namespace Discord.Commands.Builders _attributes = new List(); _aliases = new List(); } - //User-defined + #endregion + + #region User-defined internal ModuleBuilder(CommandService service, ModuleBuilder parent, string primaryAlias) : this(service, parent) { @@ -132,5 +136,6 @@ namespace Discord.Commands.Builders public ModuleInfo Build(CommandService service, IServiceProvider services) => BuildImpl(service, services); internal ModuleInfo Build(CommandService service, IServiceProvider services, ModuleInfo parent) => BuildImpl(service, services, parent); + #endregion } } diff --git a/src/Discord.Net.Commands/Builders/ParameterBuilder.cs b/src/Discord.Net.Commands/Builders/ParameterBuilder.cs index 4ad5bfac0..7f827a27e 100644 --- a/src/Discord.Net.Commands/Builders/ParameterBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ParameterBuilder.cs @@ -8,6 +8,7 @@ namespace Discord.Commands.Builders { public class ParameterBuilder { + #region ParameterBuilder private readonly List _preconditions; private readonly List _attributes; @@ -24,8 +25,9 @@ namespace Discord.Commands.Builders public IReadOnlyList Preconditions => _preconditions; public IReadOnlyList Attributes => _attributes; +#endregion - //Automatic + #region Automatic internal ParameterBuilder(CommandBuilder command) { _preconditions = new List(); @@ -33,7 +35,9 @@ namespace Discord.Commands.Builders Command = command; } - //User-defined + #endregion + + #region User-defined internal ParameterBuilder(CommandBuilder command, string name, Type type) : this(command) { @@ -132,5 +136,6 @@ namespace Discord.Commands.Builders return new ParameterInfo(this, info, Command.Module.Service); } + #endregion } } diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index 8659b0130..f897f822a 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -29,6 +29,7 @@ namespace Discord.Commands /// public class CommandService : IDisposable { + #region CommandService /// /// Occurs when a command-related information is received. /// @@ -131,8 +132,9 @@ namespace Discord.Commands entityTypeReaders.Add((typeof(IUser), typeof(UserTypeReader<>))); _entityTypeReaders = entityTypeReaders.ToImmutable(); } + #endregion - //Modules + #region Modules public async Task CreateModuleAsync(string primaryAlias, Action buildFunc) { await _moduleLock.WaitAsync().ConfigureAwait(false); @@ -322,8 +324,9 @@ namespace Discord.Commands return true; } + #endregion - //Type Readers + #region Type Readers /// /// Adds a custom to this for the supplied object /// type. @@ -448,8 +451,9 @@ namespace Discord.Commands } return null; } + #endregion - //Execution + #region Execution /// /// Searches for the command. /// @@ -602,7 +606,9 @@ namespace Discord.Commands await _commandExecutedEvent.InvokeAsync(chosenOverload.Key.Command, context, result); return result; } + #endregion + #region Dispose protected virtual void Dispose(bool disposing) { if (!_isDisposed) @@ -620,5 +626,6 @@ namespace Discord.Commands { Dispose(true); } + #endregion } } diff --git a/src/Discord.Net.Commands/ModuleBase.cs b/src/Discord.Net.Commands/ModuleBase.cs index 159b44fb8..5f470b7b6 100644 --- a/src/Discord.Net.Commands/ModuleBase.cs +++ b/src/Discord.Net.Commands/ModuleBase.cs @@ -16,6 +16,7 @@ namespace Discord.Commands public abstract class ModuleBase : IModuleBase where T : class, ICommandContext { + #region ModuleBase /// /// The underlying context of the command. /// @@ -65,8 +66,9 @@ namespace Discord.Commands protected virtual void OnModuleBuilding(CommandService commandService, ModuleBuilder builder) { } + #endregion - //IModuleBase + #region IModuleBase void IModuleBase.SetContext(ICommandContext context) { var newValue = context as T; @@ -75,5 +77,6 @@ namespace Discord.Commands void IModuleBase.BeforeExecute(CommandInfo command) => BeforeExecute(command); void IModuleBase.AfterExecute(CommandInfo command) => AfterExecute(command); void IModuleBase.OnModuleBuilding(CommandService commandService, ModuleBuilder builder) => OnModuleBuilding(commandService, builder); + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestCategoryChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestCategoryChannel.cs index 177bde21d..9f944501b 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestCategoryChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestCategoryChannel.cs @@ -12,6 +12,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestCategoryChannel : RestGuildChannel, ICategoryChannel { + #region RestCategoryChannel internal RestCategoryChannel(BaseDiscordClient discord, IGuild guild, ulong id) : base(discord, guild, id) { @@ -24,8 +25,9 @@ namespace Discord.Rest } private string DebuggerDisplay => $"{Name} ({Id}, Category)"; + #endregion - //IChannel + #region IChannel /// /// This method is not supported with category channels. IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) @@ -34,5 +36,6 @@ namespace Discord.Rest /// This method is not supported with category channels. Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) => throw new NotSupportedException(); + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs index 6f6a1f0d3..b653a2db4 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestChannel.cs @@ -11,6 +11,7 @@ namespace Discord.Rest /// public class RestChannel : RestEntity, IChannel, IUpdateable { + #region RestChannel /// public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id); @@ -53,8 +54,9 @@ namespace Discord.Rest /// public virtual Task UpdateAsync(RequestOptions options = null) => Task.Delay(0); + #endregion - //IChannel + #region IChannel /// string IChannel.Name => null; @@ -64,5 +66,6 @@ namespace Discord.Rest /// IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) => AsyncEnumerable.Empty>(); //Overridden + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs index f0150aeb2..549a4ba31 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestGuildChannel.cs @@ -12,6 +12,7 @@ namespace Discord.Rest /// public class RestGuildChannel : RestChannel, IGuildChannel { + #region RestGuildChannel private ImmutableArray _overwrites; /// @@ -191,8 +192,9 @@ namespace Discord.Rest /// A string that is the name of this channel. /// public override string ToString() => Name; + #endregion - //IGuildChannel + #region IGuildChannel /// IGuild IGuildChannel.Guild { @@ -229,13 +231,15 @@ namespace Discord.Rest /// Task IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) => Task.FromResult(null); //Overridden in Text/Voice + #endregion - //IChannel + #region IChannel /// IAsyncEnumerable> IChannel.GetUsersAsync(CacheMode mode, RequestOptions options) => AsyncEnumerable.Empty>(); //Overridden in Text/Voice /// Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) => Task.FromResult(null); //Overridden in Text/Voice + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs index ffe989dbf..ffd21afa5 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestTextChannel.cs @@ -14,6 +14,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestTextChannel : RestGuildChannel, IRestMessageChannel, ITextChannel { + #region RestTextChannel /// public string Topic { get; private set; } /// @@ -210,8 +211,9 @@ namespace Discord.Rest /// public Task SyncPermissionsAsync(RequestOptions options = null) => ChannelHelper.SyncPermissionsAsync(this, Discord, options); + #endregion - //Invites + #region Invites /// public virtual async Task CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); @@ -261,8 +263,9 @@ namespace Discord.Rest var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, options); return RestThreadChannel.Create(Discord, this.Guild, model); } + #endregion - //ITextChannel + #region ITextChannel /// async Task ITextChannel.CreateWebhookAsync(string name, Stream avatar, RequestOptions options) => await CreateWebhookAsync(name, avatar, options).ConfigureAwait(false); @@ -275,8 +278,9 @@ namespace Discord.Rest async Task ITextChannel.CreateThreadAsync(string name, ThreadType type, ThreadArchiveDuration autoArchiveDuration, IMessage message, RequestOptions options) => await CreateThreadAsync(name, type, autoArchiveDuration, message, options); + #endregion - //IMessageChannel + #region IMessageChannel /// async Task IMessageChannel.GetMessageAsync(ulong id, CacheMode mode, RequestOptions options) { @@ -324,8 +328,9 @@ namespace Discord.Rest /// 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); + #endregion - //IGuildChannel + #region IGuildChannel /// async Task IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) { @@ -342,8 +347,9 @@ namespace Discord.Rest else return AsyncEnumerable.Empty>(); } + #endregion - //IChannel + #region IChannel /// async Task IChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) { @@ -360,8 +366,9 @@ namespace Discord.Rest else return AsyncEnumerable.Empty>(); } + #endregion - // INestedChannel + #region ITextChannel /// async Task INestedChannel.GetCategoryAsync(CacheMode mode, RequestOptions options) { @@ -369,5 +376,6 @@ namespace Discord.Rest return (await Guild.GetChannelAsync(CategoryId.Value, mode, options).ConfigureAwait(false)) as ICategoryChannel; return null; } + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs index b551c7f8f..d1d567e27 100644 --- a/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs +++ b/src/Discord.Net.Rest/Entities/Channels/RestVoiceChannel.cs @@ -14,6 +14,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestVoiceChannel : RestGuildChannel, IVoiceChannel, IRestAudioChannel { + #region RestVoiceChannel /// public int Bitrate { get; private set; } /// @@ -60,8 +61,9 @@ namespace Discord.Rest /// public Task SyncPermissionsAsync(RequestOptions options = null) => ChannelHelper.SyncPermissionsAsync(this, Discord, options); + #endregion - //Invites + #region Invites /// public async Task CreateInviteAsync(int? maxAge = 86400, int? maxUses = null, bool isTemporary = false, bool isUnique = false, RequestOptions options = null) => await ChannelHelper.CreateInviteAsync(this, Discord, maxAge, maxUses, isTemporary, isUnique, options).ConfigureAwait(false); @@ -76,22 +78,25 @@ namespace Discord.Rest => await ChannelHelper.GetInvitesAsync(this, Discord, options).ConfigureAwait(false); private string DebuggerDisplay => $"{Name} ({Id}, Voice)"; + #endregion - //IAudioChannel + #region IAudioChannel /// /// Connecting to a REST-based channel is not supported. Task IAudioChannel.ConnectAsync(bool selfDeaf, bool selfMute, bool external) { throw new NotSupportedException(); } Task IAudioChannel.DisconnectAsync() { throw new NotSupportedException(); } + #endregion - //IGuildChannel + #region IGuildChannel /// Task IGuildChannel.GetUserAsync(ulong id, CacheMode mode, RequestOptions options) => Task.FromResult(null); /// IAsyncEnumerable> IGuildChannel.GetUsersAsync(CacheMode mode, RequestOptions options) => AsyncEnumerable.Empty>(); + #endregion - // INestedChannel + #region INestedChannel /// async Task INestedChannel.GetCategoryAsync(CacheMode mode, RequestOptions options) { @@ -99,5 +104,6 @@ namespace Discord.Rest return (await Guild.GetChannelAsync(CategoryId.Value, mode, options).ConfigureAwait(false)) as ICategoryChannel; return null; } + #endregion } } From 867380439b738a07b27ab7f836fbeb9893f8a696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Hjorth=C3=B8j?= Date: Tue, 21 Sep 2021 15:57:07 +0200 Subject: [PATCH 12/14] Regions discord.net.rest (#168) * BaseDiscordClient * ClientHelper * DiscordRestApiClient * DiscordRestClient * DiscordContractResolver * RestGuildUser * RestUser * RestWebhookUser * RestWebhook * RestRole * RoleHelper * RestApplicationCommandOption * InteractionHelper * GuildHelper * RestGuild --- src/Discord.Net.Rest/BaseDiscordClient.cs | 5 +- src/Discord.Net.Rest/ClientHelper.cs | 3 +- src/Discord.Net.Rest/DiscordRestApiClient.cs | 91 +++++++++++++------ src/Discord.Net.Rest/DiscordRestClient.cs | 6 +- .../Entities/Guilds/GuildHelper.cs | 36 +++++--- .../Entities/Guilds/RestGuild.cs | 35 ++++--- .../Interactions/InteractionHelper.cs | 14 ++- .../RestApplicationCommandOption.cs | 5 +- .../Entities/Roles/RestRole.cs | 6 +- .../Entities/Roles/RoleHelper.cs | 3 +- .../Entities/Users/RestGuildUser.cs | 8 +- .../Entities/Users/RestUser.cs | 5 +- .../Entities/Users/RestWebhookUser.cs | 8 +- .../Entities/Webhooks/RestWebhook.cs | 5 +- .../Net/Converters/DiscordContractResolver.cs | 5 +- 15 files changed, 164 insertions(+), 71 deletions(-) diff --git a/src/Discord.Net.Rest/BaseDiscordClient.cs b/src/Discord.Net.Rest/BaseDiscordClient.cs index 93b82c929..431859a10 100644 --- a/src/Discord.Net.Rest/BaseDiscordClient.cs +++ b/src/Discord.Net.Rest/BaseDiscordClient.cs @@ -10,6 +10,7 @@ namespace Discord.Rest { public abstract class BaseDiscordClient : IDiscordClient { + #region BaseDiscordClient public event Func Log { add { _logEvent.Add(value); } remove { _logEvent.Remove(value); } } internal readonly AsyncEvent> _logEvent = new AsyncEvent>(); @@ -155,8 +156,9 @@ namespace Discord.Rest /// public Task GetBotGatewayAsync(RequestOptions options = null) => ClientHelper.GetBotGatewayAsync(this, options); + #endregion - //IDiscordClient + #region IDiscordClient /// ConnectionState IDiscordClient.ConnectionState => ConnectionState.Disconnected; /// @@ -235,5 +237,6 @@ namespace Discord.Rest /// Task IDiscordClient.StopAsync() => Task.Delay(0); + #endregion } } diff --git a/src/Discord.Net.Rest/ClientHelper.cs b/src/Discord.Net.Rest/ClientHelper.cs index 2fc382900..4581219bb 100644 --- a/src/Discord.Net.Rest/ClientHelper.cs +++ b/src/Discord.Net.Rest/ClientHelper.cs @@ -10,7 +10,7 @@ namespace Discord.Rest { internal static class ClientHelper { - //Applications + #region Applications public static async Task GetApplicationInfoAsync(BaseDiscordClient client, RequestOptions options) { var model = await client.ApiClient.GetMyApplicationAsync(options).ConfigureAwait(false); @@ -263,5 +263,6 @@ namespace Discord.Rest public static Task RemoveRoleAsync(BaseDiscordClient client, ulong guildId, ulong userId, ulong roleId, RequestOptions options = null) => client.ApiClient.RemoveRoleAsync(guildId, userId, roleId, options); + #endregion } } diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index ead0c0e8a..0db6985b0 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -24,6 +24,7 @@ namespace Discord.API { internal class DiscordRestApiClient : IDisposable { + #region DiscordRestApiClient private static readonly ConcurrentDictionary> _bucketIdGenerators = new ConcurrentDictionary>(); public event Func SentRequest { add { _sentRequestEvent.Add(value); } remove { _sentRequestEvent.Remove(value); } } @@ -167,8 +168,9 @@ namespace Discord.API internal virtual Task ConnectInternalAsync() => Task.Delay(0); internal virtual Task DisconnectInternalAsync(Exception ex = null) => Task.Delay(0); + #endregion - //Core + #region Core internal Task SendAsync(string method, Expression> endpointExpr, BucketIds ids, ClientBucketType clientBucket = ClientBucketType.Unbucketed, RequestOptions options = null, [CallerMemberName] string funcName = null) => SendAsync(method, GetEndpoint(endpointExpr), GetBucketId(method, ids, endpointExpr, funcName), clientBucket, options); @@ -271,15 +273,17 @@ namespace Discord.API return responseStream; } + #endregion - //Auth + #region Auth public async Task ValidateTokenAsync(RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); await SendAsync("GET", () => "auth/login", new BucketIds(), options: options).ConfigureAwait(false); } + #endregion - //Gateway + #region Gateway public async Task GetGatewayAsync(RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); @@ -290,8 +294,9 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); return await SendAsync("GET", () => "gateway/bot", new BucketIds(), options: options).ConfigureAwait(false); } + #endregion - //Channels + #region Channels public async Task GetChannelAsync(ulong channelId, RequestOptions options = null) { Preconditions.NotEqual(channelId, 0, nameof(channelId)); @@ -414,8 +419,9 @@ namespace Discord.API break; } } + #endregion - // Threads + #region Threads public async Task ModifyThreadAsync(ulong channelId, ModifyThreadParams args, RequestOptions options = null) { Preconditions.NotEqual(channelId, 0, nameof(channelId)); @@ -582,8 +588,9 @@ namespace Discord.API return await SendAsync("GET", () => $"channels/{channelId}/users/@me/threads/archived/private{query}", bucket, options: options); } + #endregion - // stage + #region Stage public async Task CreateStageInstanceAsync(CreateStageInstanceParams args, RequestOptions options = null) { @@ -658,8 +665,9 @@ namespace Discord.API await SendJsonAsync("PATCH", () => $"guilds/{guildId}/voice-states/{userId}", args, bucket, options: options).ConfigureAwait(false); } + #endregion - // roles + #region Roles public async Task AddRoleAsync(ulong guildId, ulong userId, ulong roleId, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -682,8 +690,9 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); await SendAsync("DELETE", () => $"guilds/{guildId}/members/{userId}/roles/{roleId}", ids, options: options).ConfigureAwait(false); } + #endregion - //Channel Messages + #region Channel Messages public async Task GetChannelMessageAsync(ulong channelId, ulong messageId, RequestOptions options = null) { Preconditions.NotEqual(channelId, 0, nameof(channelId)); @@ -886,8 +895,9 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); return await SendJsonAsync("PATCH", () => $"channels/{channelId}/messages/{messageId}", args, ids, clientBucket: ClientBucketType.SendEdit, options: options).ConfigureAwait(false); } + #endregion - // Stickers + #region Stickers public async Task GetStickerAsync(ulong id, RequestOptions options = null) { Preconditions.NotEqual(id, 0, nameof(id)); @@ -1044,8 +1054,9 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); await SendAsync("POST", () => $"channels/{channelId}/messages/{messageId}/crosspost", ids, options: options).ConfigureAwait(false); } + #endregion - //Channel Permissions + #region Channel Permissions public async Task ModifyChannelPermissionsAsync(ulong channelId, ulong targetId, ModifyChannelPermissionsParams args, RequestOptions options = null) { Preconditions.NotEqual(channelId, 0, nameof(channelId)); @@ -1065,8 +1076,9 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); await SendAsync("DELETE", () => $"channels/{channelId}/permissions/{targetId}", ids, options: options).ConfigureAwait(false); } + #endregion - //Channel Pins + #region Channel Pins public async Task AddPinAsync(ulong channelId, ulong messageId, RequestOptions options = null) { Preconditions.GreaterThan(channelId, 0, nameof(channelId)); @@ -1094,8 +1106,9 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); return await SendAsync>("GET", () => $"channels/{channelId}/pins", ids, options: options).ConfigureAwait(false); } + #endregion - //Channel Recipients + #region Channel Recipients public async Task AddGroupRecipientAsync(ulong channelId, ulong userId, RequestOptions options = null) { Preconditions.GreaterThan(channelId, 0, nameof(channelId)); @@ -1115,8 +1128,9 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); await SendAsync("DELETE", () => $"channels/{channelId}/recipients/{userId}", ids, options: options).ConfigureAwait(false); } + #endregion - //Interactions + #region Interactions public async Task GetGlobalApplicationCommandsAsync(RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); @@ -1252,8 +1266,9 @@ namespace Discord.API return await TrySendApplicationCommand(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options)).ConfigureAwait(false); } + #endregion - //Interaction Responses + #region Interaction Responses public async Task CreateInteractionResponse(InteractionResponse response, ulong interactionId, string interactionToken, RequestOptions options = null) { if(response.Data.IsSpecified && response.Data.Value.Content.IsSpecified) @@ -1322,8 +1337,9 @@ namespace Discord.API await SendAsync("DELETE", () => $"webhooks/{CurrentUserId}/{token}/messages/{id}", new BucketIds(), options: options).ConfigureAwait(false); } + #endregion - // Application Command permissions + #region Application Command permissions public async Task GetGuildApplicationCommandPermissions(ulong guildId, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -1362,8 +1378,9 @@ namespace Discord.API return await SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); } + #endregion - //Guilds + #region Guilds public async Task GetGuildAsync(ulong guildId, bool withCounts, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -1436,8 +1453,9 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); return await SendAsync("GET", () => $"guilds/{guildId}/prune?days={args.Days}{endpointRoleIds}", ids, options: options).ConfigureAwait(false); } + #endregion - //Guild Bans + #region Guild Bans public async Task> GetGuildBansAsync(ulong guildId, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -1488,8 +1506,9 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); await SendAsync("DELETE", () => $"guilds/{guildId}/bans/{userId}", ids, options: options).ConfigureAwait(false); } + #endregion - //Guild Widget + #region Guild Widget /// must not be equal to zero. public async Task GetGuildWidgetAsync(ulong guildId, RequestOptions options = null) { @@ -1514,8 +1533,9 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); return await SendJsonAsync("PATCH", () => $"guilds/{guildId}/widget", args, ids, options: options).ConfigureAwait(false); } + #endregion - //Guild Integrations + #region Guild Integrations /// must not be equal to zero. public async Task> GetGuildIntegrationsAsync(ulong guildId, RequestOptions options = null) { @@ -1567,8 +1587,9 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); return await SendAsync("POST", () => $"guilds/{guildId}/integrations/{integrationId}/sync", ids, options: options).ConfigureAwait(false); } + #endregion - //Guild Invites + #region Guild Invites /// cannot be blank. /// must not be . public async Task GetInviteAsync(string inviteId, RequestOptions options = null) @@ -1651,8 +1672,9 @@ namespace Discord.API return await SendAsync("DELETE", () => $"invites/{inviteId}", new BucketIds(), options: options).ConfigureAwait(false); } + #endregion - //Guild Members + #region Guild Members public async Task AddGuildMemberAsync(ulong guildId, ulong userId, AddGuildMemberParams args, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -1750,8 +1772,9 @@ namespace Discord.API Expression> endpoint = () => $"guilds/{guildId}/members/search?limit={limit}&query={query}"; return await SendAsync>("GET", endpoint, ids, options: options).ConfigureAwait(false); } + #endregion - //Guild Roles + #region Guild Roles public async Task> GetGuildRolesAsync(ulong guildId, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -1798,8 +1821,9 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); return await SendJsonAsync>("PATCH", () => $"guilds/{guildId}/roles", args, ids, options: options).ConfigureAwait(false); } + #endregion - //Guild emoji + #region Guild emoji public async Task> GetGuildEmotesAsync(ulong guildId, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -1851,8 +1875,9 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); await SendAsync("DELETE", () => $"guilds/{guildId}/emojis/{emoteId}", ids, options: options).ConfigureAwait(false); } + #endregion - //Users + #region Users public async Task GetUserAsync(ulong userId, RequestOptions options = null) { Preconditions.NotEqual(userId, 0, nameof(userId)); @@ -1864,8 +1889,9 @@ namespace Discord.API } catch (HttpException ex) when (ex.HttpCode == HttpStatusCode.NotFound) { return null; } } + #endregion - //Current User/DMs + #region Current User/DMs public async Task GetMyUserAsync(RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); @@ -1924,8 +1950,9 @@ namespace Discord.API return await SendJsonAsync("POST", () => "users/@me/channels", args, new BucketIds(), options: options).ConfigureAwait(false); } + #endregion - //Voice Regions + #region Voice Regions public async Task> GetVoiceRegionsAsync(RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); @@ -1939,8 +1966,9 @@ namespace Discord.API var ids = new BucketIds(guildId: guildId); return await SendAsync>("GET", () => $"guilds/{guildId}/regions", ids, options: options).ConfigureAwait(false); } + #endregion - //Audit logs + #region Audit logs public async Task GetAuditLogsAsync(ulong guildId, GetAuditLogsParams args, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -1969,12 +1997,13 @@ namespace Discord.API .Append(args.ActionType.Value); } - // still use string interp for the query w/o params, as this is necessary for CreateBucketId + // Still use string interp for the query w/o params, as this is necessary for CreateBucketId endpoint = () => $"guilds/{guildId}/audit-logs?limit={limit}{queryArgs.ToString()}"; return await SendAsync("GET", endpoint, ids, options: options).ConfigureAwait(false); } + #endregion - //Webhooks + #region Webhooks public async Task CreateWebhookAsync(ulong channelId, CreateWebhookParams args, RequestOptions options = null) { Preconditions.NotEqual(channelId, 0, nameof(channelId)); @@ -2037,8 +2066,9 @@ namespace Discord.API var ids = new BucketIds(channelId: channelId); return await SendAsync>("GET", () => $"channels/{channelId}/webhooks", ids, options: options).ConfigureAwait(false); } + #endregion - //Helpers + #region Helpers /// Client is not logged in. protected void CheckState() { @@ -2248,5 +2278,6 @@ namespace Discord.API return (expr as MemberExpression).Member.Name; } + #endregion } } diff --git a/src/Discord.Net.Rest/DiscordRestClient.cs b/src/Discord.Net.Rest/DiscordRestClient.cs index 10a4c40a9..8254eabe9 100644 --- a/src/Discord.Net.Rest/DiscordRestClient.cs +++ b/src/Discord.Net.Rest/DiscordRestClient.cs @@ -12,6 +12,7 @@ namespace Discord.Rest /// public class DiscordRestClient : BaseDiscordClient, IDiscordClient { + #region DiscordRestClient private RestApplication _applicationInfo; /// @@ -138,7 +139,9 @@ namespace Discord.Rest => MessageHelper.RemoveAllReactionsAsync(channelId, messageId, this, options); public Task RemoveAllReactionsForEmoteAsync(ulong channelId, ulong messageId, IEmote emote, RequestOptions options = null) => MessageHelper.RemoveAllReactionsForEmoteAsync(channelId, messageId, emote, this, options); - //IDiscordClient +#endregion + + #region IDiscordClient /// async Task IDiscordClient.GetApplicationInfoAsync(RequestOptions options) => await GetApplicationInfoAsync(options).ConfigureAwait(false); @@ -229,5 +232,6 @@ namespace Discord.Rest /// async Task IDiscordClient.GetGlobalApplicationCommandAsync(ulong id, RequestOptions options) => await ClientHelper.GetGlobalApplicationCommand(this, id, options).ConfigureAwait(false); + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs index 73f59b566..1fb4b774a 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs @@ -14,7 +14,7 @@ namespace Discord.Rest { internal static class GuildHelper { - //General + #region General /// is null. public static async Task ModifyAsync(IGuild guild, BaseDiscordClient client, Action func, RequestOptions options) @@ -123,8 +123,9 @@ namespace Discord.Rest { await client.ApiClient.DeleteGuildAsync(guild.Id, options).ConfigureAwait(false); } + #endregion - //Bans + #region Bans public static async Task> GetBansAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) { @@ -148,8 +149,9 @@ namespace Discord.Rest { await client.ApiClient.RemoveGuildBanAsync(guild.Id, userId, options).ConfigureAwait(false); } + #endregion - //Channels + #region Channels public static async Task GetChannelAsync(IGuild guild, BaseDiscordClient client, ulong id, RequestOptions options) { @@ -275,16 +277,18 @@ namespace Discord.Rest var model = await client.ApiClient.CreateGuildChannelAsync(guild.Id, args, options).ConfigureAwait(false); return RestCategoryChannel.Create(client, guild, model); } + #endregion - //Voice Regions + #region Voice Regions public static async Task> GetVoiceRegionsAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) { var models = await client.ApiClient.GetGuildVoiceRegionsAsync(guild.Id, options).ConfigureAwait(false); return models.Select(x => RestVoiceRegion.Create(client, x)).ToImmutableArray(); } + #endregion - //Integrations + #region Integrations public static async Task> GetIntegrationsAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) { @@ -298,8 +302,9 @@ namespace Discord.Rest var model = await client.ApiClient.CreateGuildIntegrationAsync(guild.Id, args, options).ConfigureAwait(false); return RestGuildIntegration.Create(client, guild, model); } + #endregion - //Interactions + #region Interactions public static async Task> GetSlashCommandsAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) { @@ -312,8 +317,9 @@ namespace Discord.Rest var model = await client.ApiClient.GetGuildApplicationCommandAsync(guild.Id, id, options); return RestGuildCommand.Create(client, model, guild.Id); } + #endregion - //Invites + #region Invites public static async Task> GetInvitesAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) { @@ -329,8 +335,9 @@ namespace Discord.Rest inviteModel.Uses = vanityModel.Uses; return RestInviteMetadata.Create(client, guild, null, inviteModel); } + #endregion - //Roles + #region Roles /// is null. public static async Task CreateRoleAsync(IGuild guild, BaseDiscordClient client, string name, GuildPermissions? permissions, Color? color, bool isHoisted, bool isMentionable, RequestOptions options) @@ -350,8 +357,9 @@ namespace Discord.Rest return RestRole.Create(client, guild, model); } + #endregion - //Users + #region Users public static async Task AddGuildUserAsync(IGuild guild, BaseDiscordClient client, ulong userId, string accessToken, Action func, RequestOptions options) { @@ -470,8 +478,9 @@ namespace Discord.Rest var models = await client.ApiClient.SearchGuildMembersAsync(guild.Id, apiArgs, options).ConfigureAwait(false); return models.Select(x => RestGuildUser.Create(client, guild, x)).ToImmutableArray(); } + #endregion - // Audit logs + #region Audit logs public static IAsyncEnumerable> GetAuditLogsAsync(IGuild guild, BaseDiscordClient client, ulong? from, int? limit, RequestOptions options, ulong? userId = null, ActionType? actionType = null) { @@ -503,8 +512,9 @@ namespace Discord.Rest count: limit ); } + #endregion - //Webhooks + #region Webhooks public static async Task GetWebhookAsync(IGuild guild, BaseDiscordClient client, ulong id, RequestOptions options) { var model = await client.ApiClient.GetWebhookAsync(id, options: options).ConfigureAwait(false); @@ -517,8 +527,9 @@ namespace Discord.Rest var models = await client.ApiClient.GetGuildWebhooksAsync(guild.Id, options).ConfigureAwait(false); return models.Select(x => RestWebhook.Create(client, guild, x)).ToImmutableArray(); } + #endregion - //Emotes + #region Emotes public static async Task> GetEmotesAsync(IGuild guild, BaseDiscordClient client, RequestOptions options) { var models = await client.ApiClient.GetGuildEmotesAsync(guild.Id, options).ConfigureAwait(false); @@ -637,5 +648,6 @@ namespace Discord.Rest public static async Task DeleteStickerAsync(BaseDiscordClient client, ulong guildId, ISticker sticker, RequestOptions options = null) => await client.ApiClient.DeleteStickerAsync(guildId, sticker.Id, options).ConfigureAwait(false); + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs index d566afc81..a313de810 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs @@ -18,6 +18,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestGuild : RestEntity, IGuild, IUpdateable { + #region RestGuild private ImmutableDictionary _roles; private ImmutableArray _emotes; private ImmutableArray _stickers; @@ -217,8 +218,9 @@ namespace Discord.Rest WidgetChannelId = model.ChannelId; IsWidgetEnabled = model.Enabled; } + #endregion - //General + #region General /// public async Task UpdateAsync(RequestOptions options = null) => Update(await Discord.ApiClient.GetGuildAsync(Id, false, options).ConfigureAwait(false)); @@ -277,8 +279,9 @@ namespace Discord.Rest /// public Task LeaveAsync(RequestOptions options = null) => GuildHelper.LeaveAsync(this, Discord, options); + #endregion - //Interactions + #region Interactions /// /// Deletes all slash commands in the current guild. /// @@ -311,8 +314,9 @@ namespace Discord.Rest /// public Task GetSlashCommandAsync(ulong id, RequestOptions options = null) => GuildHelper.GetSlashCommandAsync(this, id, Discord, options); + #endregion - //Bans + #region Bans /// /// Gets a collection of all users banned in this guild. /// @@ -360,8 +364,9 @@ namespace Discord.Rest /// public Task RemoveBanAsync(ulong userId, RequestOptions options = null) => GuildHelper.RemoveBanAsync(this, Discord, userId, options); + #endregion - //Channels + #region Channels /// /// Gets a collection of all channels in this guild. /// @@ -697,14 +702,16 @@ namespace Discord.Rest /// public Task> GetVoiceRegionsAsync(RequestOptions options = null) => GuildHelper.GetVoiceRegionsAsync(this, Discord, options); + #endregion - //Integrations + #region Integrations public Task> GetIntegrationsAsync(RequestOptions options = null) => GuildHelper.GetIntegrationsAsync(this, Discord, options); public Task CreateIntegrationAsync(ulong id, string type, RequestOptions options = null) => GuildHelper.CreateIntegrationAsync(this, Discord, id, type, options); + #endregion - //Invites + #region Invites /// /// Gets a collection of all invites in this guild. /// @@ -724,8 +731,9 @@ namespace Discord.Rest /// public Task GetVanityInviteAsync(RequestOptions options = null) => GuildHelper.GetVanityInviteAsync(this, Discord, options); + #endregion - //Roles + #region Roles /// /// Gets a role in this guild. /// @@ -765,8 +773,9 @@ namespace Discord.Rest _roles = _roles.Add(role.Id, role); return role; } + #endregion - //Users + #region Users /// /// Gets a collection of all users in this guild. /// @@ -860,8 +869,9 @@ namespace Discord.Rest /// public Task> SearchUsersAsync(string query, int limit = DiscordConfig.MaxUsersPerBatch, RequestOptions options = null) => GuildHelper.SearchUsersAsync(this, Discord, query, limit, options); + #endregion - //Audit logs + #region Audit logs /// /// Gets the specified number of audit log entries for this guild. /// @@ -876,8 +886,9 @@ namespace Discord.Rest /// public IAsyncEnumerable> GetAuditLogsAsync(int limit, RequestOptions options = null, ulong? beforeId = null, ulong? userId = null, ActionType? actionType = null) => GuildHelper.GetAuditLogsAsync(this, Discord, beforeId, limit, options, userId: userId, actionType: actionType); + #endregion - //Webhooks + #region Webhooks /// /// Gets a webhook found within this guild. /// @@ -900,8 +911,9 @@ namespace Discord.Rest /// public Task> GetWebhooksAsync(RequestOptions options = null) => GuildHelper.GetWebhooksAsync(this, Discord, options); + #endregion - //Interactions + #region Interactions /// /// Gets this guilds slash commands commands /// @@ -961,6 +973,7 @@ namespace Discord.Rest /// public override string ToString() => Name; private string DebuggerDisplay => $"{Name} ({Id})"; + #endregion #region Emotes /// diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs index 8bc87339e..7a4b49166 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs @@ -11,6 +11,7 @@ namespace Discord.Rest { internal static class InteractionHelper { + #region InteractionHelper public static Task DeleteAllGuildCommandsAsync(BaseDiscordClient client, ulong guildId, RequestOptions options = null) { return client.ApiClient.BulkOverwriteGuildApplicationCommands(guildId, new CreateApplicationCommandParams[0], options); @@ -42,8 +43,9 @@ namespace Discord.Rest RestFollowupMessage entity = RestFollowupMessage.Create(client, model, token, channel); return entity; } +#endregion - // Global commands + #region Global commands public static async Task GetGlobalCommandAsync(BaseDiscordClient client, ulong id, RequestOptions options = null) { @@ -236,8 +238,9 @@ namespace Discord.Rest await client.ApiClient.DeleteGlobalApplicationCommandAsync(command.Id, options).ConfigureAwait(false); } + #endregion - // Guild Commands + #region Guild Commands public static Task CreateGuildCommand(BaseDiscordClient client, ulong guildId, Action func, RequestOptions options) where TArg : ApplicationCommandProperties { @@ -324,8 +327,9 @@ namespace Discord.Rest return DeleteGlobalCommand(client, command, options); } } + #endregion - // Responses + #region Responses public static async Task ModifyFollowupMessage(BaseDiscordClient client, RestFollowupMessage message, Action func, RequestOptions options = null) { @@ -412,8 +416,9 @@ namespace Discord.Rest public static async Task DeletedInteractionResponse(BaseDiscordClient client, RestInteractionMessage message, RequestOptions options = null) => await client.ApiClient.DeleteInteractionFollowupMessage(message.Id, message.Token, options); + #endregion - // Guild permissions + #region Guild permissions public static async Task> GetGuildCommandPermissionsAsync(BaseDiscordClient client, ulong guildId, RequestOptions options) { @@ -506,5 +511,6 @@ namespace Discord.Rest x => new GuildApplicationCommandPermission(x.Id, x.ApplicationId, x.GuildId, x.Permissions.Select( y => new ApplicationCommandPermission(y.Id, y.Type, y.Permission)).ToArray())).ToArray(); } + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs index b135ae578..78f9c0e30 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/RestApplicationCommandOption.cs @@ -13,6 +13,7 @@ namespace Discord.Rest /// public class RestApplicationCommandOption : IApplicationCommandOption { + #region RestApplicationCommandOption /// public ApplicationCommandOptionType Type { get; private set; } @@ -67,11 +68,13 @@ namespace Discord.Rest ? model.Choices.Value.Select(x => new RestApplicationCommandChoice(x)).ToImmutableArray() : null; } + #endregion - //IApplicationCommandOption + #region IApplicationCommandOption IReadOnlyCollection IApplicationCommandOption.Options => Options; IReadOnlyCollection IApplicationCommandOption.Choices => Choices; + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Roles/RestRole.cs b/src/Discord.Net.Rest/Entities/Roles/RestRole.cs index aa33ae7e5..03e954f47 100644 --- a/src/Discord.Net.Rest/Entities/Roles/RestRole.cs +++ b/src/Discord.Net.Rest/Entities/Roles/RestRole.cs @@ -11,6 +11,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestRole : RestEntity, IRole { + #region RestRole internal IGuild Guild { get; } /// public Color Color { get; private set; } @@ -64,7 +65,7 @@ namespace Discord.Rest /// public async Task ModifyAsync(Action func, RequestOptions options = null) - { + { var model = await RoleHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false); Update(model); } @@ -83,8 +84,9 @@ namespace Discord.Rest /// public override string ToString() => Name; private string DebuggerDisplay => $"{Name} ({Id})"; + #endregion - //IRole + #region IRole /// IGuild IRole.Guild { diff --git a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs index 73ab7ca31..8d525d4c3 100644 --- a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs +++ b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs @@ -7,7 +7,7 @@ namespace Discord.Rest { internal static class RoleHelper { - //General + #region General public static async Task DeleteAsync(IRole role, BaseDiscordClient client, RequestOptions options) { @@ -36,5 +36,6 @@ namespace Discord.Rest } return model; } + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs b/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs index 9ad36a074..556e5e124 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs @@ -14,6 +14,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestGuildUser : RestUser, IGuildUser { + #region RestGuildUser private long? _premiumSinceTicks; private long? _joinedAtTicks; private ImmutableArray _roleIds; @@ -155,8 +156,9 @@ namespace Discord.Rest var guildPerms = GuildPermissions; return new ChannelPermissions(Permissions.ResolveChannel(Guild, this, channel, guildPerms.RawValue)); } +#endregion - //IGuildUser + #region IGuildUser /// IGuild IGuildUser.Guild { @@ -167,8 +169,9 @@ namespace Discord.Rest throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object."); } } + #endregion - //IVoiceState + #region IVoiceState /// bool IVoiceState.IsSelfDeafened => false; /// @@ -183,5 +186,6 @@ namespace Discord.Rest bool IVoiceState.IsStreaming => false; /// DateTimeOffset? IVoiceState.RequestToSpeakTimestamp => null; + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Users/RestUser.cs b/src/Discord.Net.Rest/Entities/Users/RestUser.cs index 618804fef..7304f5f39 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestUser.cs @@ -13,6 +13,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestUser : RestEntity, IUser, IUpdateable { + #region RestUser /// public bool IsBot { get; private set; } /// @@ -116,10 +117,12 @@ namespace Discord.Rest /// public override string ToString() => $"{Username}#{Discriminator}"; private string DebuggerDisplay => $"{Username}#{Discriminator} ({Id}{(IsBot ? ", Bot" : "")})"; + #endregion - //IUser + #region IUser /// async Task IUser.CreateDMChannelAsync(RequestOptions options) => await CreateDMChannelAsync(options).ConfigureAwait(false); + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs b/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs index 40a173976..561cd92ee 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs @@ -10,6 +10,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestWebhookUser : RestUser, IWebhookUser { + #region RestWebhookUser /// public ulong WebhookId { get; } internal IGuild Guild { get; } @@ -33,8 +34,9 @@ namespace Discord.Rest entity.Update(model); return entity; } +#endregion - //IGuildUser + #region IGuildUser /// IGuild IGuildUser.Guild { @@ -91,8 +93,9 @@ namespace Discord.Rest /// Task IGuildUser.RemoveRolesAsync(IEnumerable roles, RequestOptions options) => throw new NotSupportedException("Roles are not supported on webhook users."); + #endregion - //IVoiceState + #region IVoiceState /// bool IVoiceState.IsDeafened => false; /// @@ -111,5 +114,6 @@ namespace Discord.Rest bool IVoiceState.IsStreaming => false; /// DateTimeOffset? IVoiceState.RequestToSpeakTimestamp => null; + #endregion } } diff --git a/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs b/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs index 5ae09fde0..f40b786cd 100644 --- a/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs +++ b/src/Discord.Net.Rest/Entities/Webhooks/RestWebhook.cs @@ -8,6 +8,7 @@ namespace Discord.Rest [DebuggerDisplay(@"{DebuggerDisplay,nq}")] public class RestWebhook : RestEntity, IWebhook, IUpdateable { + #region RestWebhook internal IGuild Guild { get; private set; } internal ITextChannel Channel { get; private set; } @@ -95,8 +96,9 @@ namespace Discord.Rest public override string ToString() => $"Webhook: {Name}:{Id}"; private string DebuggerDisplay => $"Webhook: {Name} ({Id})"; + #endregion - //IWebhook + #region IWebhook /// IGuild IWebhook.Guild => Guild ?? throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object."); @@ -106,5 +108,6 @@ namespace Discord.Rest /// Task IWebhook.ModifyAsync(Action func, RequestOptions options) => ModifyAsync(func, options); + #endregion } } diff --git a/src/Discord.Net.Rest/Net/Converters/DiscordContractResolver.cs b/src/Discord.Net.Rest/Net/Converters/DiscordContractResolver.cs index 5981a266e..feea164f9 100644 --- a/src/Discord.Net.Rest/Net/Converters/DiscordContractResolver.cs +++ b/src/Discord.Net.Rest/Net/Converters/DiscordContractResolver.cs @@ -10,6 +10,7 @@ namespace Discord.Net.Converters { internal class DiscordContractResolver : DefaultContractResolver { + #region DiscordContractResolver private static readonly TypeInfo _ienumerable = typeof(IEnumerable).GetTypeInfo(); private static readonly MethodInfo _shouldSerialize = typeof(DiscordContractResolver).GetTypeInfo().GetDeclaredMethod("ShouldSerialize"); @@ -57,8 +58,9 @@ namespace Discord.Net.Converters else if (genericType == typeof(EntityOrId<>)) return MakeGenericConverter(property, propInfo, typeof(UInt64EntityOrIdConverter<>), type.GenericTypeArguments[0], depth); } +#endregion - //Primitives + #region Primitives bool hasInt53 = propInfo.GetCustomAttribute() != null; if (!hasInt53) { @@ -107,5 +109,6 @@ namespace Discord.Net.Converters var innerConverter = GetConverter(property, propInfo, innerType, depth + 1); return genericType.DeclaredConstructors.First().Invoke(new object[] { innerConverter }) as JsonConverter; } + #endregion } } From a98417e177c190b89690b3527a2eace38f643bec Mon Sep 17 00:00:00 2001 From: quin lynch Date: Tue, 21 Sep 2021 14:23:23 -0300 Subject: [PATCH 13/14] Update Discord.Net.Commands.xml --- src/Discord.Net.Commands/Discord.Net.Commands.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Discord.Net.Commands/Discord.Net.Commands.xml b/src/Discord.Net.Commands/Discord.Net.Commands.xml index 7da918622..e44d71229 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. @@ -1143,6 +1143,8 @@ 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 + A collection of stickers to send with the file. From bbf9a7af0fc9464d20efaf77b84184c4b414ea09 Mon Sep 17 00:00:00 2001 From: quin lynch Date: Tue, 21 Sep 2021 14:32:57 -0300 Subject: [PATCH 14/14] deprecated always ack, fixed methods naming conventions to use async --- src/Discord.Net.Core/Discord.Net.Core.xml | 51 ++++++++++++++----- src/Discord.Net.Rest/Discord.Net.Rest.xml | 15 ++++++ src/Discord.Net.Rest/DiscordRestApiClient.cs | 46 ++++++++--------- .../Interactions/InteractionHelper.cs | 30 +++++------ .../Entities/Roles/RestRole.cs | 2 + .../Discord.Net.WebSocket.xml | 40 ++++++--------- .../DiscordSocketClient.cs | 6 --- .../DiscordSocketConfig.cs | 23 --------- .../SocketMessageComponent.cs | 10 +--- .../SocketBaseCommand/SocketCommandBase.cs | 8 +-- 10 files changed, 113 insertions(+), 118 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index 220f3fae4..38b0fa310 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -3747,6 +3747,13 @@ The options to be used when sending the request. A guild user associated with the specified ; if the user is already in the guild. + + + Disconnects the user from its current voice channel + + The user to disconnect. + A task that represents the asynchronous operation for disconnecting a user. + Gets a collection of all users in this guild. @@ -3936,6 +3943,14 @@ emote. + + + Moves the user to the voice channel. + + The user to move. + the channel where the user gets moved to. + A task that represents the asynchronous operation for moving a user. + Deletes an existing from this guild. @@ -4992,6 +5007,16 @@ ACK a Ping. + + + ACK a command without sending a message, eating the user's input. + + + + + Respond with a message, showing the user's input. + + Respond to an interaction with a message. @@ -5129,11 +5154,6 @@ Represents a builder for creating a . - - - The max length of a . - - The max length of a . @@ -5266,7 +5286,7 @@ Represents a class used to build 's. - + The max length of a . @@ -5275,13 +5295,15 @@ Gets or sets the label of the current button. - length exceeds . + length exceeds . + length exceeds . Gets or sets the custom id of the current button. length exceeds + length subceeds 1. @@ -5448,13 +5470,15 @@ Gets or sets the custom id of the current select menu. - length exceeds . + length exceeds + length subceeds 1. Gets or sets the placeholder text of the current select menu. length exceeds . + length subceeds 1. @@ -5595,7 +5619,7 @@ Represents a class used to build 's. - + The maximum length of a . @@ -5605,9 +5629,9 @@ The maximum length of a . - + - The maximum length of a . + The maximum length of a . @@ -5615,18 +5639,21 @@ Gets or sets the label of the current select menu. length exceeds + length subceeds 1. Gets or sets the custom id of the current select menu. - length exceeds . + length exceeds . + length subceeds 1. Gets or sets this menu options description. length exceeds . + length subceeds 1. diff --git a/src/Discord.Net.Rest/Discord.Net.Rest.xml b/src/Discord.Net.Rest/Discord.Net.Rest.xml index 43c2a05bc..6e6b76d21 100644 --- a/src/Discord.Net.Rest/Discord.Net.Rest.xml +++ b/src/Discord.Net.Rest/Discord.Net.Rest.xml @@ -3617,6 +3617,14 @@ is . + + + Moves the user to the voice channel. + + The user to move. + the channel where the user gets moved to. + A task that represents the asynchronous operation for moving a user. + @@ -3802,6 +3810,13 @@ + + + Disconnects the user from its current voice channel + + The user to disconnect. + A task that represents the asynchronous operation for disconnecting a user. + diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 0db6985b0..f132cb7a4 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -897,7 +897,7 @@ namespace Discord.API } #endregion - #region Stickers + #region Stickers, Reactions, Crosspost, and Acks public async Task GetStickerAsync(ulong id, RequestOptions options = null) { Preconditions.NotEqual(id, 0, nameof(id)); @@ -1166,25 +1166,25 @@ namespace Discord.API options = RequestOptions.CreateOrClone(options); - return await TrySendApplicationCommand(SendJsonAsync("POST", () => $"applications/{this.CurrentUserId}/commands", command, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("POST", () => $"applications/{this.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 TrySendApplicationCommand(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{this.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 TrySendApplicationCommand(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{this.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 TrySendApplicationCommand(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/commands/{commandId}", command, new BucketIds(), options: options)).ConfigureAwait(false); } public async Task DeleteGlobalApplicationCommandAsync(ulong commandId, RequestOptions options = null) { @@ -1193,11 +1193,11 @@ namespace Discord.API await SendAsync("DELETE", () => $"applications/{this.CurrentUserId}/commands/{commandId}", new BucketIds(), options: options).ConfigureAwait(false); } - public async Task BulkOverwriteGlobalApplicationCommands(CreateApplicationCommandParams[] commands, RequestOptions options = null) + public async Task BulkOverwriteGlobalApplicationCommandsAsync(CreateApplicationCommandParams[] commands, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); - return await TrySendApplicationCommand(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/commands", commands, new BucketIds(), options: options)).ConfigureAwait(false); } public async Task GetGuildApplicationCommandsAsync(ulong guildId, RequestOptions options = null) @@ -1239,7 +1239,7 @@ namespace Discord.API var bucket = new BucketIds(guildId: guildId); - return await TrySendApplicationCommand(SendJsonAsync("POST", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", command, bucket, options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("POST", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", command, bucket, options: options)).ConfigureAwait(false); } public async Task ModifyGuildApplicationCommandAsync(ModifyApplicationCommandParams command, ulong guildId, ulong commandId, RequestOptions options = null) { @@ -1247,7 +1247,7 @@ namespace Discord.API var bucket = new BucketIds(guildId: guildId); - return await TrySendApplicationCommand(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PATCH", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", command, bucket, options: options)).ConfigureAwait(false); } public async Task DeleteGuildApplicationCommandAsync(ulong guildId, ulong commandId, RequestOptions options = null) { @@ -1258,18 +1258,18 @@ namespace Discord.API await SendAsync("DELETE", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}", bucket, options: options).ConfigureAwait(false); } - public async Task BulkOverwriteGuildApplicationCommands(ulong guildId, CreateApplicationCommandParams[] commands, RequestOptions options = null) + public async Task BulkOverwriteGuildApplicationCommandsAsync(ulong guildId, CreateApplicationCommandParams[] commands, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); var bucket = new BucketIds(guildId: guildId); - return await TrySendApplicationCommand(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options)).ConfigureAwait(false); + return await TrySendApplicationCommandAsync(SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands", commands, bucket, options: options)).ConfigureAwait(false); } #endregion #region Interaction Responses - public async Task CreateInteractionResponse(InteractionResponse response, ulong interactionId, string interactionToken, RequestOptions options = null) + public async Task CreateInteractionResponseAsync(InteractionResponse response, ulong interactionId, string interactionToken, RequestOptions options = null) { if(response.Data.IsSpecified && response.Data.Value.Content.IsSpecified) Preconditions.AtMost(response.Data.Value.Content.Value?.Length ?? 0, 2000, nameof(response.Data.Value.Content)); @@ -1278,7 +1278,7 @@ namespace Discord.API await SendJsonAsync("POST", () => $"interactions/{interactionId}/{interactionToken}/callback", response, new BucketIds(), options: options); } - public async Task GetInteractionResponse(string interactionToken, RequestOptions options = null) + public async Task GetInteractionResponseAsync(string interactionToken, RequestOptions options = null) { Preconditions.NotNullOrEmpty(interactionToken, nameof(interactionToken)); @@ -1286,20 +1286,20 @@ namespace Discord.API return await SendAsync("GET", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options).ConfigureAwait(false); } - public async Task ModifyInteractionResponse(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null) + 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); } - public async Task DeleteInteractionResponse(string interactionToken, RequestOptions options = null) + 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); } - public async Task CreateInteractionFollowupMessage(CreateWebhookMessageParams args, string token, RequestOptions options = null) + public async Task CreateInteractionFollowupMessageAsync(CreateWebhookMessageParams args, string token, RequestOptions options = null) { if ((!args.Embeds.IsSpecified || args.Embeds.Value == null || args.Embeds.Value.Length == 0) && !args.File.IsSpecified) Preconditions.NotNullOrEmpty(args.Content, nameof(args.Content)); @@ -1315,7 +1315,7 @@ namespace Discord.API return await SendMultipartAsync("POST", () => $"webhooks/{CurrentUserId}/{token}?wait=true", args.ToDictionary(), new BucketIds(), options: options).ConfigureAwait(false); } - public async Task ModifyInteractionFollowupMessage(ModifyInteractionResponseParams args, ulong id, string token, RequestOptions options = null) + public async Task ModifyInteractionFollowupMessageAsync(ModifyInteractionResponseParams args, ulong id, string token, RequestOptions options = null) { Preconditions.NotNull(args, nameof(args)); Preconditions.NotEqual(id, 0, nameof(id)); @@ -1329,7 +1329,7 @@ namespace Discord.API return await SendJsonAsync("PATCH", () => $"webhooks/{CurrentUserId}/{token}/messages/{id}", args, new BucketIds(), options: options).ConfigureAwait(false); } - public async Task DeleteInteractionFollowupMessage(ulong id, string token, RequestOptions options = null) + public async Task DeleteInteractionFollowupMessageAsync(ulong id, string token, RequestOptions options = null) { Preconditions.NotEqual(id, 0, nameof(id)); @@ -1340,7 +1340,7 @@ namespace Discord.API #endregion #region Application Command permissions - public async Task GetGuildApplicationCommandPermissions(ulong guildId, RequestOptions options = null) + public async Task GetGuildApplicationCommandPermissionsAsync(ulong guildId, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); @@ -1349,7 +1349,7 @@ namespace Discord.API return await SendAsync("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/permissions", new BucketIds(), options: options).ConfigureAwait(false); } - public async Task GetGuildApplicationCommandPermission(ulong guildId, ulong commandId, RequestOptions options = null) + public async Task GetGuildApplicationCommandPermissionAsync(ulong guildId, ulong commandId, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); Preconditions.NotEqual(commandId, 0, nameof(commandId)); @@ -1359,7 +1359,7 @@ namespace Discord.API return await SendAsync("GET", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", new BucketIds(), options: options).ConfigureAwait(false); } - public async Task ModifyApplicationCommandPermissions(ModifyGuildApplicationCommandPermissionsParams permissions, ulong guildId, ulong commandId, RequestOptions options = null) + public async Task ModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissionsParams permissions, ulong guildId, ulong commandId, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); Preconditions.NotEqual(commandId, 0, nameof(commandId)); @@ -1369,7 +1369,7 @@ namespace Discord.API return await SendJsonAsync("PUT", () => $"applications/{this.CurrentUserId}/guilds/{guildId}/commands/{commandId}/permissions", permissions, new BucketIds(), options: options).ConfigureAwait(false); } - public async Task> BatchModifyApplicationCommandPermissions(ModifyGuildApplicationCommandPermissions[] permissions, ulong guildId, RequestOptions options = null) + public async Task> BatchModifyApplicationCommandPermissionsAsync(ModifyGuildApplicationCommandPermissions[] permissions, ulong guildId, RequestOptions options = null) { Preconditions.NotEqual(guildId, 0, nameof(guildId)); Preconditions.NotNull(permissions, nameof(permissions)); @@ -2091,7 +2091,7 @@ namespace Discord.API return _serializer.Deserialize(reader); } - protected async Task TrySendApplicationCommand(Task sendTask) + protected async Task TrySendApplicationCommandAsync(Task sendTask) { try { diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs index 7a4b49166..e79cb6e2f 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs @@ -14,31 +14,31 @@ namespace Discord.Rest #region InteractionHelper public static Task DeleteAllGuildCommandsAsync(BaseDiscordClient client, ulong guildId, RequestOptions options = null) { - return client.ApiClient.BulkOverwriteGuildApplicationCommands(guildId, new CreateApplicationCommandParams[0], options); + return client.ApiClient.BulkOverwriteGuildApplicationCommandsAsync(guildId, new CreateApplicationCommandParams[0], options); } public static Task DeleteAllGlobalCommandsAsync(BaseDiscordClient client, RequestOptions options = null) { - return client.ApiClient.BulkOverwriteGlobalApplicationCommands(new CreateApplicationCommandParams[0], options); + return client.ApiClient.BulkOverwriteGlobalApplicationCommandsAsync(new CreateApplicationCommandParams[0], options); } public static Task SendInteractionResponse(BaseDiscordClient client, InteractionResponse response, ulong interactionId, string interactionToken, RequestOptions options = null) { - return client.ApiClient.CreateInteractionResponse(response, interactionId, interactionToken, options); + return client.ApiClient.CreateInteractionResponseAsync(response, interactionId, interactionToken, options); } public static async Task GetOriginalResponseAsync(BaseDiscordClient client, IMessageChannel channel, IDiscordInteraction interaction, RequestOptions options = null) { - var model = await client.ApiClient.GetInteractionResponse(interaction.Token, options).ConfigureAwait(false); + var model = await client.ApiClient.GetInteractionResponseAsync(interaction.Token, options).ConfigureAwait(false); return RestInteractionMessage.Create(client, model, interaction.Token, channel); } public static async Task SendFollowupAsync(BaseDiscordClient client, CreateWebhookMessageParams args, string token, IMessageChannel channel, RequestOptions options = null) { - var model = await client.ApiClient.CreateInteractionFollowupMessage(args, token, options).ConfigureAwait(false); + var model = await client.ApiClient.CreateInteractionFollowupMessageAsync(args, token, options).ConfigureAwait(false); RestFollowupMessage entity = RestFollowupMessage.Create(client, model, token, channel); return entity; @@ -123,7 +123,7 @@ namespace Discord.Rest models.Add(model); } - return await client.ApiClient.BulkOverwriteGlobalApplicationCommands(models.ToArray(), options).ConfigureAwait(false); + return await client.ApiClient.BulkOverwriteGlobalApplicationCommandsAsync(models.ToArray(), options).ConfigureAwait(false); } public static async Task> BulkOverwriteGuildCommands(BaseDiscordClient client, ulong guildId, @@ -160,7 +160,7 @@ namespace Discord.Rest models.Add(model); } - return await client.ApiClient.BulkOverwriteGuildApplicationCommands(guildId, models.ToArray(), options).ConfigureAwait(false); + return await client.ApiClient.BulkOverwriteGuildApplicationCommandsAsync(guildId, models.ToArray(), options).ConfigureAwait(false); } private static TArg GetApplicationCommandProperties(IApplicationCommand command) @@ -367,11 +367,11 @@ namespace Discord.Rest Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional.Unspecified, }; - return await client.ApiClient.ModifyInteractionFollowupMessage(apiArgs, message.Id, message.Token, options).ConfigureAwait(false); + return await client.ApiClient.ModifyInteractionFollowupMessageAsync(apiArgs, message.Id, message.Token, options).ConfigureAwait(false); } public static async Task DeleteFollowupMessage(BaseDiscordClient client, RestFollowupMessage message, RequestOptions options = null) - => await client.ApiClient.DeleteInteractionFollowupMessage(message.Id, message.Token, options); + => await client.ApiClient.DeleteInteractionFollowupMessageAsync(message.Id, message.Token, options); public static async Task ModifyInteractionResponse(BaseDiscordClient client, string token, Action func, RequestOptions options = null) @@ -411,18 +411,18 @@ namespace Discord.Rest Flags = args.Flags }; - return await client.ApiClient.ModifyInteractionResponse(apiArgs, token, options).ConfigureAwait(false); + return await client.ApiClient.ModifyInteractionResponseAsync(apiArgs, token, options).ConfigureAwait(false); } public static async Task DeletedInteractionResponse(BaseDiscordClient client, RestInteractionMessage message, RequestOptions options = null) - => await client.ApiClient.DeleteInteractionFollowupMessage(message.Id, message.Token, options); + => await client.ApiClient.DeleteInteractionFollowupMessageAsync(message.Id, message.Token, options); #endregion #region Guild permissions public static async Task> GetGuildCommandPermissionsAsync(BaseDiscordClient client, ulong guildId, RequestOptions options) { - var models = await client.ApiClient.GetGuildApplicationCommandPermissions(guildId, options); + var models = await client.ApiClient.GetGuildApplicationCommandPermissionsAsync(guildId, options); return models.Select(x => new GuildApplicationCommandPermission(x.Id, x.ApplicationId, guildId, x.Permissions.Select( y => new Discord.ApplicationCommandPermission(y.Id, y.Type, y.Permission)) @@ -435,7 +435,7 @@ namespace Discord.Rest { try { - var model = await client.ApiClient.GetGuildApplicationCommandPermission(guildId, commandId, options); + var model = await client.ApiClient.GetGuildApplicationCommandPermissionAsync(guildId, commandId, options); return new GuildApplicationCommandPermission(model.Id, model.ApplicationId, guildId, model.Permissions.Select( y => new ApplicationCommandPermission(y.Id, y.Type, y.Permission)).ToArray()); } @@ -473,7 +473,7 @@ namespace Discord.Rest Permissions = permissionsList.ToArray() }; - var apiModel = await client.ApiClient.ModifyApplicationCommandPermissions(model, guildId, commandId, options); + var apiModel = await client.ApiClient.ModifyApplicationCommandPermissionsAsync(model, guildId, commandId, options); return new GuildApplicationCommandPermission(apiModel.Id, apiModel.ApplicationId, guildId, apiModel.Permissions.Select( x => new ApplicationCommandPermission(x.Id, x.Type, x.Permission)).ToArray()); @@ -505,7 +505,7 @@ namespace Discord.Rest models.Add(model); } - var apiModels = await client.ApiClient.BatchModifyApplicationCommandPermissions(models.ToArray(), guildId, options); + var apiModels = await client.ApiClient.BatchModifyApplicationCommandPermissionsAsync(models.ToArray(), guildId, options); return apiModels.Select( x => new GuildApplicationCommandPermission(x.Id, x.ApplicationId, x.GuildId, x.Permissions.Select( diff --git a/src/Discord.Net.Rest/Entities/Roles/RestRole.cs b/src/Discord.Net.Rest/Entities/Roles/RestRole.cs index 03e954f47..69a2abe20 100644 --- a/src/Discord.Net.Rest/Entities/Roles/RestRole.cs +++ b/src/Discord.Net.Rest/Entities/Roles/RestRole.cs @@ -97,5 +97,7 @@ namespace Discord.Rest throw new InvalidOperationException("Unable to return this entity's parent unless it was fetched through that object."); } } + + #endregion } } diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index 610555b61..dd0866f0c 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -1393,29 +1393,6 @@ - - - Gets or sets whether or not interactions are acknowledge with source. - - - - Discord interactions will not appear in chat until the client responds to them. With this option set to - , the client will automatically acknowledge the interaction with . - See the docs on - responding to interactions for more info. - - - With this option set to , you will have to acknowledge the interaction with - . - Only after the interaction is acknowledged, the original slash command message will be visible. - - - Please note that manually acknowledging the interaction with a message reply will not provide any return data. - Automatically acknowledging the interaction without sending the message will allow for follow up responses to - be used; follow up responses return the message data sent. - - - Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. @@ -3572,6 +3549,21 @@ + + + Moves the user to the voice channel. + + The user to move. + the channel where the user gets moved to. + A task that represents the asynchronous operation for moving a user. + + + + Disconnects the user from its current voice channel + + The user to disconnect. + A task that represents the asynchronous operation for disconnecting a user. + Gets a specific sticker within this guild. @@ -4189,7 +4181,7 @@ Responds to an Interaction with type . - If you have set to , You should use + If you have set to , You should use instead. diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 007e9f68a..2b9ac9ff8 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -72,8 +72,6 @@ namespace Discord.WebSocket internal WebSocketProvider WebSocketProvider { get; private set; } internal bool AlwaysDownloadUsers { get; private set; } internal int? HandlerTimeout { get; private set; } - internal bool AlwaysAcknowledgeInteractions { get; private set; } - internal new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient; /// public override IReadOnlyCollection Guilds => State.Guilds; @@ -143,7 +141,6 @@ namespace Discord.WebSocket UdpSocketProvider = config.UdpSocketProvider; WebSocketProvider = config.WebSocketProvider; AlwaysDownloadUsers = config.AlwaysDownloadUsers; - AlwaysAcknowledgeInteractions = config.AlwaysAcknowledgeInteractions; HandlerTimeout = config.HandlerTimeout; State = new ClientState(0, 0); Rest = new DiscordSocketRestClient(config, ApiClient); @@ -2095,9 +2092,6 @@ namespace Discord.WebSocket var interaction = SocketInteraction.Create(this, data, channel as ISocketMessageChannel); - if (this.AlwaysAcknowledgeInteractions) - await interaction.DeferAsync().ConfigureAwait(false); - await TimedInvokeAsync(_interactionCreatedEvent, nameof(InteractionCreated), interaction).ConfigureAwait(false); switch (interaction) diff --git a/src/Discord.Net.WebSocket/DiscordSocketConfig.cs b/src/Discord.Net.WebSocket/DiscordSocketConfig.cs index 6ce9489f6..22a201c67 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketConfig.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketConfig.cs @@ -105,29 +105,6 @@ namespace Discord.WebSocket /// public bool AlwaysDownloadUsers { get; set; } = false; - /// - /// Gets or sets whether or not interactions are acknowledge with source. - /// - /// - /// - /// Discord interactions will not appear in chat until the client responds to them. With this option set to - /// , the client will automatically acknowledge the interaction with . - /// See the docs on - /// responding to interactions for more info. - /// - /// - /// With this option set to , you will have to acknowledge the interaction with - /// . - /// Only after the interaction is acknowledged, the original slash command message will be visible. - /// - /// - /// Please note that manually acknowledging the interaction with a message reply will not provide any return data. - /// Automatically acknowledging the interaction without sending the message will allow for follow up responses to - /// be used; follow up responses return the message data sent. - /// - /// - public bool AlwaysAcknowledgeInteractions { get; set; } = true; - /// /// Gets or sets the timeout for event handlers, in milliseconds, after which a warning will be logged. /// Setting this property to nulldisables this check. 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 2a3ee4ba3..5daffc2cd 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs @@ -86,12 +86,6 @@ namespace Discord.WebSocket if (embeds == null && embed != null) embeds = new[] { embed }; - if (Discord.AlwaysAcknowledgeInteractions) - { - await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, options); - return; - } - 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."); @@ -341,7 +335,7 @@ namespace Discord.WebSocket }; - return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options); + return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); } /// @@ -354,7 +348,7 @@ namespace Discord.WebSocket }; - return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options); + return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); } } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs index 4161a8473..c65048a34 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketBaseCommand/SocketCommandBase.cs @@ -70,12 +70,6 @@ namespace Discord.WebSocket if (embeds == null && embed != null) embeds = new[] { embed }; - if (Discord.AlwaysAcknowledgeInteractions) - { - await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, options, component); - return; - } - 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."); @@ -244,7 +238,7 @@ namespace Discord.WebSocket } }; - return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options); + return Discord.Rest.ApiClient.CreateInteractionResponseAsync(response, this.Id, this.Token, options); } } }