72e84a1 Apr 9, 2016
1 contributor

Users who have contributed to this file

66 lines (52 sloc) 1.76 KB
import discord
from discord.ext import commands
import random
description = '''An example bot to showcase the discord.ext.commands extension
There are a number of utility commands being showcased here.'''
bot = commands.Bot(command_prefix='?', description=description)
async def on_ready():
print('Logged in as')
async def add(left : int, right : int):
"""Adds two numbers together."""
await bot.say(left + right)
async def roll(dice : str):
"""Rolls a dice in NdN format."""
rolls, limit = map(int, dice.split('d'))
except Exception:
await bot.say('Format has to be in NdN!')
result = ', '.join(str(random.randint(1, limit)) for r in range(rolls))
await bot.say(result)
@bot.command(description='For when you wanna settle the score some other way')
async def choose(*choices : str):
"""Chooses between multiple choices."""
await bot.say(random.choice(choices))
async def repeat(times : int, content='repeating...'):
"""Repeats a message multiple times."""
for i in range(times):
await bot.say(content)
async def joined(member : discord.Member):
"""Says when a member joined."""
await bot.say('{} joined in {0.joined_at}'.format(member))
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))
async def _bot():
"""Is the bot cool?"""
await bot.say('Yes, the bot is cool.')'token')