aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/utilities/pythonfacts.py
blob: a5bfb612ee16a9c1b9cc3ec4cb53e6fe35a2e6d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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)


async def setup(bot: Bot) -> None:
    """Load the PythonFacts Cog."""
    await bot.add_cog(PythonFacts())