【发布时间】:2021-08-28 20:04:22
【问题描述】:
#deleted unused registered channels
@bot.command(pass_context=True)
#so that only an admin can run this command
@commands.has_role('Admin')
async def unregister(ctx, catID):
cat = discord.utils.get(ctx.guild.categories, id = catID)
#await ctx.channel.send(cat)
for channel in cat.voice_channels:
await channel.delete()
for channel in cat.text_channels:
await channel.delete()
cat.delete()
这是我目前拥有的代码。我也用 client.get_channel() 尝试过。我似乎收到类别无法访问 .voice_channels 和 .text_channels 的错误,或者 cat 是“NoneType”。我是 python 和编写不和谐机器人的新手,所以对这个命令的任何帮助都会很棒。谢谢!
该命令旨在获取您可以通过右键单击并在 discord 上复制类别来获得的类别 ID。然后删除它下面的每个语音和文本通道。然后删除自己。
【问题讨论】:
-
究竟是什么错误?
标签: python discord discord.py