Plugin subcommands: "No subcommand was matched with the provided command."

I configured my subcommands like this:
[
{
name: "requester",
type: "group",
entries: [
{
name: "set",
messageRun: [Function: messageRun],
chatInputRun: [Function: chatInputRun]
},
{
name: "disable",
messageRun: [Function: messageRun],
chatInputRun: [Function: chatInputRun]
}
]
}
]
[
{
name: "requester",
type: "group",
entries: [
{
name: "set",
messageRun: [Function: messageRun],
chatInputRun: [Function: chatInputRun]
},
{
name: "disable",
messageRun: [Function: messageRun],
chatInputRun: [Function: chatInputRun]
}
]
}
]
...and used the commands like this:
Solution:
actually this also works pretty sure:
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.chatInputSet(chatInputRun)
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.chatInputSet(chatInputRun)
...
Jump to solution
37 Replies
yuki
yukiOP17mo ago
chat input error stack:
yuki
yukiOP17mo ago
message run error stack:
yuki
yukiOP17mo ago
here's how i register the chat input command:
yuki
yukiOP17mo ago
I used: @sapphire/framework: v4.5.0 @sapphire/plugin-subcommands: v4.0.1 discord.js: v14.11.0 pls mention me if someone know the problem
Mozart Rafi 🍃
Mozart Rafi 🍃17mo ago
:/
Favna
Favna17mo ago
what is the [Function: messageRun] here? Are they actually functions you implemented inline, or did you actually type that? Ideally they are names of other functions in the same class. Also make sure to not implement messageRun / chatInputRun in those same classes. Also you can use this.name and this.description
yuki
yukiOP17mo ago
its from console log dw wait, you cant fill that with inline function?
Favna
Favna17mo ago
you can, though not if supplied through the @ApplyOptions decorator iirc most people dont use inline functions though I think. We kept it because Vladdy wanted that style.
yuki
yukiOP17mo ago
well, its pain to handle message and chat input separately, and i just passed the message|chatinput to the same function, so, the subcommand mapping value is an inline function that runs the same function and pass message, chatinput run, and args yeah i didnt use that
Favna
Favna17mo ago
well at a glance your setup looks okay. Best thing you can do to find the cause is set a breakpoint at node_modules/@sapphire/plugin-subcommands/dist/lib/Subcommand.js line 188 then use a debugger to traverse through and check why it is not matching.
yuki
yukiOP17mo ago
yuki
yukiOP17mo ago
ahh
yuki
yukiOP17mo ago
🤔
yuki
yukiOP17mo ago
why the subcommand group name is undefined?
Favna
Favna17mo ago
uh wtf try to do the same code? interaction.options.getSubcommandGroup() in the debugger console I meant I should've added that immediately
yuki
yukiOP17mo ago
uh its there
yuki
yukiOP17mo ago
yuki
yukiOP17mo ago
actually
yuki
yukiOP17mo ago
this thing is empty uh is it possible to define the subcommands after super keyword
Favna
Favna17mo ago
oh no it's not did you dod that lol
yuki
yukiOP17mo ago
yeah because i need to access this yeah thats the issue then
Favna
Favna17mo ago
this for ... the function I guess? the function you mentioend to call
yuki
yukiOP17mo ago
yeah i can use the
Favna
Favna17mo ago
yeah you'll have to extract it to outside the class and call it that way
yuki
yukiOP17mo ago
named function i can just pass the string instead of inline
Solution
Favna
Favna17mo ago
actually this also works pretty sure:
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.chatInputSet(chatInputRun)
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.chatInputSet(chatInputRun)
Favna
Favna17mo ago
at least TS doesnt complain
yuki
yukiOP17mo ago
<:AW_KEKW:800014260787871744> ok thanks
Favna
Favna17mo ago
I think it works because the function is a callback that gets executed when it's called .... gonna test this rq
public constructor(context: Subcommand.Context) {
super(context, {
name: 'cip',
description: 'A basic chat input command that pings',
subcommands: [
{
name: 'requester',
type: 'group',
entries: [
{
name: 'set',
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.actualChatInputSet(chatInputRun)
},
{
name: 'disable',
chatInputRun: 'chatInputDisable'
}
]
}
]
});
}
public constructor(context: Subcommand.Context) {
super(context, {
name: 'cip',
description: 'A basic chat input command that pings',
subcommands: [
{
name: 'requester',
type: 'group',
entries: [
{
name: 'set',
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.actualChatInputSet(chatInputRun)
},
{
name: 'disable',
chatInputRun: 'chatInputDisable'
}
]
}
]
});
}
yuki
yukiOP17mo ago
yuki
yukiOP17mo ago
need to move that thing lel
Favna
Favna17mo ago
yeah that works
yuki
yukiOP17mo ago
wait what
Favna
Favna17mo ago
so just inline it all you can call this from the function just fine
yuki
yukiOP17mo ago
OHH i see
Favna
Favna17mo ago
entries: [
{
name: 'set',
chatInputRun: (interaction: Subcommand.ChatInputCommandInteraction) => {
const channel = interaction.options.getChannel('text-channel', true);
return this.doStuff(channel);
}
},
entries: [
{
name: 'set',
chatInputRun: (interaction: Subcommand.ChatInputCommandInteraction) => {
const channel = interaction.options.getChannel('text-channel', true);
return this.doStuff(channel);
}
},
should be something like that for you I guess
yuki
yukiOP17mo ago
oh yeah it works cool
Want results from more Discord servers?
Add your server