I'm trying to transfer a embed message from a channel to another channel using reactions. I've trying somthing like this:
client.on("messageReactionAdd", (message) => {
let analiseChannel = message.client.channels.cache.get(analiseChannelID);
const channel = message.client.channels.cache.get(aprovadasChannelID);
if (analiseChannel) {
const { content, embeds } = message
channel.send({
content,
embeds
}).then(msg => {
msg.delete({ timeout: 3000 })
})
.catch(console.error);
}
});
And this is the error:
DiscordAPIError: Cannot send an empty message
at RequestHandler.execute (R:\@Aplicações\Discord\hylex\node_modules\discord.js\src\rest\RequestHandler.js:298:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (R:\@Aplicações\Discord\hylex\node_modules\discord.js\src\rest\RequestHandler.js:50:14)
at async TextChannel.send (R:\@Aplicações\Discord\hylex\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:172:15) {
username: undefined,
avatar_url: undefined,
allowed_mentions: undefined,
flags: undefined,
message_reference: undefined,
attachments: undefined,
sticker_ids: undefined
},
files: []
}
}
*I don't know if the way I'm doing is the better one
CodePudding user response:
The messageReactionAdd
event gives an instance of MessageReaction
as its first argument. You can destructure the message
out of it
client.on("messageReactionAdd", ({ message }) => { //notice the braces around "message"
let analiseChannel = message.client.channels.cache.get(analiseChannelID);
const channel = message.client.channels.cache.get(aprovadasChannelID);
if (analiseChannel) {
const { content, embeds } = message
channel.send({
content,
embeds
}).then(msg => {
msg.delete({ timeout: 3000 })
})
.catch(console.error);
}
});