Reputation: 1
const editedMessages = new Discord.Collection();
client.on("messageUpdate", (oldMessage, newMessage) => {
if(oldMessage.content === newMessage.content)return
client.on('message', message => {
if (message.author.bot) return;
const args = message.content.trim().split(/\s+/g);
const command = args.shift().toLowerCase();
switch (command) {
case 'y!edit':
const msg = editedMessages.get(message.channel.id);
if (!message) return message.reply('There is nothing to snipe');
const edembed = new Discord.MessageEmbed()
.setColor('#deffff')
.setAuthor(newMessage.author.tag, newMessage.author.avatarURL({ dynamic: true }))
.setDescription(`**Old message:** ${oldMessage.content} \n **New message:** ${newMessage.content}`)
.setFooter(`ID: ${newMessage.author.id}`).setTimestamp()
message.channel.send({ embeds: [edembed] }).catch(err => console.error(err));
break;
}
});
});
client.on('messageUpdate', message => {
editedMessages.set(message.channel.id, message);
});
I want it to send only one embed when the command is used repeatedly. As you can see in the screenshot provided, every time the command was used it sent the previous embeds too. I've been stuck on this command line for ages.
Upvotes: 0
Views: 53
Reputation: 1353
It appears as if you are forgetting to close your preexisting bot connections.
Upvotes: 0