我正在尝试删除我的 discord 服务器中的所有角色,但这需要花费大量时间。所以我决定用 discord.py
机器人来完成这个任务,但我收到了这个错误:
discord.errors.HTTPException: 400 Bad Request (error code: 50028): Invalid Role
这是我的代码:
@client.command()
async def delroles(ctx):
for role in ctx.guild.roles:
await role.delete()
最佳答案
问题是所有用户都有一个名为@everyone
的“隐形角色”,这是无法删除的。
做:
async def delroles(ctx):
for role in ctx.guild.roles:
try:
await role.delete()
except:
await ctx.send(f"Cannot delete {role.name}")
关于python - Discord.py 如何删除服务器中的所有角色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68820168/