Skip to content

Repository files navigation

discord-app-bot

A Discord bot for automating the handling of Google Forms pushed to a server. Its primary function is to handle forms that are used for applications where the applicant is either accepted or declined.

Form responses are sent directly to the bot by a small Google Apps Script that comes with this repo. See Google Form Setup.

The basic workflow looks like this:

  • Someone submits a form response.
  • The form's Apps Script sends the response to the bot.
  • The bot posts the application to your Applications channel, and a channel for the applicant is automatically created. This channel is where the applicant can see the status of their application.
  • Once the applicant joins the server, they are tied to their application.
  • The applicant is automatically given an Applicant role. Use this to limit what the applicant can do during while waiting for a response.
  • The applicant can either be accepted or declined.
  • In either case, the application is closed. On decline the applicant is removed from the server.

See the Commands section for more details.

Installation/Setup

Google Form Setup

The only requirement for your Google Form is that it has a short answer question with the name/title Discord Username. This is used to match applicants who join the server to their application.

It's recommended that you provide an invite link to your server at the end of the form. The applicant should join the server after submitting their application for this bot to work as intended. If the applicant joins early or is not matched to their application correct, you can use the /link command to fix this.

To send form responses to the bot, add the Apps Script that comes with this repo to your form:

  1. In your form, open the more menu (three dots) and select Apps Script.
  2. Paste the contents of apps-script/on-submit.js into the editor, replacing the default contents.
  3. Fill in the constants at the top of the script:
    • BOT_URL - The URL the bot is reachable at, ending with /apps. For example: https://bot.example.com/apps
    • GUILD_ID - Your Discord server's ID.
    • EMBED_TITLE - The title shown at the top of each application posted to Discord.
  4. Go to Project Settings -> Script Properties and add a property named APP_BOT_SECRET. This must match the APP_BOT_SECRET environment variable the bot is running with.
  5. Go to Triggers and add a trigger for the onSubmit function with event source From form and event type On form submit.

The script sends the form's questions and answers to the bot as-is. Long answers are automatically split across multiple messages, and unanswered questions are shown as no response.

Discord Server Setup

This bot requires that your Discord server is set up in a certain way. You can name the roles/channels whatever you want. See the Commands section for how to set your roles/channels.

The bot needs the following:

  • An Officer/Moderator role. Anyone with this role can manage applications through the bot.
  • An Applicant role. This is the role automatically given to the applicant when they join the server.
  • An Applications channel. This is the channel where the bot posts new applications.
  • An Applicants channel category. Applicant channels are created under this category.

It's intended that you add the Applicant role to the Applicants category's permissions and decline the View Channels permission. That way the applicant can only see their own channel (applicants are automatically given permission to view their own channel when they join). You can also decline the Send Messages permission if you don't want applicants to be able to send messages in their own channel.

Additionally, you need to upload two custom server emoji:

  • One named approved and one named declined. If an applicant is approved/declined, the emoji is added as a reaction to the application in the apps channel.

While completely optional, it's recommended that you create a separate channel specifically for sending bot commands, as this will serve as a log for processed applications.

Bot Installation

docker run -d \
  --name=discord-app-bot \
  -e BOT_TOKEN=<YOUR_BOT_TOKEN> \
  -e APPLICATION_ID=<YOUR_BOT_APPLICATION_ID> \
  -e APP_BOT_SECRET=<YOUR_SECRET> \
  -e DATABASE_URL=file:db/prod.db \
  -p 8080:8080 \
  -v ./data/:/app/db/ \
  --restart unless-stopped \
  ghcr.io/adamhl8/discord-app-bot:latest
  • APP_BOT_SECRET is the shared secret used to authenticate requests from your form's Apps Script. Generate one with:
    • openssl rand -hex 24
  • The bot listens for form submissions on port 8080 (configurable via the PORT environment variable). It needs to be reachable from the internet, e.g. behind a reverse proxy with HTTPS, so that Google's servers can reach it.
  • You need to enable the Server Members intent in your bot's settings.

Commands

Use the following commands to manage the bot and applicants.

/settings set <officer-role> <applicant-role> <apps-channel> <apps-category> <decline-message> <post-logs> - The bot won't do anything unless this has been run.

  • You can always set post-logs to false. This exists as special functionality because this bot was originally created to help with applications to a World of Warcraft guild.

/settings list - Prints current settings.

/accept <applicant-channel> - Accept an applicant.

/decline <applicant-channel> - Decline an applicant.

  • Optionally takes:
    • <decline-message> - Overwrite the default decline message.
    • <kick> - Whether or not the applicant is kicked from the server on decline confirmation.

/delete <applicant-channel> - Delete an application.

  • Optionally takes:
    • <reason> - Provide a reason for the deletion.

/link <server-member> <applicant-channel> - Link an applicant to an applicant channel.

About

A Discord bot for automating the handling of Google Forms pushed to a server.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages