Working version of Interactions. All public classes/members now have correct documentation. Added AlwaysAcknowledgeInteractions to the socket client config
/// The option type of the Slash command parameter, See <see href="https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype"/>
/// The option type of the Slash command parameter, See <see href="https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype">the discord docs</see>.
/// The base command model that belongs to an application. see <see href="https://discord.com/developers/docs/interactions/slash-commands#applicationcommand"/>
/// 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
{
/// <summary>
/// Gets the unique id of the command
/// Gets the unique id of the command.
/// </summary>
ulong Id { get; }
/// <summary>
/// Gets the unique id of the parent application
/// Gets the unique id of the parent application.
/// </summary>
ulong ApplicationId { get; }
/// <summary>
/// The name of the command
/// The name of the command.
/// </summary>
string Name { get; }
/// <summary>
/// The description of the command
/// The description of the command.
/// </summary>
string Description { get; }
/// <summary>
/// Modifies this command
/// If the option is a subcommand or subcommand group type, this nested options will be the parameters.
/// Represents data of an Interaction Command, see <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata"/>
/// Represents data of an Interaction Command, see <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata"/>
/// </summary>
public interface IApplicationCommandInteractionData
/// Represents a option group for a command, see <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption"/>
/// Represents a option group for a command, see <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption"/>
/// </summary>
public interface IApplicationCommandInteractionDataOption
{
/// <summary>
/// The name of the parameter
/// The name of the parameter.
/// </summary>
string Name { get; }
/// <summary>
/// The value of the pair
/// The value of the pair.
/// <note>
/// This objects type can be any one of the option types in <see cref="ApplicationCommandOptionType"/>
/// </note>
/// </summary>
ApplicationCommandOptionType? Value { get; }
object? Value { get; }
/// <summary>
/// Present if this option is a group or subcommand
/// Present if this option is a group or subcommand.
/// Options for the <see cref="IApplicationCommand"/>, see <see href="https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption"/>
/// Options for the <see cref="IApplicationCommand"/>, see <see href="https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption"/>The docs</see>.
/// </summary>
public interface IApplicationCommandOption
{
/// <summary>
/// The type of this <see cref="IApplicationCommandOption"/>
/// The type of this <see cref="IApplicationCommandOption"/>.
/// </summary>
ApplicationCommandOptionType Type { get; }
/// <summary>
/// The name of this command option, 1-32 character name.
/// The name of this command option, 1-32 character name.
/// </summary>
string Name { get; }
/// <summary>
/// The discription of this command option, 1-100 character description
/// The discription of this command option, 1-100 character description.
/// </summary>
string Description { get; }
/// <summary>
/// the first required option for the user to complete--only one option can be default
/// The first required option for the user to complete--only one option can be default.
/// </summary>
bool? Default { get; }
/// <summary>
/// if the parameter is required or optional--default <see langword="false"/>
/// If the parameter is required or optional, default is <see langword="false"/>.
/// </summary>
bool? Required { get; }
/// <summary>
/// choices for string and int types for the user to pick from
/// Choices for string and int types for the user to pick from.
/// An interaction is the base "thing" that is sent when a user invokes a command, and is the same for Slash Commands and other future interaction types.
/// see <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction"/>
/// Represents a discord interaction
/// <para>
/// An interaction is the base "thing" that is sent when a user invokes a command, and is the same for Slash Commands
/// and other future interaction types. see <see href="https://discord.com/developers/docs/interactions/slash-commands#interaction"/>.
/// </para>
/// </summary>
public interface IDiscordInteraction : ISnowflakeEntity
{
/// <summary>
/// id of the interaction
/// The id of the interaction.
/// </summary>
ulong Id { get; }
/// <summary>
/// The type of this <see cref="IDiscordInteraction"/>
/// The type of this <see cref="IDiscordInteraction"/>.
/// </summary>
InteractionType Type { get; }
/// <summary>
/// The command data payload
/// The command data payload.
/// </summary>
IApplicationCommandInteractionData? Data { get; }
/// <summary>
/// The guild it was sent from
/// </summary>
ulong GuildId { get; }
/// <summary>
/// The channel it was sent from
/// </summary>
ulong ChannelId { get; }
/// <summary>
/// Guild member id for the invoking user
/// </summary>
ulong MemberId { get; }
/// <summary>
/// A continuation token for responding to the interaction
/// A continuation token for responding to the interaction.
if (args.Content?.Length > DiscordConfig.MaxMessageSize)
throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content));
if (args.Content?.Length > DiscordConfig.MaxMessageSize)
throw new ArgumentException(message: $"Message content is too long, length must be less or equal to {DiscordConfig.MaxMessageSize}.", paramName: nameof(args.Content));
/// If you have <see cref="DiscordSocketConfig.AlwaysAcknowledgeInteractions"/> set to <see langword="true"/>, this method
/// will be obsolete and will use <see cref="FollowupAsync(string, bool, Embed, InteractionResponseType, AllowedMentions, RequestOptions)"/>
/// </para>
/// </summary>
/// <param name="text">The text of the message to be sent</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="embed">A <see cref="Embed"/> to send with this response</param>
/// <param name="Type">The type of response to this Interaction</param>
/// <param name="allowedMentions">The allowed mentions for this response</param>
/// <param name="options">The request options for this response</param>
/// <returns>
/// The <see cref="IMessage"/> sent as the response. If this is the first acknowledgement, it will return null;
/// </returns>
/// <exception cref="ArgumentOutOfRangeException">Message content is too long, length must be less or equal to <see cref="DiscordConfig.MaxMessageSize"/>.</exception>
public async Task<IMessage> RespondAsync(string text = null, bool isTTS = false, Embed embed = null, InteractionResponseType Type = InteractionResponseType.ChannelMessageWithSource, AllowedMentions allowedMentions = null, RequestOptions options = null)
{
if (Type == InteractionResponseType.ACKWithSource || Type == InteractionResponseType.ACKWithSource || Type == InteractionResponseType.Pong)
throw new InvalidOperationException($"Cannot use {Type} on a send message function");
if (!IsValidToken)
throw new InvalidOperationException("Interaction token is no longer valid");
if (Discord.AlwaysAcknowledgeInteractions)
return await FollowupAsync();
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.");
// check that user flag and user Id list are exclusive, same with role flag and role Id list
if (allowedMentions != null && allowedMentions.AllowedTypes.HasValue)
{
if (allowedMentions.AllowedTypes.Value.HasFlag(AllowedMentionTypes.Users) &&
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.