Apply fixed for ruff smells.

This commit is contained in:
2025-02-17 16:39:10 -05:00
parent ba04858328
commit c62b87c7f7
2 changed files with 27 additions and 37 deletions
+22 -32
View File
@@ -1,6 +1,4 @@
"""
Commands for deleting groups/categories/scores in database and messages in discord..
"""
"""Commands for deleting groups/categories/scores in database and messages in discord."""
import nextcord
from nextcord.ext import commands
@@ -21,26 +19,18 @@ from .views.delete_confirm import DeleteConfirmView, create_delete_id
class DeleteCog(commands.Cog, name="Table Management"):
"""
Class holds commands for deleting.
"""
"""Class holds commands for deleting."""
def __init__(self) -> None:
"""
Default constructor for DeleteCog class.
"""
"""Default constructor for DeleteCog class."""
@nextcord.slash_command(default_member_permissions=nextcord.Permissions(administrator=True))
async def delete(self, interaction: nextcord.Interaction):
"""
Parent slash command for deleting things. Never called.
"""
async def delete(self, interaction: nextcord.Interaction) -> None:
"""Parent slash command for deleting things. Never called."""
@delete.subcommand()
async def all(self, interaction: nextcord.Interaction):
"""
Subcommand parent for deleting all of a thing. Never called.
"""
async def all(self, interaction: nextcord.Interaction) -> None:
"""Subcommand parent for deleting all of a thing. Never called."""
@all.subcommand(description="Clears highscores channel of all table messages. Does not change data.")
async def channel_messages(
@@ -55,6 +45,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
) -> None:
"""
Deletes all group messages from channel. Does not change data.
Does not delete highscores channel id. Uses current channel if not supplied a channel.
Args:
@@ -95,10 +86,11 @@ class DeleteCog(commands.Cog, name="Table Management"):
user_name: str = nextcord.SlashOption(
description="User to remove scores for. Note: This is not always a user's discord name.", required=True
),
):
) -> None:
"""
Searches all of guild's scores data for any score from the user. Removes. Updates table
message is user was removed from that table.
Searches all of guild's scores data for any score from the user and removes.
Updates table message is user was removed from that table.
Args:
interaction (nextcord.Interaction): Interaction that invoked the command.
@@ -157,10 +149,8 @@ class DeleteCog(commands.Cog, name="Table Management"):
await interaction.response.send_modal(DeleteConfirmView(custom_id=create_delete_id(int(group_id))))
@delete.subcommand()
async def user(self, interaction: nextcord.Interaction):
"""
Subcommand parent for deleting user information. Never called.
"""
async def user(self, interaction: nextcord.Interaction) -> None:
"""Subcommand parent for deleting user information. Never called."""
@user.subcommand(description="Deletes a user's scores from a category.")
async def from_category(
@@ -171,7 +161,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
name="category", description="Category to delete user from.", required=True
),
user_name: str = nextcord.SlashOption(description="User to delete.", required=True),
):
) -> None:
"""
Removes a user from a category. Uses autofill functions to fill out group_id, category_id, and user_name.
@@ -205,9 +195,9 @@ class DeleteCog(commands.Cog, name="Table Management"):
interaction: nextcord.Interaction,
group_id: str = nextcord.SlashOption(name="group", description="Group to delete user from.", required=True),
user_name: str = nextcord.SlashOption(description="User to delete.", required=True),
):
) -> None:
"""
Removes user from a goup. Uses autofill functions to fill out group_id and user_name.
Removes user from a group. Uses autofill functions to fill out group_id and user_name.
Args:
interaction (nextcord.Interaction): Interaction that invoked the command.
@@ -233,7 +223,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
@from_group.on_autocomplete("group_id")
@category.on_autocomplete("group_id")
@group.on_autocomplete("group_id")
async def group_autocomplete(self, interaction: nextcord.Interaction, group_id: str):
async def group_autocomplete(self, interaction: nextcord.Interaction, group_id: str) -> None:
"""
Autocomplete function for table names.
@@ -245,7 +235,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
@from_category.on_autocomplete("category_id")
@category.on_autocomplete("category_id")
async def category_autocomplete(self, interaction: nextcord.Interaction, category_id: str, group_id: str):
async def category_autocomplete(self, interaction: nextcord.Interaction, category_id: str, group_id: str) -> None:
"""
Autocomplete function for category names.
@@ -262,7 +252,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
@from_group.on_autocomplete("user_name")
async def user_autocomplete(
self, interaction: nextcord.Interaction, user_name: str, group_id: str, category_id: str | None = None
):
) -> None:
"""
Autocomplete functions for user names.
@@ -279,12 +269,12 @@ class DeleteCog(commands.Cog, name="Table Management"):
)
@users.on_autocomplete("user_name")
async def all_users_autocomplete(self, interaction: nextcord.Interaction, username: str):
async def all_users_autocomplete(self, interaction: nextcord.Interaction, username: str) -> None:
"""
Sends response from autofill_users_in_guild back to update_username for autocompletion of old_username.
Args:
interaction (nextcord.Interaction): Interaction with command.
old_username (str): String to run autocompletion against.
username (str): String to run autocompletion against.
"""
await interaction.response.send_autocomplete(autofill_users_in_guild(interaction.guild_id, username))
+5 -5
View File
@@ -1,4 +1,4 @@
"""View for verification buttons"""
"""View for verification buttons."""
import nextcord
@@ -7,18 +7,18 @@ from utilities.utils import submit_score
class VerificationView(nextcord.ui.View):
"""Defines views for verifying score submissions"""
"""Defines views for verifying score submissions."""
def __init__(self):
def __init__(self) -> None:
super().__init__(timeout=None)
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny-button-submission")
async def deny_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction): # pylint: disable=unused-argument
async def deny_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
"""Button for denying score submission."""
await interaction.message.delete()
@nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green, custom_id="approve-button-submission")
async def approve_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction): # pylint: disable=unused-argument
async def approve_button(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
"""Button for approving score submission."""
for embed in interaction.message.embeds:
content = embed.to_dict()