Add a deletion confirmation.

This commit is contained in:
alwayscompiling
2022-12-08 22:59:00 -05:00
parent 8952c4a352
commit 411f8ab275
2 changed files with 137 additions and 1 deletions
+40 -1
View File
@@ -19,6 +19,8 @@ from utilities.utils import (
send_highscore_message,
)
from .views.delete_confirm import DeleteConfirmView, create_delete_id
class DeleteCog(commands.Cog, name="Table Management"):
"""
@@ -39,7 +41,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
@delete.subcommand()
async def all(self, interaction: nextcord.Interaction):
"""
Subcommand parent for deleting everything in a group. 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.")
@@ -124,6 +126,40 @@ class DeleteCog(commands.Cog, name="Table Management"):
await interaction.send(f'User "{user_name}" was removed from all tables.', ephemeral=True)
@delete.subcommand(description="Delete a category from a group. Deletion is perminant.")
async def category(
self,
interaction: nextcord.Interaction,
group_id: str = nextcord.SlashOption(name="group", description="Group to delete from.", required=True),
category_id: str = nextcord.SlashOption(name="category", description="Category to delete.", required=True),
) -> None:
"""
Calls the delete confirmation view for the given group and category.
Args:
interaction (nextcord.Interaction): Interaction of command.
group_id (str): Group to delete from. Is SlashOption.
category_id (str): Category to delete. Is SlashOption.
"""
await interaction.response.send_modal(
DeleteConfirmView(custom_id=create_delete_id(int(group_id), int(category_id)))
)
@delete.subcommand(description="Delete a group. Deletion is perminant.")
async def group(
self,
interaction: nextcord.Interaction,
group_id: str = nextcord.SlashOption(name="group", description="Group to delete.", required=True),
) -> None:
"""
Calls the delete confirmation view for the given group.
Args:
interaction (nextcord.Interaction): Interaction of command.
group_id (str): Group to delete from. Is SlashOption.
"""
await interaction.response.send_modal(DeleteConfirmView(custom_id=create_delete_id(int(group_id))))
@delete.subcommand()
async def user(self, interaction: nextcord.Interaction):
"""
@@ -201,6 +237,8 @@ class DeleteCog(commands.Cog, name="Table Management"):
@from_category.on_autocomplete("group_id")
@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):
"""
Autocomplete function for table names.
@@ -212,6 +250,7 @@ class DeleteCog(commands.Cog, name="Table Management"):
await interaction.response.send_autocomplete(autofill_groups(interaction.guild_id, group_id))
@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):
"""
Autocomplete function for category names.