creed
creed

Reputation: 1427

Deleting every channel in a specified category in discord.py

I am trying to delete every channel in a specified category in discord.py.

My code so far:

category = client.get_channel(my_id_here)

I was thinking of iterating through each of the channels in that category however I'm not sure how to go about doing so.

I saw a similar post on this however that's in discord.js so I would need the discord.py equivalent.

Upvotes: 1

Views: 1090

Answers (1)

creed
creed

Reputation: 1427

Figured out the solution, hope it helps someone:

category = client.get_channel(id_here)

for channel in category.voice_channels:
    await channel.delete()

If you want to remove text channels, replace voice_channels with text_channels

Upvotes: 3

Related Questions