[commands] Add is_owner check and Bot.is_owner.
This commit is contained in:
@@ -37,7 +37,7 @@ from . import converter as converters
|
||||
__all__ = [ 'Command', 'Group', 'GroupMixin', 'command', 'group',
|
||||
'has_role', 'has_permissions', 'has_any_role', 'check',
|
||||
'bot_has_role', 'bot_has_permissions', 'bot_has_any_role',
|
||||
'cooldown', 'guild_only', ]
|
||||
'cooldown', 'guild_only', 'is_owner']
|
||||
|
||||
def wrap_callback(coro):
|
||||
@functools.wraps(coro)
|
||||
@@ -1104,6 +1104,24 @@ def guild_only():
|
||||
|
||||
return check(predicate)
|
||||
|
||||
def is_owner():
|
||||
"""A :func:`check` that checks if the person invoking this command is the
|
||||
owner of the bot.
|
||||
|
||||
This is powered by :meth:`Bot.is_owner`.
|
||||
|
||||
This check raises a special exception, :exc:`NotOwner` that is derived
|
||||
from :exc:`CheckFailure`.
|
||||
"""
|
||||
|
||||
@asyncio.coroutine
|
||||
def predicate(ctx):
|
||||
if not (yield from ctx.bot.is_owner(ctx.author)):
|
||||
raise NotOwner('You do not own this bot.')
|
||||
return True
|
||||
|
||||
return check(predicate)
|
||||
|
||||
def cooldown(rate, per, type=BucketType.default):
|
||||
"""A decorator that adds a cooldown to a :class:`Command`
|
||||
or its subclasses.
|
||||
|
||||
Reference in New Issue
Block a user