diff options
| author | 2020-10-02 07:30:59 -0700 | |
|---|---|---|
| committer | 2020-10-02 07:30:59 -0700 | |
| commit | cc6b211f3b65d43afc12da439b1d8755e90f2c18 (patch) | |
| tree | b3ffff0dbd70e5671900fb111844e85ab0ffe04a /bot/exts | |
| parent | Merge branch 'save_the_planet' of https://github.com/ChrisGallardo/seasonalbo... (diff) | |
run lint
Diffstat (limited to 'bot/exts')
| -rw-r--r-- | bot/exts/easter/save_the_planet.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/bot/exts/easter/save_the_planet.py b/bot/exts/easter/save_the_planet.py index 84bd44ab..d8bbef20 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 = [] + # cog class SaveThePlanet(commands.Cog): """A cog that teaches users how they can help our planet.""" @@ -14,6 +17,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',)) @@ -21,13 +25,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!"} @@ -47,4 +51,4 @@ def setup(bot: commands.Bot) -> None: ] embeds.append(Embed.from_dict(response)) - bot.add_cog(SaveThePlanet(bot))
\ No newline at end of file + bot.add_cog(SaveThePlanet(bot)) |