diff options
| author | 2019-02-11 23:31:19 -0700 | |
|---|---|---|
| committer | 2019-02-11 23:31:19 -0700 | |
| commit | 7acabe1a96603ae9d7213fc082bc8a3acd6a1401 (patch) | |
| tree | 389c6dbd036194f0fa816e1bf6d3ec3f4c6b5d4c /bot/seasons/evergreen/fun.py | |
| parent | Merge pull request #106 from python-discord/readme-update (diff) | |
Readded fun.py file to evergreen and added roll command.
Diffstat (limited to 'bot/seasons/evergreen/fun.py')
| -rw-r--r-- | bot/seasons/evergreen/fun.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/bot/seasons/evergreen/fun.py b/bot/seasons/evergreen/fun.py new file mode 100644 index 00000000..ebc10fca --- /dev/null +++ b/bot/seasons/evergreen/fun.py @@ -0,0 +1,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") |