diff options
author | 2021-09-05 19:46:37 +0100 | |
---|---|---|
committer | 2021-09-05 19:46:37 +0100 | |
commit | 8a410f3abd39a1b48c514d32651a50d4bdced492 (patch) | |
tree | 17fbb917adec0a1283d3d2456d8b09eee0334371 /bot/exts/utilities/pythonfacts.py | |
parent | Merge pull request #845 from python-discord/Pin-platform-in-Dockerfile (diff) | |
parent | Merge branch 'main' into lance-restructure (diff) |
Merge pull request #851 from python-discord/lance-restructure
Restructure Sir Lancebot
Diffstat (limited to 'bot/exts/utilities/pythonfacts.py')
-rw-r--r-- | bot/exts/utilities/pythonfacts.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/bot/exts/utilities/pythonfacts.py b/bot/exts/utilities/pythonfacts.py new file mode 100644 index 00000000..ef190185 --- /dev/null +++ b/bot/exts/utilities/pythonfacts.py @@ -0,0 +1,36 @@ +import itertools + +import discord +from discord.ext import commands + +from bot.bot import Bot +from bot.constants import Colours + +with open("bot/resources/utilities/python_facts.txt") as file: + FACTS = itertools.cycle(list(file)) + +COLORS = itertools.cycle([Colours.python_blue, Colours.python_yellow]) +PYFACTS_DISCUSSION = "https://github.com/python-discord/meta/discussions/93" + + +class PythonFacts(commands.Cog): + """Sends a random fun fact about Python.""" + + @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=f"Suggest more facts [here!]({PYFACTS_DISCUSSION})" + ) + await ctx.send(embed=embed) + + +def setup(bot: Bot) -> None: + """Load the PythonFacts Cog.""" + bot.add_cog(PythonFacts()) |