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ćOP3mo 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ćOP3mo ago
No description
čamdžić
čamdžićOP3mo 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ćOP3mo ago
im getting this but its still logged to console
No description
MC Princess
MC Princess3mo ago
you’re returning this.error, which should log to the console
čamdžić
čamdžićOP3mo ago
no thats how it works
čamdžić
čamdžićOP3mo ago
No description
čamdžić
čamdžićOP3mo ago
on sapphire guide
MC Princess
MC Princess3mo ago
hmm, do you have any console.logs anywhere in your code?
čamdžić
čamdžićOP3mo 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 Princess3mo 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ćOP3mo ago
ye but that wont change anything yup same thing happening
Solution
čamdžić
čamdžić3mo ago
damn i just realized i had console.log in node_modules when i was testing something
čamdžić
čamdžićOP3mo ago
sorry

Did you find this page helpful?