我如何制作正确的 "nuke" 命令 discord.py

How do i make a proper "nuke" command discord.py

好的,我想创建一个 "nuke" 命令,基本上保存旧的名称、主题和权限,删除频道并使用相同的权限、名称和主题将其添加回来。我该怎么做?

discord.py API defines the various properties and methods one may manipulate for a Discord Channel. Rather than hard-coding this, I would recommend using the clone() 方法,给定一个频道,

Clones this channel. This creates a channel with the same properties as this channel.

届时,您可以通过 delete() 删除旧频道。

这是我使用的代码,希望对您有所帮助

@client.command()
async def nuke(ctx, channel: discord.TextChannel = None):
    if channel == None: 
        await ctx.send("You did not mention a channel!")
        return

    nuke_channel = discord.utils.get(ctx.guild.channels, name=channel.name)

    if nuke_channel is not None:
        new_channel = await nuke_channel.clone(reason="Has been Nuked!")
        await nuke_channel.delete()
        await new_channel.send("THIS CHANNEL HAS BEEN NUKED!")
        await ctx.send("Nuked the Channel sucessfully!")

    else:
        await ctx.send(f"No channel named {channel.name} was found!")

只需使用 mee6 和 !delete [要删除的消息数]

在命令中

@commands.has_permissions(administrator=True)
@client.command
async def nuke():