Class InteractionModuleBase<T>
- Namespace
- Discord.Interactions
- Assembly
- Discord.Net.Interactions.dll
Provides a base class for a command module to inherit from.
public abstract class InteractionModuleBase<T> : IInteractionModuleBase where T : class, IInteractionContextType Parameters
- T
- Type of interaction context to be injected into the module. 
- Inheritance
- 
      
      InteractionModuleBase<T>
- Implements
- Derived
- Inherited Members
Properties
Context
Gets the underlying context of the command.
public T Context { get; }Property Value
- T
Methods
AfterExecute(ICommandInfo)
Method body to be executed after an application command execution.
public virtual void AfterExecute(ICommandInfo command)Parameters
- commandICommandInfo
- Command information related to the Discord Application Command. 
AfterExecuteAsync(ICommandInfo)
Method body to be executed asynchronously after an application command execution.
public virtual Task AfterExecuteAsync(ICommandInfo command)Parameters
- commandICommandInfo
- Command information related to the Discord Application Command. 
Returns
BeforeExecute(ICommandInfo)
Method body to be executed before executing an application command.
public virtual void BeforeExecute(ICommandInfo command)Parameters
- commandICommandInfo
- Command information related to the Discord Application Command. 
BeforeExecuteAsync(ICommandInfo)
Method body to be executed asynchronously before executing an application command.
public virtual Task BeforeExecuteAsync(ICommandInfo command)Parameters
- commandICommandInfo
- Command information related to the Discord Application Command. 
Returns
Construct(ModuleBuilder, InteractionService)
Method body to be executed after the automated module creation is completed and before Build(InteractionService, IServiceProvider, ModuleInfo) is called.
public virtual void Construct(ModuleBuilder builder, InteractionService commandService)Parameters
- builderModuleBuilder
- Builder class of this module. 
- commandServiceInteractionService
- Command Service instance that is building this method. 
DeferAsync(bool, RequestOptions)
Acknowledges this interaction.
protected virtual Task DeferAsync(bool ephemeral = false, RequestOptions options = null)Parameters
- ephemeralbool
- optionsRequestOptions
Returns
- Task
- A task that represents the asynchronous operation of deferring the interaction. 
DeleteOriginalResponseAsync()
Deletes this object and all its children.
protected virtual Task DeleteOriginalResponseAsync()Returns
FollowupAsync(string, Embed[], bool, bool, AllowedMentions, RequestOptions, MessageComponent, Embed, PollProperties, MessageFlags)
Sends a followup message for this interaction.
protected virtual Task<IUserMessage> FollowupAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)Parameters
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- optionsRequestOptions
- The request options for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- pollPollProperties
- A poll to send with the message. 
- flagsMessageFlags
Returns
- Task<IUserMessage>
- A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. 
FollowupWithFileAsync(FileAttachment, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Sends a followup message for this interaction.
protected virtual Task<IUserMessage> FollowupWithFileAsync(FileAttachment attachment, 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
- attachmentFileAttachment
- The attachment containing the file and description. 
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- optionsRequestOptions
- The request options for this response. 
- pollPollProperties
- A poll to send with the message. 
- flagsMessageFlags
Returns
- Task<IUserMessage>
- A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. 
FollowupWithFileAsync(Stream, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Sends a followup message for this interaction.
protected virtual Task<IUserMessage> FollowupWithFileAsync(Stream fileStream, string fileName, 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
- fileStreamStream
- The file to upload. 
- fileNamestring
- The file name of the attachment. 
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- optionsRequestOptions
- The request options for this response. 
- pollPollProperties
- A poll to send with the message. 
- flagsMessageFlags
Returns
- Task<IUserMessage>
- A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. 
FollowupWithFileAsync(string, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Sends a followup message for this interaction.
protected virtual Task<IUserMessage> FollowupWithFileAsync(string filePath, string fileName = null, 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
- filePathstring
- The file to upload. 
- fileNamestring
- The file name of the attachment. 
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- optionsRequestOptions
- The request options for this response. 
- pollPollProperties
- A poll to send with the message. 
- flagsMessageFlags
Returns
- Task<IUserMessage>
- A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. 
FollowupWithFilesAsync(IEnumerable<FileAttachment>, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Sends a followup message for this interaction.
protected virtual Task<IUserMessage> 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. 
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- optionsRequestOptions
- The request options for this response. 
- pollPollProperties
- A poll to send with the message. 
- flagsMessageFlags
Returns
- Task<IUserMessage>
- A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. 
GetOriginalResponseAsync(RequestOptions)
Gets the original response for this interaction.
protected virtual Task<IUserMessage> GetOriginalResponseAsync(RequestOptions options = null)Parameters
- optionsRequestOptions
- The request options for this async request. 
Returns
- Task<IUserMessage>
- A IUserMessage that represents the initial response. 
ModifyOriginalResponseAsync(Action<MessageProperties>, RequestOptions)
Edits original response for this interaction.
protected virtual Task<IUserMessage> ModifyOriginalResponseAsync(Action<MessageProperties> func, RequestOptions options = null)Parameters
- funcAction<MessageProperties>
- A delegate containing the properties to modify the message with. 
- optionsRequestOptions
- The request options for this async request. 
Returns
- Task<IUserMessage>
- A task that represents an asynchronous modification operation. The task result contains the updated message. 
OnModuleBuilding(InteractionService, ModuleInfo)
Method body to be executed when Build(InteractionService, IServiceProvider, ModuleInfo) is called.
public virtual void OnModuleBuilding(InteractionService commandService, ModuleInfo module)Parameters
- commandServiceInteractionService
- Command Service instance that built this module. 
- moduleModuleInfo
- Info class of this module. 
ReplyAsync(string, bool, Embed, RequestOptions, AllowedMentions, MessageReference, MessageComponent, ISticker[], Embed[], MessageFlags, PollProperties)
Sends a message to this message channel.
protected virtual Task<IUserMessage> ReplyAsync(string text = null, bool isTTS = false, Embed embed = null, RequestOptions options = null, AllowedMentions allowedMentions = null, MessageReference messageReference = null, MessageComponent components = null, ISticker[] stickers = null, Embed[] embeds = null, MessageFlags flags = MessageFlags.None, PollProperties poll = null)Parameters
- textstring
- The message to be sent. 
- isTTSbool
- Determines whether the message should be read aloud by Discord or not. 
- embedEmbed
- optionsRequestOptions
- The options to be used when sending the request. 
- allowedMentionsAllowedMentions
- Specifies if notifications are sent for mentioned users and roles in the message - text. If null, all mentioned roles and users will be notified.
- messageReferenceMessageReference
- The message references to be included. Used to reply to specific messages. 
- componentsMessageComponent
- The message components to be included with this message. Used for interactions. 
- stickersISticker[]
- A collection of stickers to send with the message. 
- embedsEmbed[]
- A array of Embeds to send with this response. Max 10. 
- flagsMessageFlags
- A message flag to be applied to the sent message, only SuppressEmbeds and SuppressNotification is permitted. 
- pollPollProperties
- A poll to send with the message. 
Returns
- Task<IUserMessage>
- A task that represents an asynchronous send operation for delivering the message. The task result contains the sent message. 
Examples
The following example sends a message with the current system time in RFC 1123 format to the channel and deletes itself after 5 seconds.
RespondAsync(string, Embed[], bool, bool, AllowedMentions, RequestOptions, MessageComponent, Embed, PollProperties, MessageFlags)
Responds to an Interaction with type ChannelMessageWithSource.
protected virtual Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent components = null, Embed embed = null, PollProperties poll = null, MessageFlags flags = MessageFlags.None)Parameters
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- optionsRequestOptions
- The request options for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- pollPollProperties
- A poll to send with the message. 
- flagsMessageFlags
Returns
- Task
- A task that represents an asynchronous send operation for delivering the message. 
RespondWithFileAsync(FileAttachment, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Responds to this interaction with a file attachment.
protected virtual Task RespondWithFileAsync(FileAttachment attachment, 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
- attachmentFileAttachment
- The attachment containing the file and description. 
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- optionsRequestOptions
- The request options for this response. 
- pollPollProperties
- A 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. 
RespondWithFileAsync(Stream, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Responds to this interaction with a file attachment.
protected virtual Task RespondWithFileAsync(Stream fileStream, string fileName, 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
- fileStreamStream
- The file to upload. 
- fileNamestring
- The file name of the attachment. 
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- optionsRequestOptions
- The request options for this response. 
- pollPollProperties
- A 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. 
RespondWithFileAsync(string, string, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Responds to this interaction with a file attachment.
protected virtual Task RespondWithFileAsync(string filePath, string fileName = null, 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
- filePathstring
- The file to upload. 
- fileNamestring
- The file name of the attachment. 
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- optionsRequestOptions
- The request options for this response. 
- pollPollProperties
- A 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. 
RespondWithFilesAsync(IEnumerable<FileAttachment>, string, Embed[], bool, bool, AllowedMentions, MessageComponent, Embed, RequestOptions, PollProperties, MessageFlags)
Responds to this interaction with a collection of file attachments.
protected virtual 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. 
- textstring
- The text of the message to be sent. 
- embedsEmbed[]
- A array of embeds to send with this response. Max 10. 
- isTTSbool
- true if the message should be read out by a text-to-speech reader, otherwise false. 
- ephemeralbool
- true if the response should be hidden to everyone besides the invoker of the command, otherwise false. 
- allowedMentionsAllowedMentions
- The allowed mentions for this response. 
- componentsMessageComponent
- A MessageComponent to be sent with this response. 
- embedEmbed
- A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored. 
- optionsRequestOptions
- The request options for this response. 
- pollPollProperties
- A 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 the interaction with a modal.
protected virtual Task RespondWithModalAsync(Modal modal, RequestOptions options = null)Parameters
- modalModal
- The modal to respond with. 
- optionsRequestOptions
- The request options for this async request. 
Returns
- Task
- A task that represents the asynchronous operation of responding to the interaction. 
RespondWithModalAsync<TModal>(string, RequestOptions, Action<ModalBuilder>)
Respond to an interaction with a IModal.
protected virtual Task RespondWithModalAsync<TModal>(string customId, RequestOptions options = null, Action<ModalBuilder> modifyModal = null) where TModal : class, IModalParameters
- customIdstring
- optionsRequestOptions
- The request options for this async request. 
- modifyModalAction<ModalBuilder>
- Delegate that can be used to modify the modal. 
Returns
- Task
- A task that represents the asynchronous operation of responding to the interaction. 
Type Parameters
- TModal
RespondWithModalAsync<TModal>(string, TModal, RequestOptions, Action<ModalBuilder>)
Respond to an interaction with an IModal and fills the value fields of the modal using the property values of the provided instance.
protected virtual Task RespondWithModalAsync<TModal>(string customId, TModal modal, RequestOptions options = null, Action<ModalBuilder> modifyModal = null) where TModal : class, IModalParameters
- customIdstring
- modalTModal
- The IModal instance to get field values from. 
- optionsRequestOptions
- The request options for this async request. 
- modifyModalAction<ModalBuilder>
- Delegate that can be used to modify the modal. 
Returns
Type Parameters
- TModal
RespondWithPremiumRequiredAsync(RequestOptions)
Responds to the interaction with an ephemeral message the invoking user, instructing them that whatever they tried to do requires the premium benefits of your app.
protected virtual Task RespondWithPremiumRequiredAsync(RequestOptions options = null)Parameters
- optionsRequestOptions
Returns
- Task
- A task that represents the asynchronous operation of responding to the interaction.