Skip to content

Commit

Permalink
changed NameAttribute to work for parameter (#765)
Browse files Browse the repository at this point in the history
  • Loading branch information
Izumemori authored and foxbot committed Aug 29, 2017
1 parent cb0ff78 commit 9c81ab9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Discord.Net.Commands/Attributes/NameAttribute.cs
Expand Up @@ -3,7 +3,7 @@
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; }
Expand Down
3 changes: 3 additions & 0 deletions src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs
Expand Up @@ -254,6 +254,9 @@ private static void BuildParameter(ParameterBuilder builder, System.Reflection.P
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}");
Expand Down

0 comments on commit 9c81ab9

Please sign in to comment.