Search code examples
javascriptdiscorddiscord.jsembed

making the embed change color during a time discord.js


    case 'test':
      let timed = "10s"
      const tests = new Discord.RichEmbed()
      .setTitle("tets")
      .setColor('#000000')

      message.channel.send(tests);
      setTimeout(function(){
      tests.setColor('#5e4242')
      }, ms(timed));

      break;

so im trying to make the embed's color change after 10 secs,this is a test command so its called test.I tried many ways and i searched google and it showed this so i decided to try it and it does completly nothing.I use richembed because when i use messagemebed it says client error


Solution

  • You would need to set the message you send into a variable and then edit that message.

      let timed = "10s"
      const tests = new Discord.RichEmbed()
      .setTitle("tets")
      .setColor('#000000')
    
      const res = await message.channel.send(tests);
      setTimeout(function(){
         tests.setColor('#5e4242');
         res.edit(tests);
      }, ms(timed));
    

    Should also note, await only works in an async function