diff options
| author | 2021-02-22 11:13:01 -0800 | |
|---|---|---|
| committer | 2021-02-22 11:13:01 -0800 | |
| commit | 16476ab7b4d5efe36a9e101b382f7be24888dec5 (patch) | |
| tree | 6621f2d1c66d5606ba4d800e6fad3c596d0e58cf /bot | |
| parent | Add colors and move embed out of send statement; add more info about Monty Py... (diff) | |
Switch to itertools.cycle and add colors to constants.py
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/constants.py | 2 | ||||
| -rw-r--r-- | bot/exts/evergreen/pythonfacts.py | 9 | 
2 files changed, 8 insertions, 3 deletions
| diff --git a/bot/constants.py b/bot/constants.py index bb538487..3aec6ba3 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -156,6 +156,8 @@ class Colours:      soft_orange = 0xf9cb54      soft_red = 0xcd6d6d      yellow = 0xf9f586 +    python_blue = 0x4B8BBE +    python_yellow = 0xFFD43B  class Emojis: diff --git a/bot/exts/evergreen/pythonfacts.py b/bot/exts/evergreen/pythonfacts.py index 734782b8..8e6d300b 100644 --- a/bot/exts/evergreen/pythonfacts.py +++ b/bot/exts/evergreen/pythonfacts.py @@ -1,13 +1,16 @@ -import random +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 = list(file) +    FACT_CYCLE = itertools.cycle(FACTS) -COLORS = [0x4B8BBE, 0xFFD43B, ] +COLORS = [Colours.python_blue, Colours.python_yellow] +COLOR_CYCLE = itertools.cycle(COLORS)  class PythonFacts(commands.Cog): @@ -19,7 +22,7 @@ class PythonFacts(commands.Cog):      @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=random.choice(FACTS), colour=random.choice(COLORS)) +        embed = discord.Embed(title='Python Facts', description=next(FACT_CYCLE), colour=next(COLOR_CYCLE))          await ctx.send(embed=embed) | 
