本文整理汇总了Python中cogs.utils.checks.is_owner方法的典型用法代码示例。如果您正苦于以下问题:Python checks.is_owner方法的具体用法?Python checks.is_owner怎么用?Python checks.is_owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogs.utils.checks
的用法示例。
在下文中一共展示了checks.is_owner方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: elaborate_response
# 需要导入模块: from cogs.utils import checks [as 别名]
# 或者: from cogs.utils.checks import is_owner [as 别名]
def elaborate_response(self, trigger, r):
settings = self.bot.settings
is_owner = (trigger.owner == settings.owner or
trigger.owner in settings.co_owners)
if not is_owner:
return "text", r
if not r.startswith("file:"):
return "text", r
else:
path = r.replace("file:", "").strip()
path = os.path.join("data", "trigger", "files", path)
if os.path.isfile(path):
return "file", path
else:
return "text", r
示例2: can_edit
# 需要导入模块: from cogs.utils import checks [as 别名]
# 或者: from cogs.utils.checks import is_owner [as 别名]
def can_edit(self, user):
settings = self.bot.settings
server = user.server
admin_role = settings.get_server_admin(server)
# Using the is_owner_check would be better but I don't always have
# context here, nor I feel like mocking it
is_owner = user.id == settings.owner or user.id in settings.co_owners
is_admin = discord.utils.get(user.roles, name=admin_role) is not None
is_trigger_owner = user.id == self.owner
trigger_is_global = self.server is None
if trigger_is_global:
return is_trigger_owner or is_owner
else:
return is_trigger_owner or is_owner or is_admin
示例3: cog_check
# 需要导入模块: from cogs.utils import checks [as 别名]
# 或者: from cogs.utils.checks import is_owner [as 别名]
def cog_check(self, ctx):
"""This check is called before running any command from this cog.
If this returns true, the command can be run, otherwise it can't.
This is also called when you /help is called, to check if the command is available to the user."""
# Only the bot owner can use the commands in this cog
return await checks.is_owner(ctx)