Address ruff smells in create.py.
This commit is contained in:
+16
-22
@@ -1,6 +1,4 @@
|
|||||||
"""
|
"""Commands for creating items in bot."""
|
||||||
Commands for creating items in bot.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import nextcord
|
import nextcord
|
||||||
from nextcord.ext import commands
|
from nextcord.ext import commands
|
||||||
@@ -14,35 +12,29 @@ from utilities.utils import MAX_LINE_LENGTH, autofill_groups, send_highscore_mes
|
|||||||
|
|
||||||
|
|
||||||
class CreateCog(commands.Cog, name="Create Cog"):
|
class CreateCog(commands.Cog, name="Create Cog"):
|
||||||
"""
|
"""Class holds commands for creating things."""
|
||||||
Class holds commands for creating things.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, bot: commands.Bot) -> None:
|
def __init__(self, bot: commands.Bot) -> None:
|
||||||
"""
|
"""Default constructor for CreateCog class."""
|
||||||
Default constructor for CreateCog class.
|
|
||||||
"""
|
|
||||||
self._bot = bot
|
self._bot = bot
|
||||||
|
|
||||||
@nextcord.slash_command(default_member_permissions=nextcord.Permissions(administrator=True))
|
@nextcord.slash_command(default_member_permissions=nextcord.Permissions(administrator=True))
|
||||||
async def create(self, interaction: nextcord.Interaction):
|
async def create(self, interaction: nextcord.Interaction) -> None:
|
||||||
"""
|
"""Parent slash command for creating things. Never called."""
|
||||||
Parent slash command for creating things. Never called.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# need all these arguments because discord command.
|
# need all these arguments because discord command.
|
||||||
# pylint: disable=too-many-arguments
|
# pylint: disable=too-many-arguments
|
||||||
@create.subcommand(description="Create a new Category. Must not exist already in Group.")
|
@create.subcommand(description="Create a new Category. Must not exist already in Group.")
|
||||||
async def category(
|
async def category( # noqa: PLR0913
|
||||||
self,
|
self,
|
||||||
interaction: nextcord.Interaction,
|
interaction: nextcord.Interaction,
|
||||||
group_id: str = nextcord.SlashOption(name="group", description="Group to add Category to.", required=True),
|
group_id: str = nextcord.SlashOption(name="group", description="Group to add Category to.", required=True),
|
||||||
category_name: str = nextcord.SlashOption(description="Name of new Category.", required=True),
|
category_name: str = nextcord.SlashOption(description="Name of new Category.", required=True),
|
||||||
is_ascending: bool = nextcord.SlashOption(description="If lower value is a better score.", required=True),
|
is_ascending: bool = nextcord.SlashOption(description="If lower value is a better score.", required=True), # noqa: FBT001
|
||||||
is_time_record: bool = nextcord.SlashOption(
|
is_time_record: bool = nextcord.SlashOption( # noqa: FBT001
|
||||||
description="If the score should be shown in time format. Cannot be changed.", required=True
|
description="If the score should be shown in time format. Cannot be changed.", required=True
|
||||||
),
|
),
|
||||||
is_validated: bool = nextcord.SlashOption(
|
is_validated: bool = nextcord.SlashOption( # noqa: FBT001
|
||||||
description="If scores need to be validated before posted.", required=True
|
description="If scores need to be validated before posted.", required=True
|
||||||
),
|
),
|
||||||
size: int = nextcord.SlashOption(
|
size: int = nextcord.SlashOption(
|
||||||
@@ -50,8 +42,9 @@ class CreateCog(commands.Cog, name="Create Cog"):
|
|||||||
),
|
),
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a new category to be placed into group_id group. Fails if the category name already exists within the
|
Creates a new category to be placed into group_id group.
|
||||||
group. Then calls send_highscore_message().
|
|
||||||
|
Fails if the category name already exists within the group. Then calls send_highscore_message().
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
interaction (nextcord.Interaction): Interaction for the command.
|
interaction (nextcord.Interaction): Interaction for the command.
|
||||||
@@ -118,8 +111,9 @@ class CreateCog(commands.Cog, name="Create Cog"):
|
|||||||
),
|
),
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Creates a new category group to be placed into the database with the guild's id. Fails if the category group
|
Creates a new category group to be placed into the database with the guild's id.
|
||||||
name already exists within the guild. Then calls send_highscore_message().
|
|
||||||
|
Fails if the category group name already exists within the guild. Then calls send_highscore_message().
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
interaction (nextcord.Interaction): Interaction for the command.
|
interaction (nextcord.Interaction): Interaction for the command.
|
||||||
@@ -156,7 +150,7 @@ class CreateCog(commands.Cog, name="Create Cog"):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@category.on_autocomplete("group_id")
|
@category.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:
|
||||||
"""
|
"""
|
||||||
Collects list of table names and compares to input table name for autocomplete assistance.
|
Collects list of table names and compares to input table name for autocomplete assistance.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user