如何批量删除特定频道?

时间:2020-05-20 05:19:20

标签: bots discord discord.js

我只是想知道如何在有人尝试在其他频道中使用批量删除命令时批量删除一个频道,而忽略其余频道。

1 个答案:

答案 0 :(得分:1)

只需在要批量删除的频道上调用bulkDelete

例如,此代码可用于使!bulkdelete #channel(提及频道)批量删除#channel中的消息:

client.on('message', message => {
  if (message.content.startsWith('!bulkdelete') {
    const channel = message.mentions.channels.first()
    // you can also bulk delete a news (announcement) channel so if you need to cater for
    // those use if (channel.type !== 'text' && channel.type !== 'news')
    if (channel.type !== 'text') {
      // you can't bulk delete a voice (or store) channel
      return
    }
    channel.bulkDelete()
  }
})