From 6ec182be1a80e93d02b81004eb9dfa4cc9daf011 Mon Sep 17 00:00:00 2001 From: stijndcl Date: Thu, 30 Jun 2022 21:39:13 +0200 Subject: [PATCH] Editing custom commands --- didier/data/modals/custom_commands.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/didier/data/modals/custom_commands.py b/didier/data/modals/custom_commands.py index 3cd908f..74e71e6 100644 --- a/didier/data/modals/custom_commands.py +++ b/didier/data/modals/custom_commands.py @@ -1,4 +1,5 @@ import traceback +import typing import discord @@ -49,7 +50,6 @@ class EditCustomCommand(discord.ui.Modal, title="Edit Custom Command"): self.original_name = name self.client = client - # TODO find a way to access these items self.add_item(discord.ui.TextInput(label="Name", placeholder="Didier", default=name)) self.add_item( discord.ui.TextInput( @@ -58,8 +58,11 @@ class EditCustomCommand(discord.ui.Modal, title="Edit Custom Command"): ) async def on_submit(self, interaction: discord.Interaction): + name_field = typing.cast(discord.ui.TextInput, self.children[0]) + response_field = typing.cast(discord.ui.TextInput, self.children[1]) + async with self.client.db_session as session: - await edit_command(session, self.original_name, self.name.value, self.response.value) + await edit_command(session, self.original_name, name_field.value, response_field.value) await interaction.response.send_message(f"Successfully edited ``{self.original_name}``.", ephemeral=True)