diff --git a/script/requirements.in b/script/requirements.in index 7a555ef..82f1673 100644 --- a/script/requirements.in +++ b/script/requirements.in @@ -6,7 +6,6 @@ flake8-comprehensions flake8-debugger flake8-isort flake8-mutable -flake8-todo flake8-tuple # Type checking diff --git a/src/sr/discord_bot/commands/join.py b/src/sr/discord_bot/commands/join.py index cac1483..77d97f1 100644 --- a/src/sr/discord_bot/commands/join.py +++ b/src/sr/discord_bot/commands/join.py @@ -30,10 +30,12 @@ async def join(interaction: discord.Interaction["BotClient"], password: str) -> guild: discord.Guild | None = interaction.guild channel: discord.interactions.InteractionChannel | None = interaction.channel - if (guild is None + if ( + guild is None or not isinstance(channel, discord.TextChannel) or channel is None - or not channel.name.startswith(CHANNEL_PREFIX)): + or not channel.name.startswith(CHANNEL_PREFIX) + ): return chosen_team = find_team(interaction.client, member, password) diff --git a/src/sr/discord_bot/commands/logs.py b/src/sr/discord_bot/commands/logs.py index d977420..bf41818 100644 --- a/src/sr/discord_bot/commands/logs.py +++ b/src/sr/discord_bot/commands/logs.py @@ -193,8 +193,7 @@ async def send_file( def extract_animations(zipfile: ZipFile, tmpdir: Path, fully_extract: bool) -> bool: animation_files = [ name for name in zipfile.namelist() - if name.split('/')[-1].startswith('animations') - and name.endswith('.zip') + if name.split('/')[-1].startswith('animations') and name.endswith('.zip') ] if not animation_files: @@ -303,10 +302,9 @@ async def logs_upload( logging_str="Uploaded animations", ) - await ctx.followup.send(content= - f"Successfully uploaded logs to {len(completed_tlas)} teams: " - f"{', '.join(completed_tlas)}", - ) + await ctx.followup.send( + content=f"Successfully uploaded logs to {len(completed_tlas)} teams: {', '.join(completed_tlas)}", + ) except BadZipFile: await log_and_reply(ctx, f"# {zip_name} is not a valid ZIP file") diff --git a/src/sr/discord_bot/commands/passwd.py b/src/sr/discord_bot/commands/passwd.py index bcc8392..564a2c4 100644 --- a/src/sr/discord_bot/commands/passwd.py +++ b/src/sr/discord_bot/commands/passwd.py @@ -6,6 +6,7 @@ if TYPE_CHECKING: from sr.discord_bot.bot import BotClient + @app_commands.command( # type:ignore[arg-type] name='passwd', description='Outputs or changes team passwords', @@ -29,7 +30,7 @@ async def passwd( if isinstance(interaction.user, discord.Member) and not interaction.user.guild_permissions.administrator: await interaction.response.send_message( "You do not have permission to change team passwords.", - ephemeral=True + ephemeral=True, ) return interaction.client.set_password(tla, new_password) diff --git a/src/sr/discord_bot/commands/team.py b/src/sr/discord_bot/commands/team.py index 34d8d1e..7ebd1cd 100644 --- a/src/sr/discord_bot/commands/team.py +++ b/src/sr/discord_bot/commands/team.py @@ -30,14 +30,15 @@ def __init__(self) -> None: def permissions(client: "BotClient", team: discord.Role) -> Mapping[ - discord.Role | discord.Member, discord.PermissionOverwrite]: + discord.Role | discord.Member, discord.PermissionOverwrite, +]: if not isinstance(client.guild, discord.Guild): return {} return { client.guild.default_role: discord.PermissionOverwrite( read_messages=False, - send_messages=False + send_messages=False, ), client.volunteer_role: discord.PermissionOverwrite( read_messages=True, @@ -46,7 +47,7 @@ def permissions(client: "BotClient", team: discord.Role) -> Mapping[ team: discord.PermissionOverwrite( read_messages=True, send_messages=True, - ) + ), } @@ -81,7 +82,7 @@ async def new_team(interaction: discord.interactions.Interaction["BotClient"], t name=f"{TEAM_CHANNEL_PREFIX}{tla.lower()}", topic=name, category=category, - overwrites=permissions(interaction.client, role) + overwrites=permissions(interaction.client, role), ) interaction.client.set_password(tla, password) await interaction.response.send_message(f"{role.mention} and {channel.mention} created!", ephemeral=True) @@ -124,7 +125,10 @@ async def delete_team(interaction: discord.interactions.Interaction["BotClient"] await role.delete(reason=reason) interaction.client.remove_password(tla) - if isinstance(interaction.channel, discord.abc.GuildChannel) and not interaction.channel.name.startswith(f"{TEAM_CHANNEL_PREFIX}{tla.lower()}"): + if ( + isinstance(interaction.channel, discord.abc.GuildChannel) + and not interaction.channel.name.startswith(f"{TEAM_CHANNEL_PREFIX}{tla.lower()}") + ): await interaction.edit_original_response(content=f"Team {tla.upper()} has been deleted") else: await interaction.delete_original_response() @@ -151,7 +155,7 @@ async def create_voice(interaction: discord.interactions.Interaction["BotClient" channel = await guild.create_voice_channel( f"{TEAM_CHANNEL_PREFIX}{tla.lower()}", category=category, - overwrites=permissions(interaction.client, role) + overwrites=permissions(interaction.client, role), ) await interaction.response.send_message(f"{channel.mention} created!", ephemeral=True) @@ -190,7 +194,7 @@ async def create_team_channel( category=category, overwrites=permissions(interaction.client, role), position=main_channel.position + 1, - reason=TEAM_CREATED_REASON + reason=TEAM_CREATED_REASON, ) await interaction.response.send_message(f"{new_channel.mention} created!", ephemeral=True) @@ -246,7 +250,7 @@ async def export_team( if tla is None: for team_role in guild.roles: if team_role.name.startswith(ROLE_PREFIX) and team_role.name != TEAM_LEADER_ROLE: - output = output + await _export_team(team_role.name.removeprefix(ROLE_PREFIX), only_teams, guild, interaction) + output += await _export_team(team_role.name.removeprefix(ROLE_PREFIX), only_teams, guild, interaction) else: output = output + await _export_team(tla, only_teams, guild, interaction) output = output + "\n```" diff --git a/src/sr/discord_bot/commands/ui.py b/src/sr/discord_bot/commands/ui.py index 7a94d24..0aea9e8 100644 --- a/src/sr/discord_bot/commands/ui.py +++ b/src/sr/discord_bot/commands/ui.py @@ -14,11 +14,15 @@ def __init__(self, guild: discord.Guild, tla: str): self.value: bool = False @discord.ui.button(label='Delete', style=discord.ButtonStyle.red) - async def confirm(self, interaction: discord.interactions.Interaction["BotClient"], item: discord.ui.Item[discord.ui.View]) -> None: + async def confirm( + self, interaction: discord.interactions.Interaction["BotClient"], item: discord.ui.Item[discord.ui.View], + ) -> None: self.value = True self.stop() @discord.ui.button(label='Cancel', style=discord.ButtonStyle.grey) - async def cancel(self, interaction: discord.interactions.Interaction["BotClient"], item: discord.ui.Item[discord.ui.View]) -> None: + async def cancel( + self, interaction: discord.interactions.Interaction["BotClient"], item: discord.ui.Item[discord.ui.View], + ) -> None: await interaction.response.defer(ephemeral=True) self.stop()