diff options
| author | Rapptz <[email protected]> | 2017-05-15 02:52:20 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-05-15 02:52:20 -0400 |
| commit | c1130d287970b5252bab7a9b797f53630352c9e6 (patch) | |
| tree | 954fac373bcf0ed2c646d555cbb7c117989ceb17 | |
| parent | Use describe for Colour documentation. (diff) | |
| download | discord.py-c1130d287970b5252bab7a9b797f53630352c9e6.tar.xz discord.py-c1130d287970b5252bab7a9b797f53630352c9e6.zip | |
[commands] Update check examples to work with rewrite.
| -rw-r--r-- | discord/ext/commands/core.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/discord/ext/commands/core.py b/discord/ext/commands/core.py index 17925f59..67a5e9f5 100644 --- a/discord/ext/commands/core.py +++ b/discord/ext/commands/core.py @@ -924,12 +924,12 @@ def check(predicate): .. code-block:: python def check_if_it_is_me(ctx): - return ctx.message.author.id == 'my-user-id' + return ctx.message.author.id == 85309593344815104 @bot.command() @commands.check(check_if_it_is_me) - async def only_for_me(): - await bot.say('I know you!') + async def only_for_me(ctx): + await ctx.send('I know you!') Transforming common checks into its own decorator: @@ -937,13 +937,13 @@ def check(predicate): def is_me(): def predicate(ctx): - return ctx.message.author.id == 'my-user-id' + return ctx.message.author.id == 85309593344815104 return commands.check(predicate) @bot.command() @is_me() - async def only_me(): - await bot.say('Only you!') + async def only_me(ctx): + await ctx.send('Only you!') """ @@ -1003,8 +1003,8 @@ def has_any_role(*names): @bot.command() @commands.has_any_role('Library Devs', 'Moderators') - async def cool(): - await bot.say('You are cool indeed') + async def cool(ctx): + await ctx.send('You are cool indeed') """ def predicate(ctx): if not isinstance(ctx.channel, discord.abc.GuildChannel): @@ -1033,8 +1033,8 @@ def has_permissions(**perms): @bot.command() @commands.has_permissions(manage_messages=True) - async def test(): - await bot.say('You can manage messages.') + async def test(ctx): + await ctx.send('You can manage messages.') """ def predicate(ctx): |