Table of Contents

Class OverrideTypeReaderAttribute

Namespace
Discord.Commands
Assembly
Discord.Net.Commands.dll

Marks the Type to be read by the specified TypeReader.

[AttributeUsage(AttributeTargets.Property|AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
public sealed class OverrideTypeReaderAttribute : Attribute
Inheritance
OverrideTypeReaderAttribute
Inherited Members

Examples

In this example, the TimeSpan will be read by a custom TypeReader, FriendlyTimeSpanTypeReader, instead of the TimeSpanTypeReader shipped by Discord.Net.

[Command("time")]
public Task GetTimeAsync([OverrideTypeReader(typeof(FriendlyTimeSpanTypeReader))]TimeSpan time)
    => ReplyAsync(time);

Remarks

This attribute is used to override a command parameter's type reading behaviour. This may be useful when you have multiple custom TypeReader and would like to specify one.

Constructors

OverrideTypeReaderAttribute(Type)

public OverrideTypeReaderAttribute(Type overridenTypeReader)

Parameters

overridenTypeReader Type

The TypeReader to be used with the parameter.

Exceptions

ArgumentException

The given overridenTypeReader does not inherit from TypeReader.

Properties

TypeReader

Gets the specified TypeReader of the parameter.

public Type TypeReader { get; }

Property Value

Type