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
yuki11mo ago
chat input error stack:
yuki
yuki11mo ago
message run error stack:
yuki
yuki11mo ago
here's how i register the chat input command:
yuki
yuki11mo 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 🍃11mo ago
:/
Favna
Favna11mo 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
yuki11mo ago
its from console log dw wait, you cant fill that with inline function?
Favna
Favna11mo 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
yuki11mo 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
Favna11mo 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
yuki11mo ago
yuki
yuki11mo ago
ahh
yuki
yuki11mo ago
🤔
yuki
yuki11mo ago
why the subcommand group name is undefined?
Favna
Favna11mo 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
yuki11mo ago
uh its there
yuki
yuki11mo ago
yuki
yuki11mo ago
actually
yuki
yuki11mo ago
this thing is empty uh is it possible to define the subcommands after super keyword
Favna
Favna11mo ago
oh no it's not did you dod that lol
yuki
yuki11mo ago
yeah because i need to access this yeah thats the issue then
Favna
Favna11mo ago
this for ... the function I guess? the function you mentioend to call
yuki
yuki11mo ago
yeah i can use the
Favna
Favna11mo ago
yeah you'll have to extract it to outside the class and call it that way
yuki
yuki11mo ago
named function i can just pass the string instead of inline
Solution
Favna
Favna11mo ago
actually this also works pretty sure:
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.chatInputSet(chatInputRun)
chatInputRun: (chatInputRun: Subcommand.ChatInputCommandInteraction) => this.chatInputSet(chatInputRun)
Favna
Favna11mo ago
at least TS doesnt complain
yuki
yuki11mo ago
<:AW_KEKW:800014260787871744> ok thanks
Favna
Favna11mo 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
yuki11mo ago
yuki
yuki11mo ago
need to move that thing lel
Favna
Favna11mo ago
yeah that works
yuki
yuki11mo ago
wait what
Favna
Favna11mo ago
so just inline it all you can call this from the function just fine
yuki
yuki11mo ago
OHH i see
Favna
Favna11mo 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
yuki11mo ago
oh yeah it works cool