Ask coding questions

← Back to all posts
handler/console.js
daddyzenith (0)

So I get the error when I try to run the code

Error:

/home/runner/500-cmd-1/handler/console.js:5
bot.channels.cache.get(messages.channels.id).send(x.join("message"));
^

ReferenceError: messages is not defined
at ReadStream.<anonymous> (/home/runner/500-cmd-1/handler/console.js:5:36)
at ReadStream.emit (events.js:314:20)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:272:9)
at ReadStream.Readable.push (_stream_readable.js:213:10)
at TTY.onStreamRead (internal/stream_base_commons.js:188:23)

What code I have in handler/console.js

Code:

module.exports = (bot, message) => {
let prompt = process.openStdin()
prompt.addListener("data", res => {
let x = res.toString().trim().split(/ +/g)
bot.channels.cache.get(messages.channels.id).send(x.join(" "));
});
};

Comments
hotnewtop
Coder100 (18903)

Here is your error:

bot.channels.cache.get(messages.channels.id).send(x.join("message"))
// ---------------------^

you never defined messages.

daddyzenith (0)

@Coder100 THanks for the respone but I have fixed this problem already! Thanks anyways! If you want to check out the bot I made then head over to https://dashboard.daddyzenith.repl.co/ !!!

Coder100 (18903)

cool! What was the problem? @daddyzenith