From 5a8582cb6a8a17b65440d33a643be68dc10351b2 Mon Sep 17 00:00:00 2001 From: Cenk Ergen <57065323+Cenngo@users.noreply.github.com> Date: Wed, 17 Jan 2024 00:22:43 +0300 Subject: [PATCH] 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 --- .../Attributes/CommandAttribute.cs | 34 +++++++++++++++++++ .../Builders/ModuleClassBuilder.cs | 3 ++ 2 files changed, 37 insertions(+) diff --git a/src/Discord.Net.Commands/Attributes/CommandAttribute.cs b/src/Discord.Net.Commands/Attributes/CommandAttribute.cs index d4d9ee3b..dc680edc 100644 --- a/src/Discord.Net.Commands/Attributes/CommandAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/CommandAttribute.cs @@ -18,6 +18,30 @@ namespace Discord.Commands public RunMode RunMode { get; set; } = RunMode.Default; public bool? IgnoreExtraArgs { get; } + /// + /// Attaches a summary to your command. + /// + /// + /// overrides the value of this property if present. + /// + public string Summary { get; set; } + + /// + /// Marks the aliases for a command. + /// + /// + /// extends the base value of this if present. + /// + public string[] Aliases { get; set; } + + /// + /// Attaches remarks to your commands. + /// + /// + /// overrides the value of this property if present. + /// + public string Remarks { get; set; } + /// 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; + } } } diff --git a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs index 9c4d5cc7..14a40d1f 100644 --- a/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs +++ b/src/Discord.Net.Commands/Builders/ModuleClassBuilder.cs @@ -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()); builder.AddAliases(command.Text); builder.RunMode = command.RunMode; builder.Name ??= command.Text;