diff options
| author | 2020-11-30 15:18:01 +0100 | |
|---|---|---|
| committer | 2020-11-30 15:18:01 +0100 | |
| commit | 556f0c5349cd5b4875953154242b863fdee510a2 (patch) | |
| tree | a2a13567372ba380bda28ea53435d9a579a1d43b /bot/exts/easter/save_the_planet.py | |
| parent | Make prideavatar support specifying the image by URL (diff) | |
| parent | Merge pull request #532 from python-discord/sebastiaan/ci/add-core-dev-approv... (diff) | |
Merge branch 'master' into prideavatar-url
Diffstat (limited to 'bot/exts/easter/save_the_planet.py')
| -rw-r--r-- | bot/exts/easter/save_the_planet.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bot/exts/easter/save_the_planet.py b/bot/exts/easter/save_the_planet.py new file mode 100644 index 00000000..8f644259 --- /dev/null +++ b/bot/exts/easter/save_the_planet.py @@ -0,0 +1,29 @@ +import json +from pathlib import Path + +from discord import Embed +from discord.ext import commands + +from bot.utils.randomization import RandomCycle + + +with Path("bot/resources/easter/save_the_planet.json").open('r', encoding='utf8') as f: + EMBED_DATA = RandomCycle(json.load(f)) + + +class SaveThePlanet(commands.Cog): + """A cog that teaches users how they can help our planet.""" + + def __init__(self, bot: commands.Bot) -> None: + self.bot = bot + + @commands.command(aliases=('savetheearth', 'saveplanet', 'saveearth')) + async def savetheplanet(self, ctx: commands.Context) -> None: + """Responds with a random tip on how to be eco-friendly and help our planet.""" + return_embed = Embed.from_dict(next(EMBED_DATA)) + await ctx.send(embed=return_embed) + + +def setup(bot: commands.Bot) -> None: + """Save the Planet Cog load.""" + bot.add_cog(SaveThePlanet(bot)) |