我正在尝试使该命令只有所有者才能运行。是否有办法检查服务器的最高角色或创建者?
我尝试了“@commands.is_owner()”,但这仅检查某人是否是机器人的所有者。
最佳答案
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 ...
关于python - 如何检查discord.py中的所有者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67036585/