Table of Contents

Class RestInteractionModuleBase<T>

Namespace
Discord.Interactions
Assembly
Discord.Net.Interactions.dll

Provides a base class for a Rest based command module to inherit from.

public abstract class RestInteractionModuleBase<T> : InteractionModuleBase<T>, IInteractionModuleBase where T : class, IInteractionContext

Type Parameters

T

Type of interaction context to be injected into the module.

Inheritance
RestInteractionModuleBase<T>
Implements
Inherited Members

Properties

InteractionService

Gets or sets the underlying Interaction Service.

public InteractionService InteractionService { get; set; }

Property Value

InteractionService

Methods

DeferAsync(bool, RequestOptions)

Defer a Rest based Discord Interaction using the RestResponseCallback delegate.

protected override Task DeferAsync(bool ephemeral = false, RequestOptions options = null)

Parameters

ephemeral bool

true if the response should be hidden to everyone besides the invoker of the command, otherwise false.

options RequestOptions

The request options for this response.

Returns

Task

A Task representing the operation of creating the interaction response.

Exceptions

InvalidOperationException

Thrown if the interaction isn't a type of RestInteraction.

RespondAsync(string, Embed[], bool, bool, AllowedMentions, RequestOptions, MessageComponent, Embed, PollProperties)

Respond to a Rest based Discord Interaction using the RestResponseCallback delegate.

protected override 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)

Parameters

text string

The text of the message to be sent.

embeds Embed[]

A array of embeds to send with this response. Max 10.

isTTS bool

true if the message should be read out by a text-to-speech reader, otherwise false.

ephemeral bool

true if the response should be hidden to everyone besides the invoker of the command, otherwise false.

allowedMentions AllowedMentions

The allowed mentions for this response.

options RequestOptions

The request options for this response.

components MessageComponent

A MessageComponent to be sent with this response.

embed Embed

A single embed to send with this response. If this is passed alongside an array of embeds, the single embed will be ignored.

poll PollProperties

Returns

Task

A Task representing the operation of creating the interaction response.

Exceptions

InvalidOperationException

Thrown if the interaction isn't a type of RestInteraction.

RespondWithModalAsync(Modal, RequestOptions)

Responds to the interaction with a modal.

protected override Task RespondWithModalAsync(Modal modal, RequestOptions options = null)

Parameters

modal Modal

The modal to respond with.

options RequestOptions

The request options for this async request.

Returns

Task

A Task representing the operation of creating the interaction response.

Exceptions

InvalidOperationException

Thrown if the interaction isn't a type of RestInteraction.

RespondWithModalAsync<TModal>(string, RequestOptions, Action<ModalBuilder>)

Responds to the interaction with a modal.

protected override Task RespondWithModalAsync<TModal>(string customId, RequestOptions options = null, Action<ModalBuilder> modifyModal = null) where TModal : class, IModal

Parameters

customId string

The custom ID of the modal.

options RequestOptions

The request options for this async request.

modifyModal Action<ModalBuilder>

Delegate that can be used to modify the modal.

Returns

Task

A Task representing the operation of creating the interaction response.

Type Parameters

TModal

Exceptions

InvalidOperationException

Thrown if the interaction isn't a type of RestInteraction.

RespondWithModalAsync<TModal>(string, TModal, RequestOptions, Action<ModalBuilder>)

Responds to the interaction with a modal.

protected override Task RespondWithModalAsync<TModal>(string customId, TModal modal, RequestOptions options = null, Action<ModalBuilder> modifyModal = null) where TModal : class, IModal

Parameters

customId string

The custom ID of the modal.

modal TModal

The modal to respond with.

options RequestOptions

The request options for this async request.

modifyModal Action<ModalBuilder>

Delegate that can be used to modify the modal.

Returns

Task

A Task representing the operation of creating the interaction response.

Type Parameters

TModal

The type of the modal.

Exceptions

InvalidOperationException

Thrown if the interaction isn't a type of RestInteraction.