Finish up smells in the commands directory.
Add a discord max message length constant. Move boolean argument to not be positional.
This commit is contained in:
+9
-16
@@ -1,6 +1,4 @@
|
||||
"""
|
||||
Commands for removing information in the database.
|
||||
"""
|
||||
"""Commands for removing information in the database."""
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
@@ -11,35 +9,29 @@ from database_setup.sql_data_classes import Presences, engine
|
||||
|
||||
|
||||
class RemoveCog(commands.Cog, name="Remove Commands"):
|
||||
"""
|
||||
Holds the view commands.
|
||||
"""
|
||||
"""Holds the view commands."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
Default constructor for RemoveCog class. Does nothing.
|
||||
"""
|
||||
"""Default constructor for RemoveCog class. Does nothing."""
|
||||
|
||||
@nextcord.slash_command(
|
||||
default_member_permissions=nextcord.Permissions(administrator=True),
|
||||
)
|
||||
async def remove(self, interaction: nextcord.Interaction):
|
||||
"""
|
||||
Parent slash command for set. Never called.
|
||||
"""
|
||||
async def remove(self, interaction: nextcord.Interaction) -> None:
|
||||
"""Parent slash command for set. Never called."""
|
||||
|
||||
@remove.subcommand(description="Remove a presence from the database.")
|
||||
async def presence(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
presence_str: str = nextcord.SlashOption(description="The presence to remove", required=True),
|
||||
):
|
||||
) -> None:
|
||||
"""
|
||||
Deletes the given presence id from the database.
|
||||
|
||||
Args:
|
||||
interaction (nextcord.Interaction): Interaction that invoked the command.
|
||||
presence (str): Is SlashOption. The presence to remove. Is the ID of the presence.
|
||||
presence_str (str): Is SlashOption. The presence to remove. Is the ID of the presence.
|
||||
"""
|
||||
presence_id = int(presence_str)
|
||||
with Session(engine) as session:
|
||||
@@ -50,9 +42,10 @@ class RemoveCog(commands.Cog, name="Remove Commands"):
|
||||
await interaction.response.send_message("Presence deleted.", ephemeral=True)
|
||||
|
||||
@presence.on_autocomplete("presence_str")
|
||||
async def presence_autocomplete(self, interaction: nextcord.Interaction, presence_str: str):
|
||||
async def presence_autocomplete(self, interaction: nextcord.Interaction, presence_str: str) -> None:
|
||||
"""
|
||||
Collects all presences that start with the presence string.
|
||||
|
||||
Sends autocomplete dict {Presence Name, Presence Id}
|
||||
|
||||
Args:
|
||||
|
||||
Reference in New Issue
Block a user