[commands] Update check examples to work with rewrite.
This commit is contained in:
parent
4023510032
commit
c1130d2879
@ -924,12 +924,12 @@ def check(predicate):
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
def check_if_it_is_me(ctx):
|
def check_if_it_is_me(ctx):
|
||||||
return ctx.message.author.id == 'my-user-id'
|
return ctx.message.author.id == 85309593344815104
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
@commands.check(check_if_it_is_me)
|
@commands.check(check_if_it_is_me)
|
||||||
async def only_for_me():
|
async def only_for_me(ctx):
|
||||||
await bot.say('I know you!')
|
await ctx.send('I know you!')
|
||||||
|
|
||||||
Transforming common checks into its own decorator:
|
Transforming common checks into its own decorator:
|
||||||
|
|
||||||
@ -937,13 +937,13 @@ def check(predicate):
|
|||||||
|
|
||||||
def is_me():
|
def is_me():
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
return ctx.message.author.id == 'my-user-id'
|
return ctx.message.author.id == 85309593344815104
|
||||||
return commands.check(predicate)
|
return commands.check(predicate)
|
||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
@is_me()
|
@is_me()
|
||||||
async def only_me():
|
async def only_me(ctx):
|
||||||
await bot.say('Only you!')
|
await ctx.send('Only you!')
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -1003,8 +1003,8 @@ def has_any_role(*names):
|
|||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
@commands.has_any_role('Library Devs', 'Moderators')
|
@commands.has_any_role('Library Devs', 'Moderators')
|
||||||
async def cool():
|
async def cool(ctx):
|
||||||
await bot.say('You are cool indeed')
|
await ctx.send('You are cool indeed')
|
||||||
"""
|
"""
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
if not isinstance(ctx.channel, discord.abc.GuildChannel):
|
if not isinstance(ctx.channel, discord.abc.GuildChannel):
|
||||||
@ -1033,8 +1033,8 @@ def has_permissions(**perms):
|
|||||||
|
|
||||||
@bot.command()
|
@bot.command()
|
||||||
@commands.has_permissions(manage_messages=True)
|
@commands.has_permissions(manage_messages=True)
|
||||||
async def test():
|
async def test(ctx):
|
||||||
await bot.say('You can manage messages.')
|
await ctx.send('You can manage messages.')
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def predicate(ctx):
|
def predicate(ctx):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user