Table of Contents

Class TypeConverter

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

Base class for creating TypeConverters. InteractionService uses TypeConverters to interface with Slash Command parameters.

public abstract class TypeConverter
Inheritance
TypeConverter
Derived
Inherited Members

Methods

CanConvertTo(Type)

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

public abstract bool CanConvertTo(Type type)

Parameters

type Type

Returns

bool

GetDiscordType()

Will be used to get the Application Command Option type.

public abstract ApplicationCommandOptionType GetDiscordType()

Returns

ApplicationCommandOptionType

The option type.

ReadAsync(IInteractionContext, IApplicationCommandInteractionDataOption, IServiceProvider)

Will be used to read the incoming payload before executing the method body.

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

Parameters

context IInteractionContext

Command execution context.

option IApplicationCommandInteractionDataOption

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.

Write(ApplicationCommandOptionProperties, IParameterInfo)

Will be used to manipulate the outgoing command option, before the command gets registered to Discord.

public virtual void Write(ApplicationCommandOptionProperties properties, IParameterInfo parameter)

Parameters

properties ApplicationCommandOptionProperties
parameter IParameterInfo