blob: ebc10fca6851eae3c41233c10f2ef38bd82ff8c7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
import logging
import random
from discord.ext import commands
log = logging.getLogger(__name__)
class Fun:
"""
A collection of general commands for fun.
"""
def __init__(self, bot):
self.bot = bot
@commands.command()
async def roll(self, ctx, str_input: str = None):
output = ""
if not str_input:
output = "To use .roll, format it as such: .roll (number)"
else:
try:
num_rolls = int(str_input)
if num_rolls > 6:
num_rolls = 6
elif num_rolls < 1:
return
for i in range(num_rolls):
output += ":terning%d: " % random.randint(1, 6)
except ValueError:
return
await ctx.send(output)
# Required in order to load the cog, use the class name in the add_cog function.
def setup(bot):
bot.add_cog(Fun(bot))
log.debug("Fun cog loaded")
|