I'm trying to edit an embed message sent by my bot (today) using this code:
const args = message.content.slice(prefix.length).split(' ');
if (!args.length) {
return message.channel.send('Non hai specificato il messaggio!');
}
const nuovoMsg = args.slice(3).join(' ');
const chId = args[1];
const msgId = args[2];
const messaggioNuovo = new Discord.MessageEmbed()
.setColor('#c95f34')
.setDescription(`${nuovoMsg}`);
const msgc = message.guild.channels.cache.get(chId).messages.cache.get(msgId);
msgc.edit(messaggioNuovo);
In a Discord text channel I sent :
njb!embede 709683421210869842 709711387324317746 Prova della modifica
Console Error :
TypeError: Cannot read property 'edit' of undefined
at Object.execute (C:\NNJPBot\commands\embede.js:32:8)
at Client.<anonymous> (C:\NNJPBot\index.js:81:11)
at Client.emit (events.js:315:20)
at MessageCreateAction.handle (C:\NNJPBot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14)
at Object.module.exports [as MESSAGE_CREATE] (C:\NNJPBot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\NNJPBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:386:31)
at WebSocketShard.onPacket (C:\NNJPBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:436:22)
at WebSocketShard.onMessage (C:\NNJPBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:293:10)
at WebSocket.onMessage (C:\NNJPBot\node_modules\ws\lib\event-target.js:125:16)
at WebSocket.emit (events.js:315:20)
Info : njb! : Prefix
embede : Command
message.guild.channels.cache.get(...).messages.cache.fetchis being called. Could you please show the code that caused the error (atembede.js:30:70)? - cherryblossom