简体   繁体   中英

Discord.js Deleting Command Messages

On my Discord bot (ran off of Node.js), I am having issues for it deleting message commands, so when a user sends a command, the bot replies. How do I make the bot delete the users message, but keep the bots command? Because this doesn't work:

let cnt = message.content

 if (cnt !== " ") {
   const cn = message.channel
   let channel = message.channel.name
   let guild = message.guild.name
   message.id.delete
   console.log(`${s(guild + ', ' + channel)} | ${w(cnt)}`)
   cn.send(cnt);
 }

(w and s are chalk commands.)

Fixed.

    let cnt = message.content
    if (cnt !== " ") {
        const cn = message.channel
        message.delete(500) // ?
        let channel = message.channel.name
        let guild = message.guild.name
        console.log(`${s(guild + ', ' + channel)} | ${w(cnt)}`)
        cn.send(cnt);
      }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM