blob: ff4893a8ad5d20c5cf0828a9b0aa7f139906c2dc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import json
import random
from pathlib import Path
from discord import Embed
from discord.ext import commands
class SaveThePlanet(commands.Cog):
"""A cog that teaches users how they can help our planet."""
json_embeds = []
def __init__(self, bot: commands.Bot) -> None:
self.bot = bot
with open(Path("bot/resources/save_the_planet.json"), 'r', encoding='utf8') as f:
for key, embed in json.load(f).items():
self.json_embeds[key] = embed
@commands.command(aliases=('savetheearth', 'saveplanet', 'saveearth'))
async def savetheplanet(self, ctx: commands.Context) -> None:
"""Responds with a random tip on how to be ecofriendly and help our planet."""
await ctx.send(embed=Embed.from_dict(random.choice(self.json_embeds)))
def setup(bot: commands.Bot) -> None:
"""save_the_planet Cog load."""
bot.add_cog(SaveThePlanet(bot))
|