Permission System for Discord.py Bot

后端 未结 3 2002
挽巷
挽巷 2021-01-04 21:50

I am in the process of making a discord bot using discord.py and asyncio. The bot has commands like kick and ban which obviously should not be avai

3条回答
  •  暖寄归人
    2021-01-04 22:06

    You could also use decorators.

    @bot.command(name = "Kick")
    @bot.has_permissions(kick_user = True)
    @bot.bot_has_permissions(kick_user = True)
    async def _kick(ctx, member: Member):
        #Do stuff...
    

    The advantage of checking user and bot permissions means it is easier to handle errors from either providing useful "Insufficient Permission" error messages.

提交回复
热议问题