diff --git a/commands/custom_commands/main.py b/commands/custom_commands/main.py index 925f122..ae30f3a 100644 --- a/commands/custom_commands/main.py +++ b/commands/custom_commands/main.py @@ -109,68 +109,9 @@ class CustomCommandsCommands(commands.Cog): # Show the creation modal modal = CustomCommandCreateModal() await interaction.response.send_modal(modal) - - # Wait for modal completion - await modal.wait() - - if not modal.is_submitted: - return - - try: - # Create the command - command = await custom_commands_service.create_command( - name=modal.result['name'], # type: ignore - content=modal.result['content'], # pyright: ignore[reportOptionalSubscript] - creator_discord_id=interaction.user.id, - creator_username=interaction.user.name, - creator_display_name=interaction.user.display_name, - tags=modal.result.get('tags') - ) - - # Success embed - embed = EmbedTemplate.success( - title="Custom Command Created!", - description=f"Your command `/cc {command.name}` has been created successfully." - ) - - embed.add_field( - name="How to use it", - value=f"Type `/cc {command.name}` to execute your command.", - inline=False - ) - - embed.add_field( - name="Management", - value="Use `/cc-mine` to view and manage all your commands.", - inline=False - ) - - # Try to get the original interaction for editing - try: - # Get the interaction that triggered the modal - original_response = await interaction.original_response() - await interaction.edit_original_response(embed=embed, view=None) - except (discord.NotFound, discord.HTTPException): - # If we can't edit the original, send a followup - await interaction.followup.send(embed=embed, ephemeral=True) - - except CustomCommandExistsError: - embed = EmbedTemplate.error( - title="Command Already Exists", - description=f"A command named `{modal.result['name']}` already exists.\nTry a different name." # pyright: ignore[reportOptionalSubscript] - ) - await interaction.followup.send(embed=embed, ephemeral=True) - - except Exception as e: - self.logger.error("Failed to create custom command", - command_name=modal.result.get('name'), # pyright: ignore[reportOptionalMemberAccess] - user_id=interaction.user.id, - error=e) - embed = EmbedTemplate.error( - title="Creation Failed", - description="An error occurred while creating your command. Please try again." - ) - await interaction.followup.send(embed=embed, ephemeral=True) + + # Modal's on_submit will show preview with confirmation buttons + # The CustomCommandCreateConfirmationView handles actual command creation @app_commands.command(name="cc-edit", description="Edit one of your custom commands") @app_commands.describe(name="Name of the command to edit")