diff options
| author | 2019-04-03 12:02:07 +1000 | |
|---|---|---|
| committer | 2019-04-03 12:02:07 +1000 | |
| commit | 34696abc0f3e26f089a046f85fb0d65eb4573365 (patch) | |
| tree | bb8b152543631ed8e76182c8b8f62f82049c2034 /bot/seasons | |
| parent | Merge pull request #173 from Suhail6inkling/egghead_quiz (diff) | |
| parent | Update bot/seasons/easter/traditions.py (diff) | |
Merge pull request #181 from RohanRadia/master
Created traditions.py and completed the easter_tradition command
Diffstat (limited to 'bot/seasons')
| -rw-r--r-- | bot/seasons/easter/traditions.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bot/seasons/easter/traditions.py b/bot/seasons/easter/traditions.py new file mode 100644 index 00000000..05cd79f3 --- /dev/null +++ b/bot/seasons/easter/traditions.py @@ -0,0 +1,33 @@ +import json +import logging +import random +from pathlib import Path + +from discord.ext import commands + +log = logging.getLogger(__name__) + +with open(Path('bot', 'resources', 'easter', 'traditions.json'), 'r', encoding="utf8") as f: + traditions = json.load(f) + + +class Traditions(commands.Cog): + """A cog which allows users to get a random easter tradition or custom from a random country.""" + + def __init__(self, bot): + self.bot = bot + + @commands.command(aliases=('eastercustoms',)) + async def easter_tradition(self, ctx): + """Responds with a random tradition or custom""" + + random_country = random.choice(list(traditions)) + + await ctx.send(f"{random_country}:\n{traditions[random_country]}") + + +def setup(bot): + """Traditions Cog load.""" + + bot.add_cog(Traditions(bot)) + log.info("Traditions cog loaded") |