UserGames Asked:2020-08-23 20:02:00 +0800 CST2020-08-23 20:02:00 +0800 CST 2020-08-23 20:02:00 +0800 CST 如何确保只有具有特定角色的人才能使用该命令 [关闭] 772 我需要以某种方式做到这一点,以便只有具有某些角色的人才能使用管理命令。 python 1 个回答 Voted Best Answer Serg Bocharov 2020-08-23T20:08:55+08:002020-08-23T20:08:55+08:00 请参阅文档。检查 def is_guild_owner(): def predicate(ctx): return ctx.guild is not None and ctx.guild.owner_id == ctx.author.id return commands.check(predicate) @bot.command() @commands.check_any(commands.is_owner(), is_guild_owner()) async def only_for_owners(ctx): await ctx.send('Hello mister owner!') 特别是在你的情况下,是这样的: @bot.command() @commands.has_any_role('Library Devs', 'Moderators', 492212595072434186) async def cool(ctx): await ctx.send('You are cool indeed')
请参阅文档。检查
特别是在你的情况下,是这样的: