MAYBE a bug with subcommands

/
Solution:
oh, going through src I figured that event's name must be PluginMessageSubcommandNoMatch
Jump to solution
5 Replies
čamdžić
čamdžićOP2d ago
So
import { ApplyOptions } from "@sapphire/decorators";
import { type Args, Listener } from "@sapphire/framework";
import type {
MessageSubcommandNoMatchContext,
SubcommandPluginEvents
} from "@sapphire/plugin-subcommands";
import type { Message } from "discord.js";
import { BotEmbed } from "../lib/builders/BotEmbed";

@ApplyOptions<Listener.Options>({
name: "MessageSubcommandNoMatch",
event: "messageSubcommandNoMatch"
})
export class BotListener extends Listener<
typeof SubcommandPluginEvents.MessageSubcommandNoMatch
> {
override run(
message: Message<boolean>,
_: Args,
context: MessageSubcommandNoMatchContext
) {
return message.reply({
embeds: [
BotEmbed.errorUsage(
"Please provide a valid subcommand",
context.command.detailedDescription,
context
)
]
});
}
}
import { ApplyOptions } from "@sapphire/decorators";
import { type Args, Listener } from "@sapphire/framework";
import type {
MessageSubcommandNoMatchContext,
SubcommandPluginEvents
} from "@sapphire/plugin-subcommands";
import type { Message } from "discord.js";
import { BotEmbed } from "../lib/builders/BotEmbed";

@ApplyOptions<Listener.Options>({
name: "MessageSubcommandNoMatch",
event: "messageSubcommandNoMatch"
})
export class BotListener extends Listener<
typeof SubcommandPluginEvents.MessageSubcommandNoMatch
> {
override run(
message: Message<boolean>,
_: Args,
context: MessageSubcommandNoMatchContext
) {
return message.reply({
embeds: [
BotEmbed.errorUsage(
"Please provide a valid subcommand",
context.command.detailedDescription,
context
)
]
});
}
}
I did this my file name is messageSubcommandNoMatch.ts
const client = new SapphireClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
],
loadApplicationCommandRegistriesStatusListeners: false,
loadMessageCommandListeners: true,
defaultPrefix: container.config.prefixes,
disableMentionPrefix: true,
cron: {
defaultTimezone: "Europe/Sarajevo"
}
});
const client = new SapphireClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
],
loadApplicationCommandRegistriesStatusListeners: false,
loadMessageCommandListeners: true,
defaultPrefix: container.config.prefixes,
disableMentionPrefix: true,
cron: {
defaultTimezone: "Europe/Sarajevo"
}
});
sapphire client looks like this when I run command money
čamdžić
čamdžićOP2d ago
No description
čamdžić
čamdžićOP2d ago
I get this BUT 2025-03-31 01:34:32 - ERROR - Unable to match a subcommand on message command "money" at path "C:\Users\Aldin\Desktop\mommy-bot\src\commands\message\economy\money.ts" with content money I still get this error in console
Solution
čamdžić
čamdžić2d ago
oh, going through src I figured that event's name must be PluginMessageSubcommandNoMatch
čamdžić
čamdžićOP2d ago
can't really understand why or how does sapphire handle this but it's defined as MessageSubcommandNoMatch anyways, it's resolved

Did you find this page helpful?