📌  相关文章
📜  如何将命令限制为 discord.py 中的权限 - Python 代码示例

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

代码示例2
from discord import Member
from discord.ext.commands import has_permissions, MissingPermissions

@bot.command(name="kick", pass_context=True)
@has_permissions(manage_roles=True, ban_members=True)
async def _kick(ctx, member: Member):
    await bot.kick(member)

@_kick.error
async def kick_error(error, ctx):
    if isinstance(error, MissingPermissions):
        text = "Sorry {}, you do not have permissions to do that!".format(ctx.message.author)
        await bot.send_message(ctx.message.channel, text)