Skip to content

Commit 3cee3b2

Browse files
Show help for text commands when used with no arguments
1 parent 8ecd085 commit 3cee3b2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Commands/GlobalCmds.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class GlobalCmds
1111
[Command("helptextcmd"), Description("Displays command help.")]
1212
[TextAlias("help")]
1313
[AllowedProcessors(typeof(TextCommandProcessor))]
14-
public async Task Help(CommandContext ctx, [Description("Command to provide help for."), RemainingText] string command = "")
14+
public static async Task Help(CommandContext ctx, [Description("Command to provide help for."), RemainingText] string command = "")
1515
{
1616
var commandSplit = command.Split(' ');
1717

@@ -319,7 +319,7 @@ public class Reminder
319319
// Runs command context checks manually. Returns a list of failed checks.
320320
// Unfortunately DSharpPlus.Commands does not provide a way to execute a command's context checks manually,
321321
// so this will have to do. This may not include all checks, but it includes everything I could think of. -Milkshake
322-
private async Task<IEnumerable<ContextCheckAttribute>> CheckPermissionsAsync(CommandContext ctx, Command cmd)
322+
private static async Task<IEnumerable<ContextCheckAttribute>> CheckPermissionsAsync(CommandContext ctx, Command cmd)
323323
{
324324
var contextChecks = cmd.Attributes.Where(x => x is ContextCheckAttribute);
325325
var failedChecks = new List<ContextCheckAttribute>();

Events/ErrorEvents.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using static Cliptok.Program;
1+
using DSharpPlus.Commands.Converters.Results;
2+
using static Cliptok.Program;
23

34
namespace Cliptok.Events
45
{
@@ -32,6 +33,12 @@ public static async Task TextCommandErrored(CommandErroredEventArgs e)
3233

3334
if (e.Exception is CommandNotFoundException && (e.Context.Command is null || commandName != "help"))
3435
return;
36+
37+
if (e.Exception is ArgumentParseException && e.Context.Arguments.All(x => x.Value is null or ArgumentNotParsedResult or Optional<ArgumentNotParsedResult>))
38+
{
39+
await Commands.GlobalCmds.Help(e.Context, e.Context.Command.Name);
40+
return;
41+
}
3542

3643
// avoid conflicts with modmail
3744
if (commandName == "edit" || commandName.Contains("timestamp"))

0 commit comments

Comments
 (0)