fabian silva
fabian silva

Reputation: 55

How do i Bulk delete a specific channel?

I just want to know how i can bulk delete only one channel and ignore the rest of the channels whenever someone tries to use the bulk delete command in a different channel.

Upvotes: 0

Views: 291

Answers (1)

Lauren Yim
Lauren Yim

Reputation: 14148

Simply call bulkDelete on the channel that you want to bulk delete.

For example, this code can be used to make !bulkdelete #channel (mentioning the channel) bulk delete the messages in #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()
  }
})

Upvotes: 1

Related Questions