diff --git a/src/Discord.Net.Commands/Attributes/NameAttribute.cs b/src/Discord.Net.Commands/Attributes/NameAttribute.cs new file mode 100644 index 0000000000..3ea0abe245 --- /dev/null +++ b/src/Discord.Net.Commands/Attributes/NameAttribute.cs @@ -0,0 +1,15 @@ +using System; + +namespace Discord.Commands +{ + // Override public name of command/module + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] + public class NameAttribute : Attribute + { + public string Text { get; } + public NameAttribute(string text) + { + Text = text; + } + } +} diff --git a/src/Discord.Net.Commands/Command.cs b/src/Discord.Net.Commands/Command.cs index 36cbdcc0f5..f46fafb270 100644 --- a/src/Discord.Net.Commands/Command.cs +++ b/src/Discord.Net.Commands/Command.cs @@ -31,6 +31,10 @@ internal Command(MethodInfo source, Module module, object instance, CommandAttri Name = source.Name; Text = groupPrefix + attribute.Text; + var nameAttr = source.GetCustomAttribute(); + if (nameAttr != null) + Name = nameAttr.Text; + var description = source.GetCustomAttribute(); if (description != null) Description = description.Text; diff --git a/src/Discord.Net.Commands/Module.cs b/src/Discord.Net.Commands/Module.cs index f965d78ab7..ecbf0b4003 100644 --- a/src/Discord.Net.Commands/Module.cs +++ b/src/Discord.Net.Commands/Module.cs @@ -25,6 +25,10 @@ internal Module(TypeInfo source, CommandService service, object instance, Module Name = source.Name; Instance = instance; + var nameAttr = source.GetCustomAttribute(); + if (nameAttr != null) + Name = nameAttr.Text; + var summaryAttr = source.GetCustomAttribute(); if (summaryAttr != null) Summary = summaryAttr.Text;