ReferenceError: blacklistLog is not defined

Code Block
const logChannel = client.channels.cache.get('1095093697047183541');
const user = message.author;

blacklistLog = new EmbedBuilder()
.setTitle(`${user.username} said a blacklisted word.`)
.setDescription(`"${message.content}"`)
.setColor('Red');
const logChannel = client.channels.cache.get('1095093697047183541');
const user = message.author;

blacklistLog = new EmbedBuilder()
.setTitle(`${user.username} said a blacklisted word.`)
.setDescription(`"${message.content}"`)
.setColor('Red');
Error
node:events:492
throw er; // Unhandled 'error' event
^

ReferenceError: blacklistLog is not defined
at module.exports (/Users/nitr0h/Developer/BoosterBotJS/src/events/messageCreate/messageCreate.js:43:15)
at Client.<anonymous> (/Users/nitr0h/Developer/BoosterBotJS/node_modules/commandkit/dist/index.js:451:39)
at Client.emit (node:events:514:28)
at MessageCreateAction.handle (/Users/nitr0h/Developer/BoosterBotJS/node_modules/discord.js/src/client/actions/MessageCreate.js:28:14)
at module.exports [as MESSAGE_CREATE] (/Users/nitr0h/Developer/BoosterBotJS/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Users/nitr0h/Developer/BoosterBotJS/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/Users/nitr0h/Developer/BoosterBotJS/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/Users/nitr0h/Developer/BoosterBotJS/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.<anonymous> (/Users/nitr0h/Developer/BoosterBotJS/node_modules/@discordjs/ws/dist/index.js:1173:51)
at WebSocketShard.emit (/Users/nitr0h/Developer/BoosterBotJS/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:397:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v20.7.0
[nodemon] app crashed - waiting for file changes before starting...
node:events:492
throw er; // Unhandled 'error' event
^

ReferenceError: blacklistLog is not defined
at module.exports (/Users/nitr0h/Developer/BoosterBotJS/src/events/messageCreate/messageCreate.js:43:15)
at Client.<anonymous> (/Users/nitr0h/Developer/BoosterBotJS/node_modules/commandkit/dist/index.js:451:39)
at Client.emit (node:events:514:28)
at MessageCreateAction.handle (/Users/nitr0h/Developer/BoosterBotJS/node_modules/discord.js/src/client/actions/MessageCreate.js:28:14)
at module.exports [as MESSAGE_CREATE] (/Users/nitr0h/Developer/BoosterBotJS/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (/Users/nitr0h/Developer/BoosterBotJS/node_modules/discord.js/src/client/websocket/WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (/Users/nitr0h/Developer/BoosterBotJS/node_modules/discord.js/src/client/websocket/WebSocketManager.js:239:12)
at WebSocketManager.emit (/Users/nitr0h/Developer/BoosterBotJS/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.<anonymous> (/Users/nitr0h/Developer/BoosterBotJS/node_modules/@discordjs/ws/dist/index.js:1173:51)
at WebSocketShard.emit (/Users/nitr0h/Developer/BoosterBotJS/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:397:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v20.7.0
[nodemon] app crashed - waiting for file changes before starting...
6 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
Nitr0h Da Bear
Nitr0h Da BearOP15mo ago
For whatever reason this file is the only file so far to give me this error despite me defining a embed the exact same way in other files? The error came out of nowhere too because I don't really touch this file.
Danial
Danial15mo ago
That's a really basic JavaScript error, did you forget to put const before blacklistLog?
Nitr0h Da Bear
Nitr0h Da BearOP15mo ago
I mean I followed a djs tutorial and they didnt put const before it and it worked. 🤷🏿‍♂️ Just confused on why all of a sudden it doesnt for this file
Mark
Mark15mo ago
You need to use const or let before defining a variable the first time. After that, you can use variable = to re-assign its value (if you defined it with let)
Nitr0h Da Bear
Nitr0h Da BearOP15mo ago
Alr thanks
Want results from more Discord servers?
Add your server