Staff application
In this guide you will learn how to make a form using discord modals.
Here's how it's going to look like:
1. Button sending
Let's send a button users will use to open up the form.
The button will be blurple
, have a label Apply
and an id staff-app
.
!!exec $button[Apply;blurple;staff-app]
2. Button handling
Once we have our button ready, let's make a command to handle it.
Trigger
It will have a button
type, and a trigger staff-app
(the ID we set in the previous step)
Code
The button is meant to send a modal upon clicking, so let's use $modal to deploy a form with three options:
- Position
- Reason
- Pronouns
$modal[
{title=Staff application}
{id=staff-app}
{input=
{name=Position}
{ph=What position would you like to apply for?}
{id=position}
{type=short}
{min=5}
{max=100}
}
{input=
{name=Reason}
{ph=Why do you apply?}
{id=reason}
{type=long}
{min=20}
}
{input=
{name=Pronouns}
{ph=What pronouns do you use?}
{id=pronouns}
{type=short}
{required=no}
}
]
3. Modal handling
As you may have noticed, after clicking the button modal appears, but submitting it doesn't do anything. We'll now create a command to catch all the submitted forms.
Trigger
In order to detect submitted forms, we need to set the type to Modal
, and trigger to staff-app
(Which is our modal ID)
Code
Once we catch a submitted form, we need to do a few things:
- Load user's answers
- Send a report to a different channel
- Confirm the submission with an interaction reply
// Save answers to different variables
$let[position;$modalAnswer[1]]
$let[reason;$modalAnswer[reason]]
$let[pronouns;$modalAnswer[pronouns]]
// Send message to #staff-applications
$channelSendMessage[$channelID[staff-applications];
{author:$usertag:$authorAvatar}
{title:Staff application}
{description:$mention has submitted the staff application}
{field:Position:$position}
{field:Reason:```$reason```}
// Attach pronouns section only if provided
$if[$get[pronouns]!=]
{footer:Pronouns\: $pronouns} // : has been escaped using a backslash
$endIf
]
// Send an ephemeral interaction reply
$interactionReply[Thank you for your submission;yes]
Related pages
Here's a list of functions used and pages mentioned in this tutorial. We recommend you to continue reading about anything that seems unclear to you:
Page or function | Description |
---|---|
$button | send a button |
Button trigger | detect button clicks |
$modal | deploy a modal |
Modal trigger | catch submitted modals |
$let | define a temporary variable |
$get | retrive a temporary variable |
$modalAnswer | get user's answer |
$channelSendMessage | send a message in a different channel |
$channelID | find a channel by it's name |
$if | conditional statement |
Complete embed | create an embed |
$interactionReply | send interaction reply |
🎉 Congratulations!
You've made a complete staff application system!