From dd4b79873b8ea001dd3f343763fcab7821a107ca Mon Sep 17 00:00:00 2001 From: Chris Gallardo <40961096+ChrisGallardo@users.noreply.github.com> Date: Fri, 2 Oct 2020 07:41:50 -0700 Subject: Fix styling --- bot/exts/easter/save_the_planet.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bot/exts/easter/save_the_planet.py b/bot/exts/easter/save_the_planet.py index 4ea7a5fb..6019304d 100644 --- a/bot/exts/easter/save_the_planet.py +++ b/bot/exts/easter/save_the_planet.py @@ -1,11 +1,14 @@ -from discord.ext import commands +import json +import random from pathlib import Path + from discord import Embed -import random -import json +from discord.ext import commands + embeds = [] + class SaveThePlanet(commands.Cog): """A cog that teaches users how they can help our planet.""" @@ -13,6 +16,7 @@ class SaveThePlanet(commands.Cog): self.bot = bot def get_response(self) -> Embed: + """Return a random Embed from the list of embeds.""" return random.choice(embeds) @commands.command(aliases=('save_the_earth',)) @@ -20,13 +24,13 @@ class SaveThePlanet(commands.Cog): """Responds with a random tip on how to be ecofriendly and help our planet.""" await ctx.send(embed=self.get_response()) + def setup(bot: commands.Bot) -> None: """save_the_planet Cog load.""" - with open(Path("bot/resources/easter/save_the_planet.json"), 'r', encoding="utf8") as f: responses = json.load(f) - # convert what's in the json to discord embed objects https://discord.com/developers/docs/resources/channel#embed-object + # convert what's in the json to discord embed objects for response in responses["embeds"]: response["title"] = f"Save the Planet: {response['topic']}" response["footer"] = {"text": "The best thing you can do is sharing this information!"} -- cgit v1.2.3