S-IAF
Join ServerSapphire - Imagine a framework
sapphire-support
Precondition with Slash Command
PPitch2/26/2023
How to report precondition failure w/ clash command?
If I use
If I use
this.error({ message: 'error' });
in precondition, it does nothing.import { Precondition } from '@sapphire/framework';
import config from '#rootJson/config' assert { type: 'json' };
export class OwnerOnlyPrecondition extends Precondition {
async messageRun(message) {
// for message command
return this.checkOwner(message.author.id);
}
async chatInputRun(interaction) {
return this.checkOwner(interaction.user.id);
}
async contextMenuRun(interaction) {
// for Context Menu Command
return this.checkOwner(interaction.user.id);
}
async checkOwner(userId) {
return config.owners.includes(userId) ? this.ok() : this.error({ message: 'Only the bot owner can use this command!' });
}
}
Solution
PPitch2/26/2023
CLI project generates listeners for messages but not for chat input. strange decision.
FFavna2/26/2023
it's not really a decision. It's just that the examples havent been updated by anyone yet. Set a good example and be the one who fixes it and make a PR to https://github.com/sapphiredev/examples