Wolfringo Wolfringo
Wolfringo Wolfringo
Wolfringo (c) 2020 TehGM
DocFX, DiscordFX theme.
Search Results for

    Class ArgumentErrorAttribute

    Base attribute for all argument error attributes.

    Inheritance
    System.Object
    System.Attribute
    ArgumentErrorAttribute
    ConvertingErrorAttribute
    MissingErrorAttribute
    Implements
    System.IEquatable<ArgumentErrorAttribute>
    System.IEquatable<System.String>
    Namespace: TehGM.Wolfringo.Commands.Attributes
    Assembly: Wolfringo.Commands.dll
    Syntax
    [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
    public abstract class ArgumentErrorAttribute : Attribute, IEquatable<ArgumentErrorAttribute>, IEquatable<string>
    Remarks

    Decorating a method parameter with this argument will allow specifying message that will be sent to the user if there's any error when building the param.

    TextTemplate can have a few placeholders inside. On runtime, each of these placeholders will be replaced with an actual value. Currently supported placeholders are: ArgPlaceholder, TypePlaceholder, NamePlaceholder, MessagePlaceholder, SenderNicknamePlaceholder, SenderIdPlaceholder, BotNicknamePlaceholder, BotIdPlaceholder.
    To add new placeholders, create new attributes inheriting from ConvertingErrorAttribute or MissingErrorAttribute, and override ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken) method. To preserve default placeholders, call

    base.ToStringAsync()
    BEFORE your custom placeholders handling.

    Constructors

    | Improve this Doc View Source

    ArgumentErrorAttribute(String)

    Attribute to specify message that will be sent as respone when argument error occurs.

    Declaration
    public ArgumentErrorAttribute(string messageTemplate)
    Parameters
    Type Name Description
    System.String messageTemplate

    Message that will be sent as response on error.

    Fields

    | Improve this Doc View Source

    ArgPlaceholder

    This placeholder will be replaced with argument value at runtime.

    Declaration
    public const string ArgPlaceholder = "{{Arg}}"
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    BotIdPlaceholder

    This placeholder will be replaced with ID of the bot at runtime.

    Declaration
    public const string BotIdPlaceholder = "{{BotID}}"
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    BotNicknamePlaceholder

    This placeholder will be replaced with nickname of the bot at runtime.

    Declaration
    public const string BotNicknamePlaceholder = "{{BotNickname}}"
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    MessagePlaceholder

    This placeholder will be replaced with received message contents at runtime.

    Declaration
    public const string MessagePlaceholder = "{{Message}}"
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    NamePlaceholder

    This placeholder will be replaced with parameter name at runtime.

    Declaration
    public const string NamePlaceholder = "{{Name}}"
    Field Value
    Type Description
    System.String
    Remarks

    Can be changed by using ArgumentNameAttribute.

    | Improve this Doc View Source

    RecipientIdPlaceholder

    This placeholder will be replaced with ID of the message recipient (bot ID for PMs, group ID for group messages).

    Declaration
    public const string RecipientIdPlaceholder = "{{RecipientID}}"
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    RecipientNamePlaceholder

    This placeholder will be replaced with name of the message recipient (bot nickname for PMs, group name for group messages).

    Declaration
    public const string RecipientNamePlaceholder = "{{RecipientName}}"
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    SenderIdPlaceholder

    This placeholder will be replaced with ID of the user that sent the command at runtime.

    Declaration
    public const string SenderIdPlaceholder = "{{SenderID}}"
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    SenderNicknamePlaceholder

    This placeholder will be replaced with nickname of the user that sent the command at runtime.

    Declaration
    public const string SenderNicknamePlaceholder = "{{SenderNickname}}"
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    TypePlaceholder

    This placeholder will be replaced with parameter type at runtime.

    Declaration
    public const string TypePlaceholder = "{{Type}}"
    Field Value
    Type Description
    System.String
    Remarks

    Can be changed by using ArgumentTypeNameAttribute.

    Properties

    | Improve this Doc View Source

    TextTemplate

    Error message that will be sent as response on error.

    Declaration
    public string TextTemplate { get; }
    Property Value
    Type Description
    System.String

    Methods

    | Improve this Doc View Source

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj
    Returns
    Type Description
    System.Boolean
    Overrides
    System.Attribute.Equals(System.Object)
    | Improve this Doc View Source

    Equals(String)

    Declaration
    public bool Equals(string other)
    Parameters
    Type Name Description
    System.String other
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Equals(ArgumentErrorAttribute)

    Declaration
    public bool Equals(ArgumentErrorAttribute other)
    Parameters
    Type Name Description
    ArgumentErrorAttribute other
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    System.Attribute.GetHashCode()
    | Improve this Doc View Source

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.Object.ToString()
    | Improve this Doc View Source

    ToStringAsync(ICommandContext, String, ParameterInfo, CancellationToken)

    Builds error response for the sent message and arg.

    Declaration
    public virtual async Task<string> ToStringAsync(ICommandContext context, string arg, ParameterInfo parameter, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    ICommandContext context

    Message context that contains the argument.

    System.String arg

    Value of argument that failed converting.

    System.Reflection.ParameterInfo parameter

    Parameter the error is for.

    System.Threading.CancellationToken cancellationToken

    Token to cancel any required server requests with.

    Returns
    Type Description
    System.Threading.Tasks.Task<System.String>

    Operators

    | Improve this Doc View Source

    Equality(ArgumentErrorAttribute, ArgumentErrorAttribute)

    Declaration
    public static bool operator ==(ArgumentErrorAttribute left, ArgumentErrorAttribute right)
    Parameters
    Type Name Description
    ArgumentErrorAttribute left
    ArgumentErrorAttribute right
    Returns
    Type Description
    System.Boolean
    | Improve this Doc View Source

    Inequality(ArgumentErrorAttribute, ArgumentErrorAttribute)

    Declaration
    public static bool operator !=(ArgumentErrorAttribute left, ArgumentErrorAttribute right)
    Parameters
    Type Name Description
    ArgumentErrorAttribute left
    ArgumentErrorAttribute right
    Returns
    Type Description
    System.Boolean

    Implements

    System.IEquatable<T>
    System.IEquatable<T>