aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Gallardo <[email protected]>2020-10-02 07:30:59 -0700
committerGravatar Chris Gallardo <[email protected]>2020-10-02 07:30:59 -0700
commitcc6b211f3b65d43afc12da439b1d8755e90f2c18 (patch)
treeb3ffff0dbd70e5671900fb111844e85ab0ffe04a
parentMerge branch 'save_the_planet' of https://github.com/ChrisGallardo/seasonalbo... (diff)
run lint
-rw-r--r--bot/exts/easter/save_the_planet.py16
-rw-r--r--bot/resources/easter/save_the_planet.json2
2 files changed, 11 insertions, 7 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))
diff --git a/bot/resources/easter/save_the_planet.json b/bot/resources/easter/save_the_planet.json
index 83c4a966..c7064f71 100644
--- a/bot/resources/easter/save_the_planet.json
+++ b/bot/resources/easter/save_the_planet.json
@@ -14,4 +14,4 @@
"solution": "Make sure you only use paper when absolutely neccesary. Find ways to plant trees (participate in Hacktober!) to combat losing them."
}
]
-} \ No newline at end of file
+}