aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/events
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts/events')
-rw-r--r--bot/exts/events/advent_of_code/__init__.py4
-rw-r--r--bot/exts/events/advent_of_code/_cog.py6
-rw-r--r--bot/exts/events/advent_of_code/_helpers.py10
-rw-r--r--bot/exts/events/advent_of_code/views/dayandstarview.py6
-rw-r--r--bot/exts/events/hacktoberfest/hacktober-issue-finder.py9
-rw-r--r--bot/exts/events/hacktoberfest/hacktoberstats.py4
-rw-r--r--bot/exts/events/hacktoberfest/timeleft.py4
-rw-r--r--bot/exts/events/trivianight/_questions.py2
-rw-r--r--bot/exts/events/trivianight/_scoreboard.py8
-rw-r--r--bot/exts/events/trivianight/trivianight.py4
10 files changed, 23 insertions, 34 deletions
diff --git a/bot/exts/events/advent_of_code/__init__.py b/bot/exts/events/advent_of_code/__init__.py
index 3c521168..33c3971a 100644
--- a/bot/exts/events/advent_of_code/__init__.py
+++ b/bot/exts/events/advent_of_code/__init__.py
@@ -1,10 +1,10 @@
from bot.bot import Bot
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Set up the Advent of Code extension."""
# Import the Cog at runtime to prevent side effects like defining
# RedisCache instances too early.
from ._cog import AdventOfCode
- bot.add_cog(AdventOfCode(bot))
+ await bot.add_cog(AdventOfCode(bot))
diff --git a/bot/exts/events/advent_of_code/_cog.py b/bot/exts/events/advent_of_code/_cog.py
index 518841d4..49140a3f 100644
--- a/bot/exts/events/advent_of_code/_cog.py
+++ b/bot/exts/events/advent_of_code/_cog.py
@@ -18,7 +18,6 @@ from bot.exts.events.advent_of_code.views.dayandstarview import AoCDropdownView
from bot.utils import members
from bot.utils.decorators import InChannelCheckFailure, in_month, whitelist_override, with_role
from bot.utils.exceptions import MovedCommandError
-from bot.utils.extensions import invoke_help_command
log = logging.getLogger(__name__)
@@ -71,7 +70,6 @@ class AdventOfCode(commands.Cog):
Runs on a schedule, as defined in the task.loop decorator.
"""
- await self.bot.wait_until_guild_available()
guild = self.bot.get_guild(Client.guild)
completionist_role = guild.get_role(Roles.aoc_completionist)
if completionist_role is None:
@@ -87,7 +85,7 @@ class AdventOfCode(commands.Cog):
try:
leaderboard = await _helpers.fetch_leaderboard()
except _helpers.FetchingLeaderboardFailedError:
- await self.bot.send_log("Unable to fetch AoC leaderboard during role sync.")
+ await self.bot.log_to_dev_log("Unable to fetch AoC leaderboard during role sync.")
return
placement_leaderboard = json.loads(leaderboard["placement_leaderboard"])
@@ -122,7 +120,7 @@ class AdventOfCode(commands.Cog):
async def adventofcode_group(self, ctx: commands.Context) -> None:
"""All of the Advent of Code commands."""
if not ctx.invoked_subcommand:
- await invoke_help_command(ctx)
+ await self.bot.invoke_help_command(ctx)
@with_role(Roles.admins)
@adventofcode_group.command(
diff --git a/bot/exts/events/advent_of_code/_helpers.py b/bot/exts/events/advent_of_code/_helpers.py
index 6c004901..abd80b77 100644
--- a/bot/exts/events/advent_of_code/_helpers.py
+++ b/bot/exts/events/advent_of_code/_helpers.py
@@ -523,13 +523,6 @@ async def countdown_status(bot: Bot) -> None:
# Log that we're going to start with the countdown status.
log.info("The Advent of Code has started or will start soon, starting countdown status.")
- # Trying to change status too early in the bot's startup sequence will fail
- # the task because the websocket instance has not yet been created. Waiting
- # for this event means that both the websocket instance has been initialized
- # and that the connection to Discord is mature enough to change the presence
- # of the bot.
- await bot.wait_until_guild_available()
-
# Calculate when the task needs to stop running. To prevent the task from
# sleeping for the entire year, it will only wait in the currently
# configured year. This means that the task will only start hibernating once
@@ -578,9 +571,6 @@ async def new_puzzle_notification(bot: Bot) -> None:
log.info("The Advent of Code has started or will start soon, waking up notification task.")
- # Ensure that the guild cache is loaded so we can get the Advent of Code
- # channel and role.
- await bot.wait_until_guild_available()
aoc_channel = bot.get_channel(Channels.advent_of_code)
aoc_role = aoc_channel.guild.get_role(AdventOfCode.role_id)
diff --git a/bot/exts/events/advent_of_code/views/dayandstarview.py b/bot/exts/events/advent_of_code/views/dayandstarview.py
index 5529c12b..f0ebc803 100644
--- a/bot/exts/events/advent_of_code/views/dayandstarview.py
+++ b/bot/exts/events/advent_of_code/views/dayandstarview.py
@@ -55,7 +55,7 @@ class AoCDropdownView(discord.ui.View):
options=[discord.SelectOption(label=str(i)) for i in range(1, 26)],
custom_id="day_select"
)
- async def day_select(self, select: discord.ui.Select, interaction: discord.Interaction) -> None:
+ async def day_select(self, _: discord.Interaction, select: discord.ui.Select) -> None:
"""Dropdown to choose a Day of the AoC."""
self.day = select.values[0]
@@ -64,12 +64,12 @@ class AoCDropdownView(discord.ui.View):
options=[discord.SelectOption(label=str(i)) for i in range(1, 3)],
custom_id="star_select"
)
- async def star_select(self, select: discord.ui.Select, interaction: discord.Interaction) -> None:
+ async def star_select(self, _: discord.Interaction, select: discord.ui.Select) -> None:
"""Dropdown to choose either the first or the second star."""
self.star = select.values[0]
@discord.ui.button(label="Fetch", style=discord.ButtonStyle.blurple)
- async def fetch(self, button: discord.ui.Button, interaction: discord.Interaction) -> None:
+ async def fetch(self, interaction: discord.Interaction, _: discord.ui.Button) -> None:
"""Button that fetches the statistics based on the dropdown values."""
if self.day == 0 or self.star == 0:
await interaction.response.send_message(
diff --git a/bot/exts/events/hacktoberfest/hacktober-issue-finder.py b/bot/exts/events/hacktoberfest/hacktober-issue-finder.py
index 1774564b..aeffc8d7 100644
--- a/bot/exts/events/hacktoberfest/hacktober-issue-finder.py
+++ b/bot/exts/events/hacktoberfest/hacktober-issue-finder.py
@@ -100,8 +100,9 @@ class HacktoberIssues(commands.Cog):
"""Format the issue data into a embed."""
title = issue["title"]
issue_url = issue["url"].replace("api.", "").replace("/repos/", "/")
- # issues can have empty bodies, which in that case GitHub doesn't include the key in the API response
- body = issue.get("body", "")
+ # Issues can have empty bodies, resulting in the value being a literal `null` (parsed as `None`).
+ # For this reason, we can't use the default arg of `dict.get`, and so instead use `or` logic.
+ body = issue.get("body") or ""
labels = [label["name"] for label in issue["labels"]]
embed = discord.Embed(title=title)
@@ -113,6 +114,6 @@ class HacktoberIssues(commands.Cog):
return embed
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Load the HacktoberIssue finder."""
- bot.add_cog(HacktoberIssues(bot))
+ await bot.add_cog(HacktoberIssues(bot))
diff --git a/bot/exts/events/hacktoberfest/hacktoberstats.py b/bot/exts/events/hacktoberfest/hacktoberstats.py
index 72067dbe..c29e24b0 100644
--- a/bot/exts/events/hacktoberfest/hacktoberstats.py
+++ b/bot/exts/events/hacktoberfest/hacktoberstats.py
@@ -432,6 +432,6 @@ class HacktoberStats(commands.Cog):
return author_id, author_mention
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Load the Hacktober Stats Cog."""
- bot.add_cog(HacktoberStats(bot))
+ await bot.add_cog(HacktoberStats(bot))
diff --git a/bot/exts/events/hacktoberfest/timeleft.py b/bot/exts/events/hacktoberfest/timeleft.py
index 55109599..f470e932 100644
--- a/bot/exts/events/hacktoberfest/timeleft.py
+++ b/bot/exts/events/hacktoberfest/timeleft.py
@@ -62,6 +62,6 @@ class TimeLeft(commands.Cog):
)
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Load the Time Left Cog."""
- bot.add_cog(TimeLeft())
+ await bot.add_cog(TimeLeft())
diff --git a/bot/exts/events/trivianight/_questions.py b/bot/exts/events/trivianight/_questions.py
index d6beced9..5f1046dc 100644
--- a/bot/exts/events/trivianight/_questions.py
+++ b/bot/exts/events/trivianight/_questions.py
@@ -127,7 +127,7 @@ class QuestionView(View):
if len(guesses) != 0:
answers_chosen = {
answer_choice: len(
- tuple(filter(lambda x: x[0] == answer_choice, guesses.values()))
+ tuple(filter(lambda x: x[0] == answer_choice, guesses.values())) # noqa: B023
)
for answer_choice in labels
}
diff --git a/bot/exts/events/trivianight/_scoreboard.py b/bot/exts/events/trivianight/_scoreboard.py
index a5a5fcac..bd61be3d 100644
--- a/bot/exts/events/trivianight/_scoreboard.py
+++ b/bot/exts/events/trivianight/_scoreboard.py
@@ -123,26 +123,26 @@ class ScoreboardView(View):
return rank_embed
@discord.ui.button(label="Scoreboard for Speed", style=ButtonStyle.green)
- async def speed_leaderboard(self, button: Button, interaction: Interaction) -> None:
+ async def speed_leaderboard(self, interaction: Interaction, _: Button) -> None:
"""
Send an ephemeral message with the speed leaderboard embed.
Parameters:
- - button: The discord.ui.Button instance representing the `Speed Leaderboard` button.
- interaction: The discord.Interaction instance containing information on the interaction between the user
and the button.
+ - button: The discord.ui.Button instance representing the `Speed Leaderboard` button.
"""
await interaction.response.send_message(embed=await self._create_speed_embed(), ephemeral=True)
@discord.ui.button(label="What's my rank?", style=ButtonStyle.blurple)
- async def rank_button(self, button: Button, interaction: Interaction) -> None:
+ async def rank_button(self, interaction: Interaction, _: Button) -> None:
"""
Send an ephemeral message with the user's rank for the overall points/average speed.
Parameters:
- - button: The discord.ui.Button instance representing the `What's my rank?` button.
- interaction: The discord.Interaction instance containing information on the interaction between the user
and the button.
+ - button: The discord.ui.Button instance representing the `What's my rank?` button.
"""
await interaction.response.send_message(embed=self._get_rank(interaction.user), ephemeral=True)
diff --git a/bot/exts/events/trivianight/trivianight.py b/bot/exts/events/trivianight/trivianight.py
index 18d8327a..10435551 100644
--- a/bot/exts/events/trivianight/trivianight.py
+++ b/bot/exts/events/trivianight/trivianight.py
@@ -323,6 +323,6 @@ class TriviaNightCog(commands.Cog):
))
-def setup(bot: Bot) -> None:
+async def setup(bot: Bot) -> None:
"""Load the TriviaNight cog."""
- bot.add_cog(TriviaNightCog(bot))
+ await bot.add_cog(TriviaNightCog(bot))