aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts
diff options
context:
space:
mode:
authorGravatar Shom770 <[email protected]>2021-10-19 21:43:53 -0400
committerGravatar Shom770 <[email protected]>2022-02-09 18:13:36 -0500
commita7d00f8de9a5cfa2b9c76f1a2b39ac861787e24e (patch)
treedf7cf2ca2f99c972c1254567ac3502e37f5f6f7c /bot/exts
parentfinished basic question interface (diff)
add trivianight structure in the main cog
Diffstat (limited to 'bot/exts')
-rw-r--r--bot/exts/events/trivianight/_questions.py (renamed from bot/exts/events/trivianight/questions.py)3
-rw-r--r--bot/exts/events/trivianight/_scoreboard.py (renamed from bot/exts/events/trivianight/scoreboard.py)4
-rw-r--r--bot/exts/events/trivianight/trivianight.py27
3 files changed, 31 insertions, 3 deletions
diff --git a/bot/exts/events/trivianight/questions.py b/bot/exts/events/trivianight/_questions.py
index 2c1dbc81..ef56ee81 100644
--- a/bot/exts/events/trivianight/questions.py
+++ b/bot/exts/events/trivianight/_questions.py
@@ -5,7 +5,7 @@ from discord import ButtonStyle, Embed, Interaction
from discord.ui import Button, View
from bot.constants import Colours, NEGATIVE_REPLIES
-from .scoreboard import Scoreboard
+from ._scoreboard import Scoreboard
class QuestionButton(Button):
@@ -87,6 +87,7 @@ class Questions:
def __init__(self, scoreboard: Scoreboard):
self.scoreboard = scoreboard
+ self.view = QuestionView()
self.questions = []
self._ptr = -1
diff --git a/bot/exts/events/trivianight/scoreboard.py b/bot/exts/events/trivianight/_scoreboard.py
index 27a45e30..96ff5ced 100644
--- a/bot/exts/events/trivianight/scoreboard.py
+++ b/bot/exts/events/trivianight/_scoreboard.py
@@ -53,8 +53,8 @@ class ScoreboardView(View):
class Scoreboard:
"""Class for the scoreboard for the trivianight event."""
- def __init__(self):
- self.view = ScoreboardView()
+ def __init__(self, bot: Bot):
+ self.view = ScoreboardView(bot)
def __setitem__(self, key: str, value: int):
if key.startswith("points: "):
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: