Class TypeReader
Base class for creating TypeConverters. InteractionService uses TypeConverters to interface with Slash Command parameters.
Namespace: Discord.Interactions
Assembly: Discord.Net.Interactions.dll
Syntax
public abstract class TypeReader : object, ITypeConverter<string>
Methods
| Improve this Doc View SourceCanConvertTo(Type)
Will be used to search for alternative TypeReaders whenever the Command Service encounters an unknown parameter type.
Declaration
public abstract bool CanConvertTo(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type | An object type. |
Returns
Type | Description |
---|---|
Boolean | The boolean result. |
ReadAsync(IInteractionContext, String, IServiceProvider)
Will be used to read the incoming payload before executing the method body.
Declaration
public abstract Task<TypeConverterResult> ReadAsync(IInteractionContext context, string option, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
IInteractionContext | context | Command execution context. |
String | option | Received option payload. |
IServiceProvider | services | Service provider that will be used to initialize the command module. |
Returns
Type | Description |
---|---|
Task<TypeConverterResult> | The result of the read process. |
SerializeAsync(Object, IServiceProvider)
Will be used to serialize objects into strings.
Declaration
public virtual Task<string> SerializeAsync(object obj, IServiceProvider services)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | Object to be serialized. |
IServiceProvider | services |
Returns
Type | Description |
---|---|
Task<String> | A task representing the conversion process. The result of the task contains the conversion result. |