@client.command()
@commands.is_owner()
async def nuke(ctx, channel_name):
existing_channel = discord.utils.get(guild.channels, name=channel_name)
if existing_channel is not None:
await clone(name=channel_name,reason="Has been nuked")
await existing_channel.delete()
else:
await ctx.send(f'No channel named **{channel_name}** was found')
I've seen multiple bots on discord that can already do this, via a nuke command, but I wanted to learn how to do this myself. The problem is, my bot is unable to detect that I've mentioned a channel (as seen in the attached image). I found a question similar to this about 'nuking a channel properly' but they were using cogs. Help? This is the attached picture
You're using clone()
wrong, its Channel.clone()
not only clone()
Below is the revised code
@client.command()
@commands.is_owner()
async def nuke(ctx, channel_name):
existing_channel = discord.utils.get(guild.channels, name=channel_name)
if existing_channel is not None:
await existing_channel.clone(reason="Has been nuked")
await existing_channel.delete()
else:
await ctx.send(f'No channel named **{channel_name}** was found')