python - 如何使用 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'
解决方案
您可以将该GuildChannel.delete
方法与 . 的任何子类一起使用GuildChannel
。
您可以使用 检索TextChannel
发送的消息Context.channel
。
您不应该修改 discord.py 类的属性,而应该引用这些类的特定对象/实例的属性。
推荐阅读
- npm - 电子安装错误:为“electron-v2.0.2-win32-x64.zip”生成的校验和与预期的校验和不匹配
- python - groupby 一列并计算另一个熊猫中超过 5 的项目
- mysql - 插入错误 #1452 - 无法添加或更新子行:外键约束失败
- java - 检测到新的指纹登记
- angular - 角材料日期选择器自定义格式
- anylogic - AnyLogic 如何将一个代理链接到另一个代理
- kubernetes - k8s DaemonSet:被拒绝的 Pod 重新创建太快而无法获取任何日志或事件
- javascript - NodeJS & express 使用 Promise 实现 HTTP 模块的 catch 写入功能
- python - matplotlib 图表中感兴趣的阴影区域
- java - Java中数组矩阵中的点积