📌  相关文章
📜  discord py 检查用户是否是管理员 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:51.344000             🧑  作者: Mango

代码示例1
from discord.ext.commands import Bot, has_permissions, CheckFailure

client = Bot()

@client.command(pass_context=True)
@has_permissions(administrator=True)
async def whoami(ctx):
    msg = "You're an admin {}".format(ctx.message.author.mention)  
    await client.send_message(ctx.message.channel, msg)

@whoami.error
async def whoami_error(error, ctx):
    if isinstance(error, CheckFailure):
        msg = "You're an average joe {}".format(ctx.message.author.mention)  
        await client.send_message(ctx.message.channel, msg)