Deleting all messages in discord.js text channel

后端 未结 7 1594
梦如初夏
梦如初夏 2021-02-09 18:09

Ok, so I searched for a while, but I couldn\'t find any information on how to delete all messages in a discord channel. And by all messages I mean every single message ever writ

7条回答
  •  太阳男子
    2021-02-09 19:06

    This will work on discord.js version 12.2.0 Just put this inside your client on message event and type the command: !nuke-this-channel Every message on channel will get wiped then, a kim jong un meme will be posted.

    if (msg.content.toLowerCase() == '!nuke-this-channel') {
        async function wipe() {
            var msg_size = 100;
            while (msg_size == 100) {
                await msg.channel.bulkDelete(100)
            .then(messages => msg_size = messages.size)
            .catch(console.error);
            }
            msg.channel.send(`<@${msg.author.id}>\n> ${msg.content}`, { files: ['http://www.quickmeme.com/img/cf/cfe8938e72eb94d41bbbe99acad77a50cb08a95e164c2b7163d50877e0f86441.jpg'] })
        }
        wipe()
    }
    

提交回复
热议问题