Skip to content

Commit

Permalink
Optional Aliasses, Summary and Remarks Properties to CommandAttribute (
Browse files Browse the repository at this point in the history
…#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>
  • Loading branch information
Cenngo and Misha-133 authored Jan 16, 2024
1 parent 12179a9 commit 5a8582c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Discord.Net.Commands/Attributes/CommandAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,30 @@ public class CommandAttribute : Attribute
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()
{
Expand All @@ -32,10 +56,20 @@ public CommandAttribute(string text)
{
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;
}
}
}
3 changes: 3 additions & 0 deletions src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ private static void BuildCommand(CommandBuilder builder, TypeInfo typeInfo, Meth
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;
Expand Down

0 comments on commit 5a8582c

Please sign in to comment.