Apply fixed for ruff smells.
This commit is contained in:
+22
-32
@@ -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
|
import nextcord
|
||||||
from nextcord.ext import commands
|
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 DeleteCog(commands.Cog, name="Table Management"):
|
||||||
"""
|
"""Class holds commands for deleting."""
|
||||||
Class holds commands for deleting.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""
|
"""Default constructor for DeleteCog class."""
|
||||||
Default constructor for DeleteCog class.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@nextcord.slash_command(default_member_permissions=nextcord.Permissions(administrator=True))
|
@nextcord.slash_command(default_member_permissions=nextcord.Permissions(administrator=True))
|
||||||
async def delete(self, interaction: nextcord.Interaction):
|
async def delete(self, interaction: nextcord.Interaction) -> None:
|
||||||
"""
|
"""Parent slash command for deleting things. Never called."""
|
||||||
Parent slash command for deleting things. Never called.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@delete.subcommand()
|
@delete.subcommand()
|
||||||
async def all(self, interaction: nextcord.Interaction):
|
async def all(self, interaction: nextcord.Interaction) -> None:
|
||||||
"""
|
"""Subcommand parent for deleting all of a thing. Never called."""
|
||||||
Subcommand parent for deleting all of a thing. Never called.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@all.subcommand(description="Clears highscores channel of all table messages. Does not change data.")
|
@all.subcommand(description="Clears highscores channel of all table messages. Does not change data.")
|
||||||
async def channel_messages(
|
async def channel_messages(
|
||||||
@@ -55,6 +45,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Deletes all group messages from channel. Does not change data.
|
Deletes all group messages from channel. Does not change data.
|
||||||
|
|
||||||
Does not delete highscores channel id. Uses current channel if not supplied a channel.
|
Does not delete highscores channel id. Uses current channel if not supplied a channel.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -95,10 +86,11 @@ class DeleteCog(commands.Cog, name="Table Management"):
|
|||||||
user_name: str = nextcord.SlashOption(
|
user_name: str = nextcord.SlashOption(
|
||||||
description="User to remove scores for. Note: This is not always a user's discord name.", required=True
|
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
|
Searches all of guild's scores data for any score from the user and removes.
|
||||||
message is user was removed from that table.
|
|
||||||
|
Updates table message is user was removed from that table.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
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))))
|
await interaction.response.send_modal(DeleteConfirmView(custom_id=create_delete_id(int(group_id))))
|
||||||
|
|
||||||
@delete.subcommand()
|
@delete.subcommand()
|
||||||
async def user(self, interaction: nextcord.Interaction):
|
async def user(self, interaction: nextcord.Interaction) -> None:
|
||||||
"""
|
"""Subcommand parent for deleting user information. Never called."""
|
||||||
Subcommand parent for deleting user information. Never called.
|
|
||||||
"""
|
|
||||||
|
|
||||||
@user.subcommand(description="Deletes a user's scores from a category.")
|
@user.subcommand(description="Deletes a user's scores from a category.")
|
||||||
async def from_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
|
name="category", description="Category to delete user from.", required=True
|
||||||
),
|
),
|
||||||
user_name: str = nextcord.SlashOption(description="User to delete.", 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.
|
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,
|
interaction: nextcord.Interaction,
|
||||||
group_id: str = nextcord.SlashOption(name="group", description="Group to delete user from.", required=True),
|
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),
|
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:
|
Args:
|
||||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
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")
|
@from_group.on_autocomplete("group_id")
|
||||||
@category.on_autocomplete("group_id")
|
@category.on_autocomplete("group_id")
|
||||||
@group.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.
|
Autocomplete function for table names.
|
||||||
|
|
||||||
@@ -245,7 +235,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
|
|||||||
|
|
||||||
@from_category.on_autocomplete("category_id")
|
@from_category.on_autocomplete("category_id")
|
||||||
@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.
|
Autocomplete function for category names.
|
||||||
|
|
||||||
@@ -262,7 +252,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
|
|||||||
@from_group.on_autocomplete("user_name")
|
@from_group.on_autocomplete("user_name")
|
||||||
async def user_autocomplete(
|
async def user_autocomplete(
|
||||||
self, interaction: nextcord.Interaction, user_name: str, group_id: str, category_id: str | None = None
|
self, interaction: nextcord.Interaction, user_name: str, group_id: str, category_id: str | None = None
|
||||||
):
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Autocomplete functions for user names.
|
Autocomplete functions for user names.
|
||||||
|
|
||||||
@@ -279,12 +269,12 @@ class DeleteCog(commands.Cog, name="Table Management"):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@users.on_autocomplete("user_name")
|
@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.
|
Sends response from autofill_users_in_guild back to update_username for autocompletion of old_username.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
interaction (nextcord.Interaction): Interaction with command.
|
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))
|
await interaction.response.send_autocomplete(autofill_users_in_guild(interaction.guild_id, username))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""View for verification buttons"""
|
"""View for verification buttons."""
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
|
|
||||||
@@ -7,18 +7,18 @@ from utilities.utils import submit_score
|
|||||||
|
|
||||||
|
|
||||||
class VerificationView(nextcord.ui.View):
|
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)
|
super().__init__(timeout=None)
|
||||||
|
|
||||||
@nextcord.ui.button(label="Deny", style=nextcord.ButtonStyle.red, custom_id="deny-button-submission")
|
@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."""
|
"""Button for denying score submission."""
|
||||||
await interaction.message.delete()
|
await interaction.message.delete()
|
||||||
|
|
||||||
@nextcord.ui.button(label="Approve", style=nextcord.ButtonStyle.green, custom_id="approve-button-submission")
|
@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."""
|
"""Button for approving score submission."""
|
||||||
for embed in interaction.message.embeds:
|
for embed in interaction.message.embeds:
|
||||||
content = embed.to_dict()
|
content = embed.to_dict()
|
||||||
|
|||||||
Reference in New Issue
Block a user