Class SocketCommandBase
Base class for User, Message, and Slash command interactions.
public class SocketCommandBase : SocketInteraction, IDiscordInteraction, ISnowflakeEntity, IEntity<ulong>
- Inheritance
-
SocketCommandBase
- Implements
- Derived
- Inherited Members
- Extension Methods
Properties
CommandId
Gets the id of the invoked command.
public ulong CommandId { get; }
Property Value
CommandName
Gets the name of the invoked command.
public string CommandName { get; }
Property Value
HasResponded
Gets whether or not this interaction has been responded to.
public override bool HasResponded { get; }
Property Value
Remarks
This property is locally set -- if you're running multiple bots off the same token then this property won't be in sync with them.
Methods
DeferAsync(bool, RequestOptions)
Acknowledges this interaction with the DeferredChannelMessageWithSource.
public override Task DeferAsync(bool ephemeral = false, RequestOptions options = null)
Parameters
ephemeralbooloptionsRequestOptions
Returns
- Task
A task that represents the asynchronous operation of acknowledging the interaction.
FollowupAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Sends a followup message for this interaction.
public override Task<RestFollowupMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
Parameters
textstringThe text of the message to be sent.
embedsEmbed[]A array of embeds to send with this response. Max 10.
isTTSbooltrue if the message should be read out by a text-to-speech reader, otherwise false.
ephemeralbooltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
allowedMentionsAllowedMentionsThe allowed mentions for this response.
componentsMessageComponentA MessageComponent to be sent with this response.
embedEmbedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.
optionsRequestOptionsThe request options for this response.
pollPollPropertiesA poll to send with the message.
flagsMessageFlags
Returns
- Task<RestFollowupMessage>
The sent message.
FollowupWithFilesAsync(IEnumerable<FileAttachment>, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Sends a followup message for this interaction.
public override Task<RestFollowupMessage> FollowupWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
Parameters
attachmentsIEnumerable<FileAttachment>A collection of attachments to upload.
textstringThe text of the message to be sent.
embedsEmbed[]A array of embeds to send with this response. Max 10.
isTTSbooltrue if the message should be read out by a text-to-speech reader, otherwise false.
ephemeralbooltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
allowedMentionsAllowedMentionsThe allowed mentions for this response.
componentsMessageComponentA MessageComponent to be sent with this response.
embedEmbedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.
optionsRequestOptionsThe request options for this response.
pollPollPropertiesA poll to send with the message.
flagsMessageFlags
Returns
- Task<RestFollowupMessage>
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
RespondAsync(string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Responds to an Interaction with type ChannelMessageWithSource.
public override Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
Parameters
textstringThe text of the message to be sent.
embedsEmbed[]A array of embeds to send with this response. Max 10.
isTTSbooltrue if the message should be read out by a text-to-speech reader, otherwise false.
ephemeralbooltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
allowedMentionsAllowedMentionsThe allowed mentions for this response.
componentsMessageComponentA MessageComponent to be sent with this response.
embedEmbedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.
optionsRequestOptionsThe request options for this response.
pollPollPropertiesA poll to send with the message.
flagsMessageFlags
Returns
Exceptions
- ArgumentOutOfRangeException
Message content is too long, length must be less or equal to MaxMessageSize.
- InvalidOperationException
The parameters provided were invalid or the token was invalid.
RespondWithFilesAsync(IEnumerable<FileAttachment>, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Responds to this interaction with a collection of file attachments.
public override Task RespondWithFilesAsync(IEnumerable<FileAttachment> attachments, string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, MessageComponent components = null, Embed embed = null, RequestOptions options = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)
Parameters
attachmentsIEnumerable<FileAttachment>A collection of attachments to upload.
textstringThe text of the message to be sent.
embedsEmbed[]A array of embeds to send with this response. Max 10.
isTTSbooltrue if the message should be read out by a text-to-speech reader, otherwise false.
ephemeralbooltrue if the response should be hidden to everyone besides the invoker of the command, otherwise false.
allowedMentionsAllowedMentionsThe allowed mentions for this response.
componentsMessageComponentA MessageComponent to be sent with this response.
embedEmbedA single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.
optionsRequestOptionsThe request options for this response.
pollPollPropertiesA poll to send with the message.
flagsMessageFlags
Returns
- Task
A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message.
RespondWithModalAsync(Modal, RequestOptions)
Responds to this interaction with a Modal.
public override Task RespondWithModalAsync(Modal modal, RequestOptions options = null)
Parameters
modalModalThe Modal to respond with.
optionsRequestOptionsThe request options for this async request.
Returns
- Task
A task that represents the asynchronous operation of responding to the interaction.