diff options
Diffstat (limited to 'bot/seasons/evergreen')
| -rw-r--r-- | bot/seasons/evergreen/error_handler.py | 5 | ||||
| -rw-r--r-- | bot/seasons/evergreen/fun.py | 38 | 
2 files changed, 42 insertions, 1 deletions
diff --git a/bot/seasons/evergreen/error_handler.py b/bot/seasons/evergreen/error_handler.py index 6de35e60..47e18a31 100644 --- a/bot/seasons/evergreen/error_handler.py +++ b/bot/seasons/evergreen/error_handler.py @@ -42,9 +42,12 @@ class CommandErrorHandler:                  f"{ctx.author} called the command '{ctx.command}' "
                  "but they were on cooldown!"
              )
 +            seconds = error.retry_after
 +            remaining_minutes, remaining_seconds = divmod(seconds, 60)
 +            time_remaining = f'{int(remaining_minutes)} minutes {math.ceil(remaining_seconds)} seconds'
              return await ctx.send(
                  "This command is on cooldown,"
 -                f" please retry in {math.ceil(error.retry_after)}s."
 +                f" please retry in {time_remaining}."
              )
          if isinstance(error, commands.DisabledCommand):
              logging.debug(
 diff --git a/bot/seasons/evergreen/fun.py b/bot/seasons/evergreen/fun.py new file mode 100644 index 00000000..4da01dd1 --- /dev/null +++ b/bot/seasons/evergreen/fun.py @@ -0,0 +1,38 @@ +import logging +import random + +from discord.ext import commands + +from bot.constants import Emojis + +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, num_rolls: int = 1): +        """ +            Outputs a number of random dice emotes (up to 6) +        """ +        output = "" +        if num_rolls > 6: +            num_rolls = 6 +        elif num_rolls < 1: +            output = ":no_entry: You must roll at least once." +        for _ in range(num_rolls): +            terning = f"terning{random.randint(1, 6)}" +            output += getattr(Emojis, terning, '') +        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")  |