Md Shahriyar Alam
2 months ago
First create a command and give it any name and description you want
Then disable Auto Defer
so that the command does not get automatically deferred
First create the modal
pymodal = ModalBuilder(title="Test Modal", custom_id="test_modal")
modal.add_text_input(
name="name",
label="Country",
placeholder="What country do you live in?"
)
modal.add_text_input(
name="description",
label="Description",
placeholder="Write something about your country",
style="long",
)
I have added 2 input fields name
and description
and also gave the modal a custom_id test_modal
you can change the custom id and make your own fields
Then you have to send the modal
pyawait send_modal(modal)
After that you can handle the modal submission using an Event
or you can handle it inside the command's hooks
if you want to handle the modal using events
py#! test_modal
name = values["name"]
description = values["description"]
# Do what you want to do with these variables
defer_response(ephemeral=True)
respond_interaction(interaction, content="Thank you for submitting the modal")
By the upper code you can access the values and do whatever you want
if you want to handle using pre hook
pydef check(event):
return (
event.interaction.user.id == user.id and
event.interaction.custom_id == "test_modal" # use your own custom id here
)
event = await wait_for("modal_submit", check=check)
values = get_modal_values(event.interaction)
await defer(event.interaction, ephemeral=False)
respond_interaction(
event.interaction,
content=f"Name: {values['name']}\nDescription: {values['description']}"
)
If you still need any kind of help, have a suggestion for us or having a question in mind? Feel free to reach us out.
Join support server#1 Custom commands discord bot available on the internet
20-22 Wenlock RoadEnglandN1 7GU
© WEiRDSOFT LTD. All rights reserved.