diff options
author | 2021-03-04 17:13:05 -0800 | |
---|---|---|
committer | 2021-03-04 17:13:05 -0800 | |
commit | 872d11c0a6ae7a1e1803a9937bf15866849ed649 (patch) | |
tree | 6868c442e2a990a1a729438bca53273ef466ec66 /bot/exts/evergreen/pythonfacts.py | |
parent | Removed the Question about the Nile and changed the IDs to matc the order again (diff) | |
parent | Merge pull request #596 from MrKomodoDragon/master (diff) |
Merge branch 'master' into trivia
Diffstat (limited to 'bot/exts/evergreen/pythonfacts.py')
-rw-r--r-- | bot/exts/evergreen/pythonfacts.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bot/exts/evergreen/pythonfacts.py b/bot/exts/evergreen/pythonfacts.py new file mode 100644 index 00000000..457c2fd3 --- /dev/null +++ b/bot/exts/evergreen/pythonfacts.py @@ -0,0 +1,33 @@ +import itertools + +import discord +from discord.ext import commands + +from bot.constants import Colours + +with open('bot/resources/evergreen/python_facts.txt') as file: + FACTS = itertools.cycle(list(file)) + +COLORS = itertools.cycle([Colours.python_blue, Colours.python_yellow]) + + +class PythonFacts(commands.Cog): + """Sends a random fun fact about Python.""" + + def __init__(self, bot: commands.Bot) -> None: + self.bot = bot + + @commands.command(name='pythonfact', aliases=['pyfact']) + async def get_python_fact(self, ctx: commands.Context) -> None: + """Sends a Random fun fact about Python.""" + embed = discord.Embed(title='Python Facts', + description=next(FACTS), + colour=next(COLORS)) + embed.add_field(name='Suggestions', + value="Suggest more facts [here!](https://github.com/python-discord/meta/discussions/93)") + await ctx.send(embed=embed) + + +def setup(bot: commands.Bot) -> None: + """Load PythonFacts Cog.""" + bot.add_cog(PythonFacts(bot)) |