so the bot runs smoothly with these codes, all the prefix command are working except the embed message. When I want to send an embed message an error appears (The bot didn't send any embed message and went offline a few minutes later)
Codes:
const Discord = require('discord.js');
const client = new Discord.Client({ intents: 32767 });
const { MessageEmbed } = require('discord.js');
client.on('ready', () => {
console.log('Bot is online!');
});
client.on('messageCreate', (message) => {
const prefix = '.';
if (!message.content.startsWith(prefix)) return;
if (message.content === `${prefix}hello`) {
message.channel.send("Hello, I'm I.R.F.A.N.\nIntegrted Robot For Assistant Needs\nI'm Currently In Development");
}
if (message.content === `${prefix}embed`) {
let embed = new Discord.MessageEmbed()
.setTitle("Title")
.setDescription("Description")
.setColor("#0099ff")
message.channel.send({embed:[embed]});
}
});
client.login('token censored');
Terminal:
throw new DiscordAPIError(data, res.status, request);
^
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (C:\Users\M. IRFAN NAZRIL\Documents\Belajar Coding\discord bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\M. IRFAN NAZRIL\Documents\Belajar Coding\discord bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async TextChannel.send (C:\Users\M. IRFAN NAZRIL\Documents\Belajar Coding\discord bot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:176:15) {
method: 'post',
path: '/channels/990157044688494663/messages',
code: 50006,
httpStatus: 400,
requestData: {
json: {
content: undefined,
tts: false,
nonce: undefined,
embeds: undefined,
components: undefined,
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
It says, "tts: false," but I've allowed all the permissions in discord
You sent the message incorrectly. It should be:
message.channel.send({ embeds: [embed] })