aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts')
-rw-r--r--bot/exts/easter/save_the_planet.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/bot/exts/easter/save_the_planet.py b/bot/exts/easter/save_the_planet.py
index 811feb93..99f06bbc 100644
--- a/bot/exts/easter/save_the_planet.py
+++ b/bot/exts/easter/save_the_planet.py
@@ -1,25 +1,28 @@
import json
-import random
from pathlib import Path
from discord import Embed
from discord.ext import commands
+from bot.utils import RandomCycle
+
+EMBED_DATA = []
+
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
- self.embed_data = []
- with open(Path("bot/resources/easter/save_the_planet.json"), 'r', encoding='utf8') as f:
- self.embed_data = json.load(f)
+ with Path("bot/resources/easter/save_the_planet.json").open('r', encoding='utf8') as f:
+ global EMBED_DATA
+ EMBED_DATA = RandomCycle(json.load(f))
@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(random.choice(self.embed_data))
+ return_embed = Embed.from_dict(next(EMBED_DATA))
await ctx.send(embed=return_embed)