changed NameAttribute to work for parameter (#765)
This commit is contained in:
@@ -3,7 +3,7 @@ using System;
|
||||
namespace Discord.Commands
|
||||
{
|
||||
// Override public name of command/module
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)]
|
||||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Parameter)]
|
||||
public class NameAttribute : Attribute
|
||||
{
|
||||
public string Text { get; }
|
||||
|
||||
@@ -254,6 +254,9 @@ namespace Discord.Commands
|
||||
case ParameterPreconditionAttribute precon:
|
||||
builder.AddPrecondition(precon);
|
||||
break;
|
||||
case NameAttribute name:
|
||||
builder.Name = name.Text;
|
||||
break;
|
||||
case RemainderAttribute _:
|
||||
if (position != count - 1)
|
||||
throw new InvalidOperationException($"Remainder parameters must be the last parameter in a command. Parameter: {paramInfo.Name} in {paramInfo.Member.DeclaringType.Name}.{paramInfo.Member.Name}");
|
||||
|
||||
Reference in New Issue
Block a user