This bot was created for Programmer Network, which you can join on Twitch or Discord.
Note: Slash Commands must be registered before they can be used. See Deploy Commands for instructions on how to do this.
/ping: Returns the bot's latency and can be used to test if the bot is online./adopt <@user>: Adopt a user as an Early Adopter, which gives them theEarly Adopter ⭐role and instructs them to use#early-adoptersfor discussions related to the platform.
- Clone the repository
Note: this project was created with
yarn, so if you usenpmyou might run into some issues (and should removeyarn.lockbefore running anything).
- Run
npm installoryarn - Rename
.env.exampleto.envand fill in the values- DISCORD_TOKEN: Obtained by following this guide.
- DISCORD_CLIENT_ID: Your Application ID available under
Your App > General Informationafter following the above guide. - DISCORD_DEBUG_GUILD_ID: This variable is used to deploy the newest bot commands to a specific server. To obtain the server ID, right-click the desired server in Discord and select 'Copy ID'. This requires 'Developer Mode' to be enabled, which can be done by going to
User Settings (gear icon) > Advancedand toggling the 'Developer Mode' switch." - DATABASE_URL: This is the connection string to a local PostgreSQL database.
Before running the bot in development mode, you must first migrate the database by running npm run migrate or yarn migrate.
Next, execute npm run dev or yarn dev to start the bot in development mode. This mode will automatically restart the bot when changes are made.
Build the project by running npm run build or yarn build.
Then execute npm run start or yarn start to start the bot in production mode.
This project is configured to run on Fly.io, which is a free hosting service for Node.js apps. To deploy to Fly.io, you must first install the Fly CLI and authenticate.
Before deploying this bot, you must copy the .env file to .env.production and fill in the values. The DISCORD_TOKEN variable should be the bot's token, and the DISCORD_CLIENT_ID value should be the bot's Application ID. You should also create a PostgreSQL database (either on Fly.io or another host) and add the connection string to the DATABASE_URL variable.
To deploy a new version of the bot, execute flyctl deploy.
To stop the bot, execute flyctl scale count 0.
NOTE: You must re-deploy for changes to take effect.
The bot can be restarted by reverting to flyctl scale count 1 and re-deploying.
Run npm run lint:fix or yarn lint:fix to lint the code and implement any fixes, or omit the :fix to just run the linter without making any changes.
Run npm run deploy:guild or yarn deploy:guild to deploy all the bot's commands to the server specified in the DISCORD_DEBUG_GUILD_ID environment variable.
Run npm run deploy:global or yarn deploy:global to deploy all the bot's commands globally (to all servers the bot is in).
Note: It might take up to an hour to take effect.
Contributions are welcome, please open a pull request or issue if you have any suggestions or find any bugs and try to be as descriptive as possible. Don't forget to run Linting before opening a pull request.