Precondition doesn't return an error message
import { ApplyOptions } from '@sapphire/decorators';
import { Precondition } from '@sapphire/framework';
import type { PreconditionOptions, PreconditionResult } from '@sapphire/framework';
import type { CommandInteraction, ContextMenuCommandInteraction, GuildMember } from 'discord.js';
import { container } from '@sapphire/framework';
import { Result } from '@sapphire/framework';
@ApplyOptions<PreconditionOptions>({
name: 'TicketModerate',
})
export class TicketModeratePrecondition extends Precondition {
public override chatInputRun(interaction: CommandInteraction): PreconditionResult {
return this.checkModeratePermission(interaction);
}
public override contextMenuRun(interaction: ContextMenuCommandInteraction): PreconditionResult {
return this.checkModeratePermission(interaction);
}
private checkModeratePermission(interaction: CommandInteraction | ContextMenuCommandInteraction): PreconditionResult {
const member = interaction.member as GuildMember;
if (member.permissions.has('Administrator') || interaction.guild?.ownerId === interaction.user.id) {
return this.ok();
}
const { prisma } = container;
return Result.fromAsync(
prisma.ticket.findFirst({
where: {
channelId: interaction.channelId,
status: {
not: 'CLOSED'
}
},
include: {
category: {
include: {
moderatorRoles: true
}
}
}
}).then(ticket => {
if (!ticket) {
return this.error({ message: '❌ Cette commande ne peut être utilisée que dans un ticket actif.' });
}
const hasRole = ticket.category.moderatorRoles.some(
role => member.roles.cache.has(role.roleId) && ['MANAGE', 'READ_WRITE'].includes(role.permission)
);
if (!hasRole) {
console.log('❌ Vous n\'avez pas la permission d\'utiliser cette commande.');
return this.error({ message: "❌ Vous n'avez pas la permission d'utiliser cette commande." });
}
return this.ok();
})
);
}
}
declare module '@sapphire/framework' {
interface Preconditions {
TicketModerate: never;
}
}import { ApplyOptions } from '@sapphire/decorators';
import { Precondition } from '@sapphire/framework';
import type { PreconditionOptions, PreconditionResult } from '@sapphire/framework';
import type { CommandInteraction, ContextMenuCommandInteraction, GuildMember } from 'discord.js';
import { container } from '@sapphire/framework';
import { Result } from '@sapphire/framework';
@ApplyOptions<PreconditionOptions>({
name: 'TicketModerate',
})
export class TicketModeratePrecondition extends Precondition {
public override chatInputRun(interaction: CommandInteraction): PreconditionResult {
return this.checkModeratePermission(interaction);
}
public override contextMenuRun(interaction: ContextMenuCommandInteraction): PreconditionResult {
return this.checkModeratePermission(interaction);
}
private checkModeratePermission(interaction: CommandInteraction | ContextMenuCommandInteraction): PreconditionResult {
const member = interaction.member as GuildMember;
if (member.permissions.has('Administrator') || interaction.guild?.ownerId === interaction.user.id) {
return this.ok();
}
const { prisma } = container;
return Result.fromAsync(
prisma.ticket.findFirst({
where: {
channelId: interaction.channelId,
status: {
not: 'CLOSED'
}
},
include: {
category: {
include: {
moderatorRoles: true
}
}
}
}).then(ticket => {
if (!ticket) {
return this.error({ message: '❌ Cette commande ne peut être utilisée que dans un ticket actif.' });
}
const hasRole = ticket.category.moderatorRoles.some(
role => member.roles.cache.has(role.roleId) && ['MANAGE', 'READ_WRITE'].includes(role.permission)
);
if (!hasRole) {
console.log('❌ Vous n\'avez pas la permission d\'utiliser cette commande.');
return this.error({ message: "❌ Vous n'avez pas la permission d'utiliser cette commande." });
}
return this.ok();
})
);
}
}
declare module '@sapphire/framework' {
interface Preconditions {
TicketModerate: never;
}
}Hey actually this precondition send the console.log('
But there is no message replied to the user



