我试图让这个命令只有所有者才能运行它。是否有办法检查服务器的最高角色或创建者?
我尝试了“@commands.is_owner()”,但这仅检查某人是否是机器人的所有者。
Guild.owner https://discordpy.readthedocs.io/en/latest/api.html?highlight=owner#discord.Guild.owner存在,所以这是它的使用示例!
from discord.ext import commands
bot = commands.Bot(command_prefix="your_prefix")
# example use with custom decorator
def guild_owner_only():
async def predicate(ctx):
return ctx.author == ctx.guild.owner # checks if author is the owner
return commands.check(predicate)
@bot.command()
@guild_owner_only()
async def ...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)