aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/events
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2023-08-23 10:31:24 +0100
committerGravatar wookie184 <[email protected]>2023-08-23 10:31:24 +0100
commit6ebc2806b1b2737c27c090da324d85577ea67fb6 (patch)
tree1fb65b1dd1c8185bab4874dfc8fe5e272f20de3d /bot/exts/events
parentHandle snakes without images (diff)
parentCorrected attribute name to fetch github url in extensions.py (#1348) (diff)
Merge branch 'main' into snakes-cleanup
Diffstat (limited to 'bot/exts/events')
-rw-r--r--bot/exts/events/hacktoberfest/hacktoberstats.py4
-rw-r--r--bot/exts/events/trivianight/_game.py4
-rw-r--r--bot/exts/events/trivianight/_scoreboard.py6
-rw-r--r--bot/exts/events/trivianight/trivianight.py2
4 files changed, 8 insertions, 8 deletions
diff --git a/bot/exts/events/hacktoberfest/hacktoberstats.py b/bot/exts/events/hacktoberfest/hacktoberstats.py
index c7fd3601..04dc4aae 100644
--- a/bot/exts/events/hacktoberfest/hacktoberstats.py
+++ b/bot/exts/events/hacktoberfest/hacktoberstats.py
@@ -43,7 +43,7 @@ class HacktoberStats(commands.Cog):
@in_month(Month.SEPTEMBER, Month.OCTOBER, Month.NOVEMBER)
@commands.group(name="hacktoberstats", aliases=("hackstats",), invoke_without_command=True)
- async def hacktoberstats_group(self, ctx: commands.Context, github_username: str = None) -> None:
+ async def hacktoberstats_group(self, ctx: commands.Context, github_username: str | None = None) -> None:
"""
Display an embed for a user's Hacktoberfest contributions.
@@ -70,7 +70,7 @@ class HacktoberStats(commands.Cog):
@in_month(Month.SEPTEMBER, Month.OCTOBER, Month.NOVEMBER)
@hacktoberstats_group.command(name="link")
- async def link_user(self, ctx: commands.Context, github_username: str = None) -> None:
+ async def link_user(self, ctx: commands.Context, github_username: str | None = None) -> None:
"""
Link the invoking user's Github github_username to their Discord ID.
diff --git a/bot/exts/events/trivianight/_game.py b/bot/exts/events/trivianight/_game.py
index 15126f60..0568ce81 100644
--- a/bot/exts/events/trivianight/_game.py
+++ b/bot/exts/events/trivianight/_game.py
@@ -134,7 +134,7 @@ class TriviaNightGame:
def __iter__(self) -> Iterable[Question]:
return iter(self._questions)
- def next_question(self, number: str = None) -> Question:
+ def next_question(self, number: str | None = None) -> Question:
"""
Consume one random question from the trivia night game.
@@ -145,7 +145,7 @@ class TriviaNightGame:
if number is not None:
try:
- question = [q for q in self._all_questions if q.number == int(number)][0]
+ question = next(q for q in self._all_questions if q.number == int(number))
except IndexError:
raise ValueError(f"Question number {number} does not exist.")
elif len(self._questions) == 0:
diff --git a/bot/exts/events/trivianight/_scoreboard.py b/bot/exts/events/trivianight/_scoreboard.py
index bd61be3d..c2b39d67 100644
--- a/bot/exts/events/trivianight/_scoreboard.py
+++ b/bot/exts/events/trivianight/_scoreboard.py
@@ -155,18 +155,18 @@ class Scoreboard:
self._points = {}
self._speed = {}
- def assign_points(self, user_id: int, *, points: int = None, speed: float = None) -> None:
+ def assign_points(self, user_id: int, *, points: int | None = None, speed: float | None = None) -> None:
"""
Assign points or deduct points to/from a certain user.
This method should be called once the question has finished and all answers have been registered.
"""
- if points is not None and user_id not in self._points.keys():
+ if points is not None and user_id not in self._points:
self._points[user_id] = points
elif points is not None:
self._points[user_id] += points
- if speed is not None and user_id not in self._speed.keys():
+ if speed is not None and user_id not in self._speed:
self._speed[user_id] = [1, speed]
elif speed is not None:
self._speed[user_id] = [
diff --git a/bot/exts/events/trivianight/trivianight.py b/bot/exts/events/trivianight/trivianight.py
index e0db45d8..e47d1d83 100644
--- a/bot/exts/events/trivianight/trivianight.py
+++ b/bot/exts/events/trivianight/trivianight.py
@@ -107,7 +107,7 @@ class TriviaNightCog(commands.Cog):
@trivianight.command(aliases=("next",))
@commands.has_any_role(*TRIVIA_NIGHT_ROLES)
- async def question(self, ctx: commands.Context, question_number: str = None) -> None:
+ async def question(self, ctx: commands.Context, question_number: str | None = None) -> None:
"""
Gets a random question from the unanswered question list and lets the user(s) choose the answer.