aboutsummaryrefslogtreecommitdiff
path: root/examples/basic_bot.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-01-03 20:57:41 -0500
committerRapptz <[email protected]>2017-01-03 20:58:11 -0500
commitf8a5d890fed1e2c7105964dfd1d310d6d7fa22ee (patch)
tree73365f2e688746a029f1ae8293aa8eca965ffb11 /examples/basic_bot.py
parentFix Messageable.typing context manager. (diff)
downloaddiscord.py-f8a5d890fed1e2c7105964dfd1d310d6d7fa22ee.tar.xz
discord.py-f8a5d890fed1e2c7105964dfd1d310d6d7fa22ee.zip
Update examples to match the new rewrite API.
Diffstat (limited to 'examples/basic_bot.py')
-rw-r--r--examples/basic_bot.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/examples/basic_bot.py b/examples/basic_bot.py
index 7d1c83c8..88909f44 100644
--- a/examples/basic_bot.py
+++ b/examples/basic_bot.py
@@ -16,50 +16,50 @@ async def on_ready():
print('------')
@bot.command()
-async def add(left : int, right : int):
+async def add(ctx, left: int, right: int):
"""Adds two numbers together."""
- await bot.say(left + right)
+ await ctx.send(left + right)
@bot.command()
-async def roll(dice : str):
+async def roll(ctx, dice: str):
"""Rolls a dice in NdN format."""
try:
rolls, limit = map(int, dice.split('d'))
except Exception:
- await bot.say('Format has to be in NdN!')
+ await ctx.send('Format has to be in NdN!')
return
result = ', '.join(str(random.randint(1, limit)) for r in range(rolls))
- await bot.say(result)
+ await ctx.send(result)
@bot.command(description='For when you wanna settle the score some other way')
-async def choose(*choices : str):
+async def choose(ctx, *choices: str):
"""Chooses between multiple choices."""
- await bot.say(random.choice(choices))
+ await ctx.send(random.choice(choices))
@bot.command()
-async def repeat(times : int, content='repeating...'):
+async def repeat(ctx, times: int, content='repeating...'):
"""Repeats a message multiple times."""
for i in range(times):
- await bot.say(content)
+ await ctx.send(content)
@bot.command()
-async def joined(member : discord.Member):
+async def joined(ctx, member: discord.Member):
"""Says when a member joined."""
- await bot.say('{0.name} joined in {0.joined_at}'.format(member))
+ await ctx.send('{0.name} joined in {0.joined_at}'.format(member))
[email protected](pass_context=True)
async def cool(ctx):
"""Says if a user is cool.
In reality this just checks if a subcommand is being invoked.
"""
if ctx.invoked_subcommand is None:
- await bot.say('No, {0.subcommand_passed} is not cool'.format(ctx))
+ await ctx.send('No, {0.subcommand_passed} is not cool'.format(ctx))
@cool.command(name='bot')
-async def _bot():
+async def _bot(ctx):
"""Is the bot cool?"""
- await bot.say('Yes, the bot is cool.')
+ await ctx.send('Yes, the bot is cool.')
bot.run('token')