Merge pull request #206 from FiniteReality/issue/203

Add NameAttribute for overriding Name in commands/modules
This commit is contained in:
RogueException
2016-08-18 11:30:13 -03:00
committed by GitHub
3 changed files with 23 additions and 0 deletions

View File

@@ -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;
}
}
}

View File

@@ -31,6 +31,10 @@ namespace Discord.Commands
Name = source.Name;
Text = groupPrefix + attribute.Text;
var nameAttr = source.GetCustomAttribute<NameAttribute>();
if (nameAttr != null)
Name = nameAttr.Text;
var description = source.GetCustomAttribute<DescriptionAttribute>();
if (description != null)
Description = description.Text;

View File

@@ -25,6 +25,10 @@ namespace Discord.Commands
Name = source.Name;
Instance = instance;
var nameAttr = source.GetCustomAttribute<NameAttribute>();
if (nameAttr != null)
Name = nameAttr.Text;
var summaryAttr = source.GetCustomAttribute<SummaryAttribute>();
if (summaryAttr != null)
Summary = summaryAttr.Text;