Skip to main content

Modals

I recommend subclassing here!

main.py
class MyModal(discord.ui.Modal):
def __init__(self):
super().__init__(title='Modal Title') # You MUST include a title!
self.add_item(discord.ui.InputText(label='Long input', style=discord.InputTextStyle.long))
self.add_item(discord.ui.InputText(label='Short input', style=discord.InputTextStyle.short))
async def callback(self, interaction):
embed = discord.Embed(color=discord.Colour.blurple())
for child in self.children:
embed.add_field(name=child.label, value=child.value) # this will add an embed field for every input given in the modal
await interaction.response.send_message(embed=embed, ephemeral=True)

@client.slash_command(name="modal")
async def modal(ctx):
MODAL = MyModal()
await ctx.interaction.response.send_modal(MODAL) # you *CAN NOT* send a modal in `ctx.respond`