如何在 discord.py rewrite 中检查作者是否是管理员
How to check if author is an administrator in discord.py rewrite
我想在he/she使用discord.py
的重写分支中的命令之前检查作者是否是管理员
我试过了:
@client.command() #Command to delete messages in bulk.
async def clear(ctx, amount=100):
if ctx.message.author.server_permissions.administrator:
await ctx.channel.purge(limit = amount+1)
await ctx.send(str(amount) + ' messages deleted.')
else:
await ctx.send('No can do mister!')
但这返回了一个错误,我猜是因为它对重写分支不起作用。有什么想法吗?
而不是使用:
ctx.message.author.server_permissions.administrator
您想使用:
ctx.message.author.guild_permissions.administrator
我想在he/she使用discord.py
的重写分支中的命令之前检查作者是否是管理员我试过了:
@client.command() #Command to delete messages in bulk.
async def clear(ctx, amount=100):
if ctx.message.author.server_permissions.administrator:
await ctx.channel.purge(limit = amount+1)
await ctx.send(str(amount) + ' messages deleted.')
else:
await ctx.send('No can do mister!')
但这返回了一个错误,我猜是因为它对重写分支不起作用。有什么想法吗?
而不是使用:
ctx.message.author.server_permissions.administrator
您想使用:
ctx.message.author.guild_permissions.administrator