Optional Aliasses, Summary and Remarks Properties to CommandAttribute (#2700)

* add optional remarks, aliases and summary properties to the CommandAttribute

* fix inline doc typo

* add CommandAttribute Aliasses prop integration

* add CommandAttribute Aliasses prop integration

* add ctor with new params

---------

Co-authored-by: Misha133 <mihagribkov133@gmail.com>
This commit is contained in:
Cenk Ergen
2024-01-17 00:22:43 +03:00
committed by GitHub
parent 12179a93d7
commit 5a8582cb6a
2 changed files with 37 additions and 0 deletions

View File

@@ -18,6 +18,30 @@ namespace Discord.Commands
public RunMode RunMode { get; set; } = RunMode.Default;
public bool? IgnoreExtraArgs { get; }
/// <summary>
/// Attaches a summary to your command.
/// </summary>
/// <remarks>
/// <see cref="Summary"/> overrides the value of this property if present.
/// </remarks>
public string Summary { get; set; }
/// <summary>
/// Marks the aliases for a command.
/// </summary>
/// <remarks>
/// <see cref="AliasAttribute"/> extends the base value of this if present.
/// </remarks>
public string[] Aliases { get; set; }
/// <summary>
/// Attaches remarks to your commands.
/// </summary>
/// <remarks>
/// <see cref="RemainderAttribute"/> overrides the value of this property if present.
/// </remarks>
public string Remarks { get; set; }
/// <inheritdoc />
public CommandAttribute()
{
@@ -32,10 +56,20 @@ namespace Discord.Commands
{
Text = text;
}
public CommandAttribute(string text, bool ignoreExtraArgs)
{
Text = text;
IgnoreExtraArgs = ignoreExtraArgs;
}
public CommandAttribute(string text, bool ignoreExtraArgs, string summary = default, string[] aliases = default, string remarks = default)
{
Text = text;
IgnoreExtraArgs = ignoreExtraArgs;
Summary = summary;
Aliases = aliases;
Remarks = remarks;
}
}
}

View File

@@ -154,6 +154,9 @@ namespace Discord.Commands
switch (attribute)
{
case CommandAttribute command:
builder.Summary ??= command.Summary;
builder.Remarks ??= command.Remarks;
builder.AddAliases(command.Aliases ?? Array.Empty<string>());
builder.AddAliases(command.Text);
builder.RunMode = command.RunMode;
builder.Name ??= command.Text;