Editing custom commands

pull/118/head
stijndcl 2022-06-30 21:39:13 +02:00
parent bec893bd20
commit bd63f80a7d
1 changed files with 5 additions and 2 deletions

View File

@ -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)