how to fix events not working after restarting the bot

Refresh

April 2019

Views

5 time

0

i have a problem with the message reaction, i made the bot to delete any message sent on channel names appeal and send it to another channel names the appeals and react to the message with :white_check_mark: and if someone reacted to the message with the :white_check_mark:, the bot will automaticly delete the bot,

thats working but there is a problem, if i restarting the bot and reacting to the message sent before the restarting , the bot don't deleting the message

why?

client.on('message', async message => {
   if(message.author.bot) return;
  var muted = message.guild.member(message.author).roles.find(j => j.id === "505763004797812766");

    if (muted && message.channel.id === "563944611693854721"){
      var muted = message.guild.member(message.author).roles.find(j => j.id === "505763004797812766");
      const args = message.content.split(" ").slice(0).join(" ");
      const appeal = new Discord.RichEmbed()
      .setAuthor(message.author.username, message.author.avatarURL)
      .setTitle(message.author.username + " appeal")
      .setColor("RED")
      .addField("Message", args);
      message.guild.channels.find(ch => ch.id === "563966341980225536").send(appeal).then(msg => {
        msg.react('✅');

        client.on('messageReactionAdd', (reaction, user) => {
          if(reaction.emoji.name === "✅") {
            const whitecheckmark = (reaction, user) => reaction.emoji.name === "✅";

            const done = msg.createReactionCollector(whitecheckmark, {time: 60000});

            done.on('collect', r => {
              msg.delete();
              message.guild.channels.find(ch => ch.id === "563966341980225536").send(message.author + " Appeal ended by: " + reaction.users.last())

            })
          }
      });


       })



       message.delete();
       message.channel.overwritePermissions(message.author, {SEND_MESSAGES: false}); 



    }
    else if(!muted && message.channel.id === "563944611693854721"){
      message.channel.overwritePermissions(message.author, {SEND_MESSAGES: true});
    }

   });

0 answers