'need help understanding (node:18496) DeprecationWarning error, help please?
im new to discord.js trying to learn to make a bot but i keep getting "cannot sent empty message" heres my code, can someone help me understand this error?
const Discord = require("discord.js");
const client = new Discord.Client({intents:["GUILDS","GUILD_MESSAGES"]});
const token = require("./token.js");
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {
if (msg.content.includes("docs")){
msg.reply([
"if you're looking for docs",
"more to come soon"
]);
}
});
client.login(token);
Solution 1:[1]
I tried your codes after sending the word docs
It will loop. So try to change the code:
client.on('message', msg => {
if (msg.content.includes("docs")){
msg.reply([
"if you're looking for docs",
"more to come soon"
]);
}
});
To this:
client.on('messageCreate', msg => {
if(msg.content.includes("docs")) {
msg.reply({content: "if you're looking for some of it, more to come soon"})
}
});
Can be like this too:
client.on('messageCreate', msg => {
if(msg.content.includes("docs")) {
msg.reply("if you're looking for some of it, more to come soon")
}
});
Because the bot will send another word docs
that's why it will loop.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | æ–°Acesyyy |