diff options
author | 2019-04-26 09:52:53 +0530 | |
---|---|---|
committer | 2019-04-26 09:52:53 +0530 | |
commit | 9c0685abac0bcb97fd5361d802780d4964c282d2 (patch) | |
tree | a7e61dd6a702a8846826d109a0052d3ac73b2d4f | |
parent | using top level array in json file (diff) |
changes a few doc strings and renamed the background method
-rw-r--r-- | bot/seasons/easter/egg_facts.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/bot/seasons/easter/egg_facts.py b/bot/seasons/easter/egg_facts.py index c4cd8cf9..e5abd685 100644 --- a/bot/seasons/easter/egg_facts.py +++ b/bot/seasons/easter/egg_facts.py @@ -10,21 +10,28 @@ from bot.constants import Colours class EasterFacts(commands.Cog): - """A cog for easter egg facts.""" + """ + A cog contains a command that will return an easter egg fact when called. + + It also contains a background task which sends an easter egg fact in the event channel everyday. + """ + def __init__(self, bot): self.bot = bot self.facts = self.load_json() @staticmethod def load_json(): - """Loading the json data""" + """Load a list of easter egg facts from the resource JSON file.""" + p = Path('bot', 'resources', 'easter', 'easter_egg_facts.json') with p.open(encoding="utf8") as f: facts = load(f) return facts - async def background(self): - """A background task that sends a easter egg fact.""" + async def send_egg_fact_daily(self): + """A background task that sends an easter egg fact in the event channel everyday.""" + channel = self.bot.get_channel(426566445124812815) while True: embed = self.make_embed() @@ -34,11 +41,13 @@ class EasterFacts(commands.Cog): @commands.command(name='eggfact', aliases=['fact']) async def easter_facts(self, ctx): """Get easter egg facts.""" + embed = self.make_embed() await ctx.send(embed=embed) def make_embed(self): """Makes a nice embed for the message to be sent.""" + embed = discord.Embed() embed.colour = Colours.soft_red embed.title = 'Easter Egg Fact' @@ -48,6 +57,7 @@ class EasterFacts(commands.Cog): def setup(bot): - """Loading the cog""" - bot.loop.create_task(EasterFacts(bot).background()) + """EasterEgg facts loaded.""" + + bot.loop.create_task(EasterFacts(bot).send_egg_fact_daily()) bot.add_cog(EasterFacts(bot)) |