diff options
Diffstat (limited to 'bot/exts/events/trivianight/trivianight.py')
| -rw-r--r-- | bot/exts/events/trivianight/trivianight.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/bot/exts/events/trivianight/trivianight.py b/bot/exts/events/trivianight/trivianight.py index 29a9e3d1..66b2ae43 100644 --- a/bot/exts/events/trivianight/trivianight.py +++ b/bot/exts/events/trivianight/trivianight.py @@ -1,6 +1,13 @@ +from json import loads +from random import choice + +from discord import Embed from discord.ext import commands from bot.bot import Bot +from bot.constants import Colours, POSITIVE_REPLIES +from ._questions import Questions +from ._scoreboard import Scoreboard class TriviaNight(commands.Cog): @@ -8,6 +15,26 @@ class TriviaNight(commands.Cog): def __init__(self, bot: Bot): self.bot = bot + self.scoreboard = Scoreboard(self.bot) + self.questions = Questions(self.scoreboard) + + @commands.group() + async def trivianight(self, ctx: commands.Context) -> None: + """No-op subcommand group for organizing different commands.""" + return + + @trivianight.command() + async def load(self, ctx: commands.Context) -> None: + """Load the JSON file provided into the questions.""" + json_text = (await ctx.message.attachments[0].read()).decode("utf8") + serialized_json = loads(json_text) + self.questions.set_questions(serialized_json) + success_embed = Embed( + title=choice(POSITIVE_REPLIES), + description="The JSON was loaded successfully!", + color=Colours.soft_green + ) + await ctx.send(embed=success_embed) def setup(bot: Bot) -> None: |