Fix #203 by adding a NameAttribute to override Name

This commit is contained in:
FiniteReality
2016-08-18 13:50:02 +01:00
parent f8ae8bd9c3
commit 8b864d4b9e
3 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
using System;
namespace Discord.Commands
{
// Full summary of method
[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;