首页 > 解决方案 > 如何使用 Python 删除 Discord 频道?

问题描述

@Bot.command(pass_context= True)
async def complete(ctx):
    guild = ctx.message.guild
    id_admin = discord.Role.id=658306078928273408
    overwrites = {
        id_admin: discord.PermissionOverwrite(send_messages=True),
        guild.me: discord.PermissionOverwrite(read_messages=True),

    }
    await guild.delete_text_channel(discord.TextChannel.name)

我没有在 Discord API 中找到正确的属性。
我应该使用什么属性来删除我编写命令的通道?
Error: AttributeError: 'Guild' object has no attribute 'delete_text_channel'

标签: pythonpython-3.xdiscord.py

解决方案


您可以将该GuildChannel.delete方法与 . 的任何子类一起使用GuildChannel
您可以使用 检索TextChannel发送的消息Context.channel

您不应该修改 discord.py 类的属性,而应该引用这些类的特定对象/实例的属性。


推荐阅读