Mace
Mace

Reputation: 23

discord.js: Bot is sending the same embed twice

I programmed my discord bot to reply with a message when i type down a certain command, but for some reason, its sending the same embed twice. I couldn't figure out why. Here's my code:

const Discord = require('discord.js');
const client = new Discord.Client();

client.on("message", message => {

     if (message.content.toLowerCase().startsWith(prefix + "clear")) {
        message.channel.messages.fetch({limit: 100}).then(messages => {         
        message.channel.bulkDelete(messages)});

        const deleteEmbed = new Discord.MessageEmbed()
        .setColor('#ffd6d6')
        .setTitle('Bot has completed the action of clearing messages.\n')
        .setDescription(`Bot has deleted some messages.`)
        client.channels.cache.get('757945678772305921').send(deleteEmbed); 
    }
}); 

Upvotes: 2

Views: 932

Answers (2)

Liam Skinner
Liam Skinner

Reputation: 1

This Code works for me

client.on('message', message => {
  const args = message.content.slice(prefix.length).split(/ +/);
  const command = args.shift().toLowerCase();
  if (!message.content.startsWith(prefix) || message.author.bot) return;
  if (command.includes('blacklist')) {
    message.react('💯')
    const blacklistEmbed = new Discord.MessageEmbed()
      .setColor('#ffd6d6')
      .setTitle('!Blacklist\n')
      .setDescription('Private Messages\nCheck Your PMs For More Information')
    message.channel.send(blacklistEmbed)
    const blacklist2Embed = new Discord.MessageEmbed()
      .setColor('#ffd6d6')
      .setTitle('!Blacklist\n')
      .addField("Banned Words Are;", profanities)
    message.author.send(blacklist2Embed)
  }
});

Upvotes: 0

Emir Güvenni
Emir Güvenni

Reputation: 73

It might be running on another terminal. Try restarting your PC or find and close that terminal.

Upvotes: 2

Related Questions