// based off FlyByWire Simulations Discord Bot - https://github.com/flybywiresim/discord-bot
Please reference the information below when contributing to this repository.
- Write your commands professionally and clearly.
- Proofread your work before submitting as ready for review.
- Choose user-friendly command names.
- Test your build locally before submitting as ready for review.
To ensure that commands are written professionally and clearly, please follow the guide below.
- Use the proper name for third party services. For example, simBrief and not SimBrief.
- Refrain from using exclamation points unless it is a warning.
- Ensure that the contents of the command are correct. If you are unsure if something is correct please speak to any bot developer, and they will be able to verify anything.
- Ensure that grammar and spelling is correct.
Reminder: The main branch is 'staging'
- Fork the repo
- Clone to your local system using your IDE of choice
- Make a new branch from staging and name appropriately (e.g. feat: added IRS command, fix: typos fixed in IRS)
- Create/edit the command you are working on
- Test your build locally (Instructions below)
- Create a PR to merge your changes into staging
Note: It may be beneficial to create a draft PR while working on your command. This will allow us to see who is working on what, and will enable the community to give active feedback on your work.
You can find the pull request template here.
- Install node, npm is bundled with the download
- Open a command prompt in your repo directory and run 'npm install'.
- Log into the Discord website and navigate to the applications page
- Click
New Application
- Give your application a name
- Navigate to the
Bot
tab and clickAdd Bot
. You will have to confirm by clickingYes, do it!
- Click the
Copy
button underneath token. (Do not share this) - Create a file called
.env
in your bot repo - Inside the .env file, type
DISCORD_TOKEN=TOKEN
replacing TOKEN with what you copied in step 6 - You may need to add the .env file to your gitignore if your IDE hasn't done it automatically.
Some commands may require additional tokens. If you would like to test them out on your bot, you must include the tokens inside your .env file. These commands include the metar and station commands. Both of these use the same API meaning you only need one token. The steps below will explain how to set this up.
- Make a free account here. Then, follow the steps here to get your token
- Inside the .env file, on a new line type
METAR_TOKEN=TOKEN
replacing TOKEN with what you copied in step 1 - Then, on another new line within the .env file, type
STATION_TOKEN=TOKEN
replacing TOKEN with what you copied in step 1
Privileged Gateway Intents must now be enabled within the Discord Developer Portal in order for your bot to function. The steps below will explain how to enable them.
- Log into the Discord website and navigate to the applications page and select your application. Then select
Bot
underSettings
- Scroll down to the Privileged Gateway Intents section and enable all the intents.
- Create a Discord server where you can test your bot
- On the applications page, select your application and navigate to the
OAuth2
tab. Then selectbot
under thescopes
section - Tick
Administrator
under theBot Permissions
section - Click the
Copy
button and paste it into your browser of choice, invite it to your test server.
- Open a command prompt in your repo directory
- Run
npm run dev
- If all has gone well, you will see the bot is running as
http://localhost:3000
and logged into the name of the bot you created! - You can now test your commands
A ban appeal form is sent to a user when they are banned. The URL for the form is stored as an environment variable,
BAN_APPEAL_URL. For testing, you could set to a URL like https://hdsimulations.com
Some commands require access to a MongoDB server to store persistence data. The steps below outline MongoDB's setup procedure, and the necessary steps to connect your application to your MongoDB instance.
- Install MongoDB from their website or set up an Atlas cluster
- If running MongoDB locally, run it as a service or from the terminal
- Create a new database named hd in your MongoDB instance
- Inside the .env file, on a new line type
MONGODB_URL=URL
replacing URL with your MongoDB access URL
If you have installed MongoDB locally, your access url will be mongodb://localhost:27017/hd
. If you are using Atlas, the connection URL can be found under
Connect->Connect your application
in Database, located under Deployments.
Please note, this will only show the basics of adding a command
- Create a new file in the relevant folder within
src/commands/
and name it appropriately.yourcommand.ts
- Create your command
- Add it to
src/commands/index.ts
. You need to add the lineimport { name } from './commandfolder/filename';
, replacingname
with theexport const
from your command,commandfolder
with the relevant folder your command has been placed within, andfilename
with the file name you created in step 1. (Add this below the last command.) - Add your command name to the list under
const commands: CommandDefinition[] = [
- Add your command name the COMMANDS.md index under the appropriate section in the .github directory
- Add your command to the CHANGELOG.md in the .github directory.
If you need help creating a command, you may find it useful to copy an existing command as a template, changing what you need.
Please ensure that the command category is appropriate for the command. You can find what each category means in src/lib/constants.ts
. For example, a command used for support would use the 'SUPPORT' category.
All you need to do is open the command you wish to edit in src/commands/
, edit what you need, commit and push!
import { CommandDefinition } from '../../lib/command';
import { makeEmbed, makeLines } from '../../lib/embed';
import { CommandCategory } from '../../constants';
const IRS_IMAGE_URL = 'https://media.discordapp.net/attachments/984255062010396702/990392133825490994/IRS_Switch_POS.png'; //TODO: Add a more professional looking photo (square view of overhead panel), clean red box
export const irs: CommandDefinition = {
name: 'irs',
description: 'Display help with IRS alignment',
category: CommandCategory.B78XH,
executor: (msg) => {
const irsEmbed = makeEmbed({
title: 'Heavy Division | IRS',
description: makeLines([
'On the overhead panel you will see the two knobs labelled \'IRS\' left and right. Turn these two to the \'ON\' position. ',
'',
'You can check how long you have to wait by looking at the align time on the upper MFD. ',
'',
' **It takes several minutes for the IRS to align.**',
'',
'To align the IRS instantly (not realistic) in the CDU select: ',
'\'HEAVY\' -> \'IRS CONFIGURATION\' -> \'FORCE ALIGN\' ',
]),
image: { url: IRS_IMAGE_URL },
});
return msg.channel.send({ embeds: [irsEmbed] });
},
};