@@ -3914,6 +3914,16 @@ | |||
A task that represents the asynchronous removal operation. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.IGuild.GetApplicationCommandsAsync(Discord.RequestOptions)"> | |||
<summary> | |||
Gets this guilds slash commands commands | |||
</summary> | |||
<param name="options">The options to be used when sending the request.</param> | |||
<returns> | |||
A task that represents the asynchronous get operation. The task result contains a read-only collection | |||
of application commands found within the guild. | |||
</returns> | |||
</member> | |||
<member name="T:Discord.IGuildIntegration"> | |||
<summary> | |||
Holds information for a guild integration feature. | |||
@@ -4504,13 +4514,6 @@ | |||
If the option is a subcommand or subcommand group type, this nested options will be the parameters. | |||
</summary> | |||
</member> | |||
<member name="M:Discord.IApplicationCommand.DeleteAsync(Discord.RequestOptions)"> | |||
<summary> | |||
Deletes this command | |||
</summary> | |||
<param name="options">The options to be used when sending the request.</param> | |||
<returns>A task that represents the asynchronous delete operation.</returns> | |||
</member> | |||
<member name="T:Discord.IApplicationCommandInteractionData"> | |||
<summary> | |||
Represents data of an Interaction Command, see <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata"/>. | |||
@@ -4644,6 +4647,58 @@ | |||
read-only property, always 1. | |||
</summary> | |||
</member> | |||
<member name="M:Discord.IDiscordInteraction.RespondAsync(System.String,Discord.Embed[],System.Boolean,System.Boolean,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.Embed)"> | |||
<summary> | |||
Responds to an Interaction with type <see cref="F:Discord.InteractionResponseType.ChannelMessageWithSource"/>. | |||
</summary> | |||
<param name="text">The text of the message to be sent.</param> | |||
<param name="embeds">A array of embeds to send with this response. Max 10</param> | |||
<param name="isTTS"><see langword="true"/> if the message should be read out by a text-to-speech reader, otherwise <see langword="false"/>.</param> | |||
<param name="ephemeral"><see langword="true"/> if the response should be hidden to everyone besides the invoker of the command, otherwise <see langword="false"/>.</param> | |||
<param name="allowedMentions">The allowed mentions for this response.</param> | |||
<param name="options">The request options for this response.</param> | |||
<param name="component">A <see cref="T:Discord.MessageComponent"/> to be sent with this response</param> | |||
<param name="embed">A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.</param> | |||
</member> | |||
<member name="M:Discord.IDiscordInteraction.FollowupAsync(System.String,Discord.Embed[],System.Boolean,System.Boolean,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.Embed)"> | |||
<summary> | |||
Sends a followup message for this interaction. | |||
</summary> | |||
<param name="text">The text of the message to be sent</param> | |||
<param name="embeds">A array of embeds to send with this response. Max 10</param> | |||
<param name="isTTS"><see langword="true"/> if the message should be read out by a text-to-speech reader, otherwise <see langword="false"/>.</param> | |||
<param name="ephemeral"><see langword="true"/> if the response should be hidden to everyone besides the invoker of the command, otherwise <see langword="false"/>.</param> | |||
<param name="allowedMentions">The allowed mentions for this response.</param> | |||
<param name="options">The request options for this response.</param> | |||
<param name="component">A <see cref="T:Discord.MessageComponent"/> to be sent with this response</param> | |||
<param name="embed">A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.</param> | |||
<returns> | |||
The sent message. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.IDiscordInteraction.GetOriginalResponseAsync(Discord.RequestOptions)"> | |||
<summary> | |||
Gets the original response for this interaction. | |||
</summary> | |||
<param name="options">The request options for this async request.</param> | |||
<returns>A <see cref="T:Discord.IUserMessage"/> that represents the initial response.</returns> | |||
</member> | |||
<member name="M:Discord.IDiscordInteraction.ModifyOriginalResponseAsync(System.Action{Discord.MessageProperties},Discord.RequestOptions)"> | |||
<summary> | |||
Edits original response for this interaction. | |||
</summary> | |||
<param name="func">A delegate containing the properties to modify the message with.</param> | |||
<param name="options">The request options for this async request.</param> | |||
<returns>A <see cref="T:Discord.IUserMessage"/> that represents the initial response.</returns> | |||
</member> | |||
<member name="M:Discord.IDiscordInteraction.DeferAsync(Discord.RequestOptions)"> | |||
<summary> | |||
Acknowledges this interaction. | |||
</summary> | |||
<returns> | |||
A task that represents the asynchronous operation of acknowledging the interaction. | |||
</returns> | |||
</member> | |||
<member name="T:Discord.IDiscordInteractionData"> | |||
<summary> | |||
Represents an interface used to specify classes that they are a vaild dataype of a <see cref="T:Discord.IDiscordInteraction"/> class. | |||
@@ -4794,6 +4849,11 @@ | |||
Represents a builder for creating a <see cref="T:Discord.MessageComponent"/>. | |||
</summary> | |||
</member> | |||
<member name="F:Discord.ComponentBuilder.MaxButtonLabelLength"> | |||
<summary> | |||
The max length of a <see cref="P:Discord.ButtonComponent.Label"/>. | |||
</summary> | |||
</member> | |||
<member name="F:Discord.ComponentBuilder.MaxCustomIdLength"> | |||
<summary> | |||
The max length of a <see cref="P:Discord.ButtonComponent.CustomId"/>. | |||
@@ -4921,7 +4981,7 @@ | |||
<summary> | |||
Gets or sets the label of the current button. | |||
</summary> | |||
<exception cref="T:System.ArgumentException" accessor="set"><see cref="P:Discord.ButtonBuilder.Label"/> length exceeds <see cref="F:Discord.ButtonBuilder.MaxLabelLength"/>.</exception> | |||
<exception cref="T:System.ArgumentException" accessor="set"><see cref="P:Discord.ButtonBuilder.Label"/> length exceeds <see cref="F:Discord.ComponentBuilder.MaxButtonLabelLength"/>.</exception> | |||
</member> | |||
<member name="P:Discord.ButtonBuilder.CustomId"> | |||
<summary> | |||
@@ -5251,11 +5311,16 @@ | |||
The maximum length of a <see cref="P:Discord.SelectMenuOption.Description"/>. | |||
</summary> | |||
</member> | |||
<member name="F:Discord.SelectMenuOptionBuilder.MaxSelectLabelLength"> | |||
<summary> | |||
The maximum length of a <see cref="P:Discord.SelectMenuOption.Label"/>. | |||
</summary> | |||
</member> | |||
<member name="P:Discord.SelectMenuOptionBuilder.Label"> | |||
<summary> | |||
Gets or sets the label of the current select menu. | |||
</summary> | |||
<exception cref="T:System.ArgumentException" accessor="set"><see cref="P:Discord.SelectMenuOptionBuilder.Label"/> length exceeds <see cref="F:Discord.SelectMenuOptionBuilder.MaxLabelLength"/></exception> | |||
<exception cref="T:System.ArgumentException" accessor="set"><see cref="P:Discord.SelectMenuOptionBuilder.Label"/> length exceeds <see cref="F:Discord.SelectMenuOptionBuilder.MaxSelectLabelLength"/></exception> | |||
</member> | |||
<member name="P:Discord.SelectMenuOptionBuilder.Value"> | |||
<summary> | |||
@@ -941,5 +941,15 @@ namespace Discord | |||
/// A task that represents the asynchronous removal operation. | |||
/// </returns> | |||
Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null); | |||
/// <summary> | |||
/// Gets this guilds slash commands commands | |||
/// </summary> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns> | |||
/// A task that represents the asynchronous get operation. The task result contains a read-only collection | |||
/// of application commands found within the guild. | |||
/// </returns> | |||
Task<IReadOnlyCollection<IApplicationCommand>> GetApplicationCommandsAsync (RequestOptions options = null); | |||
} | |||
} |
@@ -9,7 +9,7 @@ namespace Discord | |||
/// <summary> | |||
/// The base command model that belongs to an application. see <see href="https://discord.com/developers/docs/interactions/slash-commands#applicationcommand"/> | |||
/// </summary> | |||
public interface IApplicationCommand : ISnowflakeEntity | |||
public interface IApplicationCommand : ISnowflakeEntity, IDeletable | |||
{ | |||
/// <summary> | |||
/// Gets the unique id of the parent application. | |||
@@ -35,12 +35,5 @@ namespace Discord | |||
/// If the option is a subcommand or subcommand group type, this nested options will be the parameters. | |||
/// </summary> | |||
IReadOnlyCollection<IApplicationCommandOption> Options { get; } | |||
/// <summary> | |||
/// Deletes this command | |||
/// </summary> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns>A task that represents the asynchronous delete operation.</returns> | |||
Task DeleteAsync(RequestOptions options = null); | |||
} | |||
} |
@@ -39,5 +39,59 @@ namespace Discord | |||
/// read-only property, always 1. | |||
/// </summary> | |||
int Version { get; } | |||
/// <summary> | |||
/// Responds to an Interaction with type <see cref="InteractionResponseType.ChannelMessageWithSource"/>. | |||
/// </summary> | |||
/// <param name="text">The text of the message to be sent.</param> | |||
/// <param name="embeds">A array of embeds to send with this response. Max 10</param> | |||
/// <param name="isTTS"><see langword="true"/> if the message should be read out by a text-to-speech reader, otherwise <see langword="false"/>.</param> | |||
/// <param name="ephemeral"><see langword="true"/> if the response should be hidden to everyone besides the invoker of the command, otherwise <see langword="false"/>.</param> | |||
/// <param name="allowedMentions">The allowed mentions for this response.</param> | |||
/// <param name="options">The request options for this response.</param> | |||
/// <param name="component">A <see cref="MessageComponent"/> to be sent with this response</param> | |||
/// <param name="embed">A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.</param> | |||
Task RespondAsync (string text = null, Embed[] embeds = null, bool isTTS = false, | |||
bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null); | |||
/// <summary> | |||
/// Sends a followup message for this interaction. | |||
/// </summary> | |||
/// <param name="text">The text of the message to be sent</param> | |||
/// <param name="embeds">A array of embeds to send with this response. Max 10</param> | |||
/// <param name="isTTS"><see langword="true"/> if the message should be read out by a text-to-speech reader, otherwise <see langword="false"/>.</param> | |||
/// <param name="ephemeral"><see langword="true"/> if the response should be hidden to everyone besides the invoker of the command, otherwise <see langword="false"/>.</param> | |||
/// <param name="allowedMentions">The allowed mentions for this response.</param> | |||
/// <param name="options">The request options for this response.</param> | |||
/// <param name="component">A <see cref="MessageComponent"/> to be sent with this response</param> | |||
/// <param name="embed">A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.</param> | |||
/// <returns> | |||
/// The sent message. | |||
/// </returns> | |||
Task<IUserMessage> FollowupAsync (string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, | |||
AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null); | |||
/// <summary> | |||
/// Gets the original response for this interaction. | |||
/// </summary> | |||
/// <param name="options">The request options for this async request.</param> | |||
/// <returns>A <see cref="IUserMessage"/> that represents the initial response.</returns> | |||
Task<IUserMessage> GetOriginalResponseAsync (RequestOptions options = null); | |||
/// <summary> | |||
/// Edits original response for this interaction. | |||
/// </summary> | |||
/// <param name="func">A delegate containing the properties to modify the message with.</param> | |||
/// <param name="options">The request options for this async request.</param> | |||
/// <returns>A <see cref="IUserMessage"/> that represents the initial response.</returns> | |||
Task<IUserMessage> ModifyOriginalResponseAsync (Action<MessageProperties> func, RequestOptions options = null); | |||
/// <summary> | |||
/// Acknowledges this interaction. | |||
/// </summary> | |||
/// <returns> | |||
/// A task that represents the asynchronous operation of acknowledging the interaction. | |||
/// </returns> | |||
Task DeferAsync (RequestOptions options = null); | |||
} | |||
} |
@@ -10,6 +10,11 @@ namespace Discord | |||
/// </summary> | |||
public class ComponentBuilder | |||
{ | |||
/// <summary> | |||
/// The max length of a <see cref="ButtonComponent.Label"/>. | |||
/// </summary> | |||
public const int MaxButtonLabelLength = 80; | |||
/// <summary> | |||
/// The max length of a <see cref="ButtonComponent.CustomId"/>. | |||
/// </summary> | |||
@@ -310,14 +315,14 @@ namespace Discord | |||
/// <summary> | |||
/// Gets or sets the label of the current button. | |||
/// </summary> | |||
/// <exception cref="ArgumentException" accessor="set"><see cref="Label"/> length exceeds <see cref="MaxLabelLength"/>.</exception> | |||
/// <exception cref="ArgumentException" accessor="set"><see cref="Label"/> length exceeds <see cref="ComponentBuilder.MaxButtonLabelLength"/>.</exception> | |||
public string Label | |||
{ | |||
get => _label; | |||
set | |||
{ | |||
if (value != null && value.Length > MaxLabelLength) | |||
throw new ArgumentException(message: $"Button label must be {MaxLabelLength} characters or less!", paramName: nameof(Label)); | |||
if (value != null && value.Length > ComponentBuilder.MaxButtonLabelLength) | |||
throw new ArgumentException(message: $"Button label must be {ComponentBuilder.MaxButtonLabelLength} characters or less!", paramName: nameof(Label)); | |||
_label = value; | |||
} | |||
@@ -840,19 +845,24 @@ namespace Discord | |||
/// The maximum length of a <see cref="SelectMenuOption.Description"/>. | |||
/// </summary> | |||
public const int MaxDescriptionLength = 100; | |||
/// <summary> | |||
/// The maximum length of a <see cref="SelectMenuOption.Label"/>. | |||
/// </summary> | |||
public const int MaxSelectLabelLength = 100; | |||
/// <summary> | |||
/// Gets or sets the label of the current select menu. | |||
/// </summary> | |||
/// <exception cref="ArgumentException" accessor="set"><see cref="Label"/> length exceeds <see cref="MaxLabelLength"/></exception> | |||
/// <exception cref="ArgumentException" accessor="set"><see cref="Label"/> length exceeds <see cref="MaxSelectLabelLength"/></exception> | |||
public string Label | |||
{ | |||
get => _label; | |||
set | |||
{ | |||
if (value != null) | |||
if (value.Length > MaxLabelLength) | |||
throw new ArgumentException(message: $"Button label must be {MaxLabelLength} characters or less!", paramName: nameof(Label)); | |||
if (value.Length > MaxSelectLabelLength) | |||
throw new ArgumentException(message: $"Button label must be {MaxSelectLabelLength} characters or less!", paramName: nameof(Label)); | |||
_label = value; | |||
} | |||
@@ -3493,6 +3493,16 @@ | |||
of webhooks found within the guild. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.Rest.RestGuild.GetApplicationCommandsAsync(Discord.RequestOptions)"> | |||
<summary> | |||
Gets this guilds slash commands commands | |||
</summary> | |||
<param name="options">The options to be used when sending the request.</param> | |||
<returns> | |||
A task that represents the asynchronous get operation. The task result contains a read-only collection | |||
of application commands found within the guild. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.Rest.RestGuild.ToString"> | |||
<summary> | |||
Returns the name of the guild. | |||
@@ -3650,6 +3660,9 @@ | |||
<member name="M:Discord.Rest.RestGuild.Discord#IGuild#GetWebhooksAsync(Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="M:Discord.Rest.RestGuild.Discord#IGuild#GetApplicationCommandsAsync(Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="P:Discord.Rest.RestGuildIntegration.Name"> | |||
<inheritdoc /> | |||
</member> | |||
@@ -869,6 +869,18 @@ namespace Discord.Rest | |||
public Task<IReadOnlyCollection<RestWebhook>> GetWebhooksAsync(RequestOptions options = null) | |||
=> GuildHelper.GetWebhooksAsync(this, Discord, options); | |||
//Interactions | |||
/// <summary> | |||
/// Gets this guilds slash commands commands | |||
/// </summary> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
/// <returns> | |||
/// A task that represents the asynchronous get operation. The task result contains a read-only collection | |||
/// of application commands found within the guild. | |||
/// </returns> | |||
public async Task<IReadOnlyCollection<RestApplicationCommand>> GetApplicationCommandsAsync (RequestOptions options = null) | |||
=> await ClientHelper.GetGuildApplicationCommands(Discord, Id, options).ConfigureAwait(false); | |||
/// <summary> | |||
/// Returns the name of the guild. | |||
/// </summary> | |||
@@ -1154,6 +1166,8 @@ namespace Discord.Rest | |||
/// <inheritdoc /> | |||
async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options) | |||
=> await GetWebhooksAsync(options).ConfigureAwait(false); | |||
/// <inheritdoc /> | |||
async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync (RequestOptions options) | |||
=> await GetApplicationCommandsAsync(options).ConfigureAwait(false); | |||
} | |||
} |
@@ -3599,6 +3599,9 @@ | |||
<member name="M:Discord.WebSocket.SocketGuild.Discord#IGuild#GetWebhooksAsync(Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="M:Discord.WebSocket.SocketGuild.Discord#IGuild#GetApplicationCommandsAsync(Discord.RequestOptions)"> | |||
<inheritdoc /> | |||
</member> | |||
<member name="T:Discord.WebSocket.SocketMessageComponent"> | |||
<summary> | |||
Represents a Websocket-based interaction type for Message Components. | |||
@@ -3897,6 +3900,15 @@ | |||
A task that represents the asynchronous operation of acknowledging the interaction. | |||
</returns> | |||
</member> | |||
<member name="M:Discord.WebSocket.SocketInteraction.Discord#IDiscordInteraction#FollowupAsync(System.String,Discord.Embed[],System.Boolean,System.Boolean,Discord.AllowedMentions,Discord.RequestOptions,Discord.MessageComponent,Discord.Embed)"> | |||
<inheritdoc/> | |||
</member> | |||
<member name="M:Discord.WebSocket.SocketInteraction.Discord#IDiscordInteraction#GetOriginalResponseAsync(Discord.RequestOptions)"> | |||
<inheritdoc/> | |||
</member> | |||
<member name="M:Discord.WebSocket.SocketInteraction.Discord#IDiscordInteraction#ModifyOriginalResponseAsync(System.Action{Discord.MessageProperties},Discord.RequestOptions)"> | |||
<inheritdoc/> | |||
</member> | |||
<member name="T:Discord.WebSocket.SocketInvite"> | |||
<summary> | |||
Represents a WebSocket-based invite to a guild. | |||
@@ -30,7 +30,16 @@ namespace Discord.WebSocket | |||
/// <inheritdoc /> | |||
public override IActivity Activity { get => _shards[0].Activity; protected set { } } | |||
internal new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient; | |||
internal new DiscordSocketApiClient ApiClient | |||
{ | |||
get | |||
{ | |||
if (base.ApiClient.CurrentUserId == null) | |||
base.ApiClient.CurrentUserId = CurrentUser?.Id; | |||
return base.ApiClient; | |||
} | |||
} | |||
/// <inheritdoc /> | |||
public override IReadOnlyCollection<SocketGuild> Guilds => GetGuilds().ToReadOnlyCollection(GetGuildCount); | |||
/// <inheritdoc /> | |||
@@ -1478,6 +1478,9 @@ namespace Discord.WebSocket | |||
/// <inheritdoc /> | |||
async Task<IReadOnlyCollection<IWebhook>> IGuild.GetWebhooksAsync(RequestOptions options) | |||
=> await GetWebhooksAsync(options).ConfigureAwait(false); | |||
/// <inheritdoc /> | |||
async Task<IReadOnlyCollection<IApplicationCommand>> IGuild.GetApplicationCommandsAsync (RequestOptions options) | |||
=> await GetApplicationCommandsAsync(options).ConfigureAwait(false); | |||
void IDisposable.Dispose() | |||
{ | |||
@@ -173,5 +173,20 @@ namespace Discord.WebSocket | |||
// Tokens last for 15 minutes according to https://discord.com/developers/docs/interactions/slash-commands#responding-to-an-interaction | |||
return (DateTime.UtcNow - this.CreatedAt.UtcDateTime).TotalMinutes <= 15d; | |||
} | |||
// IDiscordInteraction | |||
/// <inheritdoc/> | |||
async Task<IUserMessage> IDiscordInteraction.FollowupAsync (string text, Embed[] embeds, bool isTTS, bool ephemeral, AllowedMentions allowedMentions, | |||
RequestOptions options, MessageComponent component, Embed embed) | |||
=> await FollowupAsync(text, embeds, isTTS, ephemeral, allowedMentions, options, component, embed).ConfigureAwait(false); | |||
/// <inheritdoc/> | |||
async Task<IUserMessage> IDiscordInteraction.GetOriginalResponseAsync (RequestOptions options) | |||
=> await GetOriginalResponseAsync(options).ConfigureAwait(false); | |||
/// <inheritdoc/> | |||
async Task<IUserMessage> IDiscordInteraction.ModifyOriginalResponseAsync (Action<MessageProperties> func, RequestOptions options) | |||
=> await ModifyOriginalResponseAsync(func, options).ConfigureAwait(false); | |||
} | |||
} |