I'm making a Discord bot that can put peoples' messages into different types of categories to respond to. For some reason it keeps suggesting that the Discord.Message.content
is undefined
when I try to run it.
I've tried searching up if I was defining it correctly and couldn't find much. I'm doing this with Brain.js:
const network = new brain.recurrent.LSTM();
const trainingData = data.map(item => ({
input: item.message,
output: item.category
}));
network.train(trainingData, {
interations: 2000
});
bot.on('message', msg =>{
const raw = network.run(Discord.Message.content)
});
Replace this:
bot.on('message', msg =>{
const raw = network.run(Discord.Message.content)
})
with this:
bot.on('message', msg =>{
const raw = network.run(msg.content)
})
Discord.Message
is the type of object (aka "class"), whereas msg
is the object itself. The docs will refer to Message
objects, which msg
is one of, but to access the content of a specific message you need to use the variable holding that specific message, which is msg
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.