Table of Contents

Class ModalComponentTypeConverter

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

Base class for creating ModalComponentTypeConverters. InteractionService uses ModalComponentTypeConverters to interface with Modal component parameters.

public abstract class ModalComponentTypeConverter
Inheritance
ModalComponentTypeConverter
Derived
Inherited Members

Methods

CanConvertTo(Type)

Will be used to search for alternative ModalComponentTypeConverters whenever the Interaction Service encounters an unknown parameter type.

public abstract bool CanConvertTo(Type type)

Parameters

type Type

Type of the modal property.

Returns

bool

Whether this converter can be used to handle the given type.

ReadAsync(IInteractionContext, IComponentInteractionData, IServiceProvider)

Will be used to read the incoming payload before building the modal instance.

public abstract Task<TypeConverterResult> ReadAsync(IInteractionContext context, IComponentInteractionData option, IServiceProvider services)

Parameters

context IInteractionContext

Command execution context.

option IComponentInteractionData

Received option payload.

services IServiceProvider

Service provider that will be used to initialize the command module.

Returns

Task<TypeConverterResult>

The result of the read process.

TryGetModalInteractionData(IInteractionContext, out IModalInteractionData)

Tries to get the IModalInteractionData from the provided IInteractionContext.

protected bool TryGetModalInteractionData(IInteractionContext context, out IModalInteractionData modalData)

Parameters

context IInteractionContext

Context containing the IModalInteractionData.

modalData IModalInteractionData

IModalInteractionData found in the context if successful, null otherwise.

Returns

bool

true when successful.

WriteAsync<TBuilder>(TBuilder, IDiscordInteraction, InputComponentInfo, object)

Will be used to manipulate the outgoing modal component, before the modal gets sent to Discord.

public virtual Task WriteAsync<TBuilder>(TBuilder builder, IDiscordInteraction interaction, InputComponentInfo component, object value) where TBuilder : class, IInteractableComponentBuilder

Parameters

builder TBuilder
interaction IDiscordInteraction
component InputComponentInfo
value object

Returns

Task

Type Parameters

TBuilder