Precondition with Slash Command

How to report precondition failure w/ clash command? 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!' });
}
}
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:
Sapphire Framework
Reporting precondition failure | Sapphire
When a precondition fails, it's usually important for the user to know why. For example, if they hit a cooldown or lack
Jump to solution
3 Replies
Solution
Favna
Favna2y ago
Sapphire Framework
Reporting precondition failure | Sapphire
When a precondition fails, it's usually important for the user to know why. For example, if they hit a cooldown or lack
Pitch
Pitch2y ago
CLI project generates listeners for messages but not for chat input. strange decision.
Favna
Favna2y ago
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
GitHub
GitHub - sapphiredev/examples: Various examples of setting up your ...
Various examples of setting up your bot with the Sapphire Framework - GitHub - sapphiredev/examples: Various examples of setting up your bot with the Sapphire Framework
Want results from more Discord servers?
Add your server