I'm trying to create a command that allows the user to delete every Text-Channel in their server. I've got an error when running this piece of code.
AttributeError: 'Guild' object has no attribute 'delete_text_channel'
@client.command()
async def test(ctx):
guild = ctx.message.guild
for channel in guild.channels:
guild.delete_text_channel(channel)
Use await channel.delete().
As your error message sais, the object 'Guild' has no attribute 'delete_text_channel'
The correct way would be:
@client.command()
async def test(ctx):
guild = ctx.guild
for channel in guild.channels:
await channel.delete()
Alternatively, you can add a reason why you deleted the message, which would show up in the audit log:
channel.delete("Because I can")
More information here.
guild.channels calls all channels, not only Textchannels.
To call Textchannels only, use guild.text_channels.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With