Discord bot simple editing its own message gives me error

The “message” variable has the exact same name ad the “message” variable in the client.on('message') so change it to ‘msg’ and everything should work fine :

module.exports = {
 name: 'hack',
 execute: function(message, args) {
  const user = message.mentions.users.first() || args[0];

  const member = message.guild.member(user);

  if (member) {
   message.channel
    .send('Scrambling Through Database')

    .then((msg) => {
     setTimeout(function() {
      msg.edit(`Working on hack`);
     }, 4000);
    });

   // all codings

   setTimeout(function() {
    msg.edit(`A successful hack was complete and it was real`);
   }, 3000);
  } else {
   message.channel.send(
    'Who are you even trying to hack? Is it that tough to mention a user?'
   );
  }
 },
};

Leave a Comment