precondition error logging in console

hey, when my precondition errors, its logged to console and i don't understand how to stop it?
Solution:
damn i just realized i had console.log in node_modules when i was testing something
Jump to solution
14 Replies
čamdžić
čamdžićOP4w ago
const client = new SapphireClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
],
loadMessageCommandListeners: true,
caseInsensitiveCommands: true,
defaultPrefix: container.config.prefix,
cronTasks: {
defaultTimezone: 'America/New_York'
}
});
const client = new SapphireClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent
],
loadMessageCommandListeners: true,
caseInsensitiveCommands: true,
defaultPrefix: container.config.prefix,
cronTasks: {
defaultTimezone: 'America/New_York'
}
});
čamdžić
čamdžićOP4w ago
No description
čamdžić
čamdžićOP4w ago
import { ApplyOptions } from '@sapphire/decorators';
import { Precondition } from '@sapphire/framework';
import type { ChatInputCommandInteraction } from 'discord.js';

@ApplyOptions<Precondition.Options>({
position: 20
})
export class BotPrecondition extends Precondition {
override chatInputRun(interaction: ChatInputCommandInteraction) {
if (interaction.inCachedGuild()) {
return this.error({
message: 'This command can only be used in a server.'
});
}

return this.ok();
}
}
import { ApplyOptions } from '@sapphire/decorators';
import { Precondition } from '@sapphire/framework';
import type { ChatInputCommandInteraction } from 'discord.js';

@ApplyOptions<Precondition.Options>({
position: 20
})
export class BotPrecondition extends Precondition {
override chatInputRun(interaction: ChatInputCommandInteraction) {
if (interaction.inCachedGuild()) {
return this.error({
message: 'This command can only be used in a server.'
});
}

return this.ok();
}
}
I also have my own listener for every error and command denied thing But if I try to debug in those listeners, it logs after this error btw this is just for testing, I know that it should be like !interaction.inCachedGuild()
čamdžić
čamdžićOP4w ago
im getting this but its still logged to console
No description
MC Princess
MC Princess4w ago
you’re returning this.error, which should log to the console
čamdžić
čamdžićOP4w ago
no thats how it works
čamdžić
čamdžićOP4w ago
No description
čamdžić
čamdžićOP4w ago
on sapphire guide
MC Princess
MC Princess4w ago
hmm, do you have any console.logs anywhere in your code?
čamdžić
čamdžićOP4w ago
no i mean i tried everything im having this issue for like 30 minutes trying to find the problem but can't
@ApplyOptions<Listener.Options>({})
export class BotListener extends Listener<
typeof Events.ChatInputCommandDenied
> {
override run(error: UserError, payload: ChatInputCommandDeniedPayload) {
}
}
@ApplyOptions<Listener.Options>({})
export class BotListener extends Listener<
typeof Events.ChatInputCommandDenied
> {
override run(error: UserError, payload: ChatInputCommandDeniedPayload) {
}
}
this is my ChatInputCommandDenied listener and that works fine
MC Princess
MC Princess4w ago
have you tried formatting the error like it is in the example? it doesn’t seem to be formatted the same ? this.ok : this.error(<insert msg here>)
čamdžić
čamdžićOP4w ago
ye but that wont change anything yup same thing happening
Solution
čamdžić
čamdžić4w ago
damn i just realized i had console.log in node_modules when i was testing something
čamdžić
čamdžićOP4w ago
sorry

Did you find this page helpful?