aboutsummaryrefslogtreecommitdiffstats
path: root/bot
diff options
context:
space:
mode:
authorGravatar Chris Gallardo <[email protected]>2020-10-05 08:55:45 -0700
committerGravatar Chris Gallardo <[email protected]>2020-10-05 08:55:45 -0700
commit46ece4e009788e930c17aaf3d0f67d130c7f0514 (patch)
treea9e2d1532ae063f166a3f3c2bfc6ea9c3ad180aa /bot
parentApply suggestions from code review (diff)
apply @Den4200's suggestions
Co-Authored-By: Dennis Pham <[email protected]>
Diffstat (limited to 'bot')
-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)