Fix #203 by adding a NameAttribute to override Name
This commit is contained in:
15
src/Discord.Net.Commands/Attributes/NameAttribute.cs
Normal file
15
src/Discord.Net.Commands/Attributes/NameAttribute.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,6 +31,10 @@ namespace Discord.Commands
|
|||||||
Name = source.Name;
|
Name = source.Name;
|
||||||
Text = groupPrefix + attribute.Text;
|
Text = groupPrefix + attribute.Text;
|
||||||
|
|
||||||
|
var nameAttr = source.GetCustomAttribute<NameAttribute>();
|
||||||
|
if (nameAttr != null)
|
||||||
|
Name = nameAttr.Text;
|
||||||
|
|
||||||
var description = source.GetCustomAttribute<DescriptionAttribute>();
|
var description = source.GetCustomAttribute<DescriptionAttribute>();
|
||||||
if (description != null)
|
if (description != null)
|
||||||
Description = description.Text;
|
Description = description.Text;
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ namespace Discord.Commands
|
|||||||
Name = source.Name;
|
Name = source.Name;
|
||||||
Instance = instance;
|
Instance = instance;
|
||||||
|
|
||||||
|
var nameAttr = source.GetCustomAttribute<NameAttribute>();
|
||||||
|
if (nameAttr != null)
|
||||||
|
Name = nameAttr.Text;
|
||||||
|
|
||||||
var summaryAttr = source.GetCustomAttribute<SummaryAttribute>();
|
var summaryAttr = source.GetCustomAttribute<SummaryAttribute>();
|
||||||
if (summaryAttr != null)
|
if (summaryAttr != null)
|
||||||
Summary = summaryAttr.Text;
|
Summary = summaryAttr.Text;
|
||||||
|
|||||||
Reference in New Issue
Block a user