plugin-subcommands: subcommands with preconditions

HI, so im creating subcommands with preconditions, but its not working on subcommands, its only working on normal commands (chatInputCommands) - When i run normal chatInputCommands, its working (first pic) - But when i run subComands with preconditions (second pic) - My subcommands code are like this (third pic) - And my precondition are like this (fourth pic)
No description
No description
No description
No description
Solution:
the event name still has to be changed to Subcommand but that'd be a breaking change so it's pending whenever there is more kekw
No description
Jump to solution
41 Replies
Vann
VannOPā€¢14mo ago
my filter command's preconditions placed like this
No description
Vann
VannOPā€¢14mo ago
am i wrong doing it?
Favna
Favnaā€¢14mo ago
The application did not respond is correct because you did indeed not respond. Subcommand precondition violations do not go to the chatInputCommandDenied listener so you'll need to create a separate listener for them and reply accordingly. The fact that you get Application did not respond in fact means that the preconditions do work, you're just not handling it. The correct listener for this is SubcommandPluginEvents.ChatInputSubcommandDenied, which as parameters error: UserError, payload: ChatInputSubcommandDeniedPayload
Vann
VannOPā€¢14mo ago
so i need make new listener right? for handling subcommandDenied
Vann
VannOPā€¢14mo ago
the listener still not running, or am i doing wrong again?
No description
Favna
Favnaā€¢14mo ago
name of the file is the event, and the name is wrong. The name is chatInputSubcommandDenied not subCommandDenied
Vann
VannOPā€¢14mo ago
oooooo okay sir
Vann
VannOPā€¢14mo ago
still the same
No description
Vann
VannOPā€¢14mo ago
or because folder name?
Vann
VannOPā€¢14mo ago
No description
Favna
Favnaā€¢14mo ago
folder name is irrelevant. Did you rebuild your TS code. Also make sure to delete dist, rebuilding TS doesn't delete old JS files. oh actually I think it has to be chatInputSubCommandDenied
Vann
VannOPā€¢14mo ago
yap also i deleted the dist file to make sure its newest
Solution
Favna
Favnaā€¢14mo ago
the event name still has to be changed to Subcommand but that'd be a breaking change so it's pending whenever there is more kekw
No description
Favna
Favnaā€¢14mo ago
so now now SubCommand you can also set the event programmatically btw: https://www.sapphirejs.dev/docs/Guide/listeners/creating-your-own-listeners. Then you can just use the enum.
Vann
VannOPā€¢14mo ago
i can do it, but i dont know who will emit the event only SubCommand?, the folder name or the file name pepeThink
Favna
Favnaā€¢14mo ago
1. it's always client unless otherwise specified 2. That option is optional anyway file name and not only chatInputSubCommandDenied
Vann
VannOPā€¢14mo ago
like this?
No description
Vann
VannOPā€¢14mo ago
umm, like this right?, but the emitter is client, and the event is chatInputSubCommandDenied
No description
Favna
Favnaā€¢14mo ago
export class UserEvent extends Listener<typeof SubcommandPluginEvents.ChatInputSubcommandDenied> {
public constructor(context: Listener.Context) {
super(context, {
event: SubcommandPluginEvents.ChatInputSubcommandDenied
});
}

public override run({ message: content }: UserError, { interaction }: ChatInputCommandDeniedPayload) {
return interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(content)
.setColor('Red')
]
});
}
}
export class UserEvent extends Listener<typeof SubcommandPluginEvents.ChatInputSubcommandDenied> {
public constructor(context: Listener.Context) {
super(context, {
event: SubcommandPluginEvents.ChatInputSubcommandDenied
});
}

public override run({ message: content }: UserError, { interaction }: ChatInputCommandDeniedPayload) {
return interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(content)
.setColor('Red')
]
});
}
}
or
@ApplyOptions<Listener.Options>({
event: SubcommandPluginEvents.ChatInputSubcommandDenied
})
export class UserEvent extends Listener<typeof SubcommandPluginEvents.ChatInputSubcommandDenied> {
public override run({ message: content }: UserError, { interaction }: ChatInputCommandDeniedPayload) {
return interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(content)
.setColor('Red')
]
});
}
}
@ApplyOptions<Listener.Options>({
event: SubcommandPluginEvents.ChatInputSubcommandDenied
})
export class UserEvent extends Listener<typeof SubcommandPluginEvents.ChatInputSubcommandDenied> {
public override run({ message: content }: UserError, { interaction }: ChatInputCommandDeniedPayload) {
return interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(content)
.setColor('Red')
]
});
}
}
Like I said, emitter is optional. It defaults to client
Vann
VannOPā€¢14mo ago
still nope xD
import { ApplyOptions } from '@sapphire/decorators';
import { Listener, UserError, } from '@sapphire/framework';
import { ChatInputSubcommandDeniedPayload, SubcommandPluginEvents } from '@sapphire/plugin-subcommands';
import { EmbedBuilder } from 'discord.js';

@ApplyOptions<Listener.Options>({
event: SubcommandPluginEvents.ChatInputSubcommandDenied
})

export class UserEvent extends Listener<typeof SubcommandPluginEvents.ChatInputSubcommandDenied> {
public override async run({ message: content }: UserError, { interaction }: ChatInputSubcommandDeniedPayload) {

return interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(content)
.setColor("Red")
]
});
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Listener, UserError, } from '@sapphire/framework';
import { ChatInputSubcommandDeniedPayload, SubcommandPluginEvents } from '@sapphire/plugin-subcommands';
import { EmbedBuilder } from 'discord.js';

@ApplyOptions<Listener.Options>({
event: SubcommandPluginEvents.ChatInputSubcommandDenied
})

export class UserEvent extends Listener<typeof SubcommandPluginEvents.ChatInputSubcommandDenied> {
public override async run({ message: content }: UserError, { interaction }: ChatInputSubcommandDeniedPayload) {

return interaction.reply({
embeds: [
new EmbedBuilder()
.setDescription(content)
.setColor("Red")
]
});
}
}
Favna
Favnaā€¢14mo ago
SubCommand I've typed that so many times now capital C oh I guess I made the mistake above either way I still typed capital C so many times now
Vann
VannOPā€¢14mo ago
pepeHmm i searching for the capital c, and found nothing?, or im blinded
Favna
Favnaā€¢14mo ago
definitely are
Vann
VannOPā€¢14mo ago
hehe
Favna
Favnaā€¢14mo ago
unless your vscode filters out deprecated symbols in which case heck is that setting and I recommend changing it
No description
Vann
VannOPā€¢14mo ago
ahhh, my vscode
Vann
VannOPā€¢14mo ago
No description
Vann
VannOPā€¢14mo ago
found what are you mean šŸ’€ yap its working
Vann
VannOPā€¢14mo ago
isnt this the same?
No description
Vann
VannOPā€¢14mo ago
hehe
Favna
Favnaā€¢14mo ago
look at the C in subcommand
Vann
VannOPā€¢14mo ago
no, i mean
No description
Favna
Favnaā€¢14mo ago
yes, look at the C in subcommand
Vann
VannOPā€¢14mo ago
oooooooo oke for now i hate c wtf
Favna
Favnaā€¢14mo ago
C is a pretty garbage language yes /jk
Vann
VannOPā€¢14mo ago
yes, for me xD
Favna
Favnaā€¢14mo ago
anyway I'll release a fix for this. It was pending a new major because removing an event and forcing users to change is a breaking change but screw it I can C this causes a lot of confusion pun intended
Vann
VannOPā€¢14mo ago
yeah, its true for me, since its now really showed on ide
Favna
Favnaā€¢14mo ago
so after the release then there will be just 1 event called chatInputSubcommandDenied so with a lowercase c
Vann
VannOPā€¢14mo ago
2 hour because of "c"
Vann
VannOPā€¢14mo ago
ty sir @Favna
Want results from more Discord servers?
Add your server