mirror of https://github.com/stijndcl/didier
Typing
parent
a614e9a9f1
commit
28cf094ea3
|
@ -12,8 +12,8 @@ __all__ = ["AddLink"]
|
|||
class AddLink(discord.ui.Modal, title="Add Link"):
|
||||
"""Modal to add a new link"""
|
||||
|
||||
name = discord.ui.TextInput(label="Name", style=discord.TextStyle.short, placeholder="Source")
|
||||
url = discord.ui.TextInput(
|
||||
name: discord.ui.TextInput = discord.ui.TextInput(label="Name", style=discord.TextStyle.short, placeholder="Source")
|
||||
url: discord.ui.TextInput = discord.ui.TextInput(
|
||||
label="URL", style=discord.TextStyle.short, placeholder="https://github.com/stijndcl/didier"
|
||||
)
|
||||
|
||||
|
@ -25,6 +25,12 @@ class AddLink(discord.ui.Modal, title="Add Link"):
|
|||
|
||||
@overrides
|
||||
async def on_submit(self, interaction: discord.Interaction):
|
||||
if self.name.value is None:
|
||||
return await interaction.response.send_message("Required field `Name` cannot be empty.", ephemeral=True)
|
||||
|
||||
if self.url.value is None:
|
||||
return await interaction.response.send_message("Required field `URL` cannot be empty.", ephemeral=True)
|
||||
|
||||
async with self.client.postgres_session as session:
|
||||
await add_link(session, self.name.value, self.url.value)
|
||||
await self.client.database_caches.links.invalidate(session)
|
||||
|
|
Loading…
Reference in New Issue