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: Video preview

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]

Button preview

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)Button trigger

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)Modal trigger

Code

Once we catch a submitted form, we need to do a few things:

  1. Load user's answers
  2. Send a report to a different channel
  3. 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 functionDescription
$buttonsend a button
Button triggerdetect button clicks
$modaldeploy a modal
Modal triggercatch submitted modals
$letdefine a temporary variable
$getretrive a temporary variable
$modalAnswerget user's answer
$channelSendMessagesend a message elsewhere
$channelIDfind a channel by it's name
$ifconditional statement
Complete embedcreate an embed
$interactionReplysend interaction reply

🎉 Congratulations!

You've made a complete staff application system!