Subcommand unintentionally triggers Events.MessageCommandRun

I have a /dpm subcommand is defined as:
subcommands: [
{ name: "all", chatInputRun: "dpmAll" },
{ name: "job", chatInputRun: "dpmJob" },
{ name: "ign", chatInputRun: "dpmIgn" }
]
subcommands: [
{ name: "all", chatInputRun: "dpmAll" },
{ name: "job", chatInputRun: "dpmJob" },
{ name: "ign", chatInputRun: "dpmIgn" }
]
I noticed a strange occurence where, if my message command prefix is set to /, and I run /dpm as a message, the MessageCommandRun event will be triggered and gives this error, even though I never registered a messageRun method.
UserError: No subcommand was matched with the provided arguments.
UserError: No subcommand was matched with the provided arguments.
Wondering if this is intended or am I doing something wrong?
Solution:
Set a default on one of the subcommands or handle the error
Jump to solution
3 Replies
Solution
Favna
Favna2y ago
Set a default on one of the subcommands or handle the error
Favna
Favna2y ago
Also you should really not use / as default prefix because that's going to confuse literally everyone. No one is going to know if you have a message based bot or a slash command bot.
fluffy
fluffyOP2y ago
ah, my bot actually doesn't use message commands, I have / prefix purely to remind users how to use slash commands properly should they wrongly send the command as a message. There are way too many of them! Thank you for the default tip, even though jt still triggers the MessageRun event it is a sufficient workaround!
Want results from more Discord servers?
Add your server