本文整理匯總了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)