aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/pythonfacts.py
diff options
context:
space:
mode:
authorGravatar bradtimmis <[email protected]>2021-08-30 22:09:44 -0400
committerGravatar bradtimmis <[email protected]>2021-08-30 22:09:44 -0400
commit8bc54b2e2aeaeef30efd9f7f684cce48b7b64daf (patch)
tree91e844d1431a127815d33406139e5798341b533a /bot/exts/evergreen/pythonfacts.py
parentNumerous syntax and bug fixes (diff)
parentMerge pull request #831 from brad90four/patch-1 (diff)
Update branch with main
Diffstat (limited to 'bot/exts/evergreen/pythonfacts.py')
-rw-r--r--bot/exts/evergreen/pythonfacts.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/bot/exts/evergreen/pythonfacts.py b/bot/exts/evergreen/pythonfacts.py
new file mode 100644
index 00000000..80a8da5d
--- /dev/null
+++ b/bot/exts/evergreen/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/evergreen/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())