Main Discord bot for the Opserv Integration project. This bot allows for Opserv to be integrated with Discord by providing a bridge between the two platforms.
- Node.js (https://nodejs.org/en/download/) (v16.9.0 or higher)
- Discord.js (https://discord.js.org/#/) (v13.3.1 or higher)
- NPM (https://www.npmjs.com/get-npm) (should be installed with Node.js)
- PM2 (https://pm2.keymetrics.io/docs/usage/quick-start/) (Optional) - Used to run the application as a service.
- Discord Bot Token (https://discord.com/developers/applications) - Used to authenticate the bot with Discord.
- Access to the Opserv Database
- Access to the Forum Database
It's HIGHLY recommended running the application as a service. This will allow the application to run in the background and automatically restart if it crashes.
- Download the latest release from the releases page.
- Extract the zip file to a directory of your choice.
- Open a terminal window and navigate to the directory where you extracted the zip file.
- Run
npm installto install the required dependencies. - Run
npm run startto start the application. - The application will now be running in the terminal window. You can close the terminal window if you wish.
- To stop the application, press
CTRL + Cin the terminal window.
- Download the latest release from the releases page.
- Extract the zip file to a directory of your choice.
- Open a terminal window and navigate to the directory where you extracted the zip file.
- Run
npm installto install the required dependencies. - Run
pm2 start ecosystem.config.jsonto start the application as a service. You can then usepm2 stop <name>/<id>to stop the application, andpm2 restart name>/<id>to restart the application. - If you wish to run the application as a service on startup, you can use PM2 to do so. Run
pm2 startupto generate the startup command for your system. Then run the command that was generated to enable PM2 to run on startup. Then runpm2 saveto save the current PM2 configuration. You can then usepm2 stop name>/<id>to stop the application, andpm2 restart name>/<id>to restart the application.
The application requires access to the Xenforo Database and the Bot Database.
The application requires access to the Xenforo Database to fetch the user's forum username. The application will only fetch the user's forum username if the user has linked their forum account to their Discord account from OpServ.
The application requires access to the Bot Database to store the user's Discord ID and their forum username. The application will only store the user's forum username if the user has linked their forum account to their Discord account from OpServ.
The application will self create the required tables if they do not exist. The application will also self populate the required data if it does not exist.
If the application is crashing on startup due to database tables missing relationships, columns, or tables you can access the file models/botdb/botProvider.js and set forceSync to true. This will FORCE the application to DROP ALL TABLES and recreate them. This will also DELETE ALL DATA STORED in the database.
DO NOT set forceSync to true if you have data in the database that you wish to keep. If possible, please create a backup of the database before setting forceSync to true.
NODE_ENV- The environment that the application is running in. This can be set to development or production. This is used to change the logging output between file (production) and console (development). The default value is production. This should not be changed unless you are developing the application.SSLDomain- The domain that the application is running on. This is used to generate the SSL certificate. The default value is localhost. This should not be changed unless you are developing the application.SSLFolder- The folder that the SSL certificate is stored in. The default value is nodecerts. This should not be changed unless you are developing the application.apiPort- The port that the application is running on. The default value is 4500. This should not be changed unless you are developing the application.owners- The Discord IDs of the owners of the bot. This is used to allow the owners to run commands that are restricted to the owners. This should be set to the Discord IDs of the owners of the bot.developers- The Discord IDs of the developers of the bot. This is used to allow the developers to run commands that are restricted to the developers. This should be set to the Discord IDs of the developers of the bot.settings_clientId- The client ID of the Discord bot. This is used to authenticate the bot with Discord when deploying new slash commands. This should be set to the client ID of the Discord bot that you created.botMainDiscordServer- The Discord ID of the main Discord server that the bot is running on. This is used to allow the bot to send messages to the main Discord server. This should be set to the Discord ID of the main Discord server that the bot is running on.streamerRole- The Discord ID of the streamer role. This is used to allow the bot to assign the streamer role to users when they go live. This should be set to the Discord ID of the streamer role.embedColor- The color of the embeds that the bot sends. This is used to change the color of the embeds that the bot sends. This should be set to a RGB color.omitLockdownChannels- The channels that the bot shouldn't lock down when the lockdown command is run. This is used to allow the bot to not lock down certain channels when the lockdown command is run. This should be set to an array of Discord channel IDs.omitLockdownRoles- The roles that the bot shouldn't prevent from messaging in lockdown channels when the lockdown command is run. This should be set to an array of Discord role IDs.creatorId- The Discord ID of the creator of the bot.version- The version of the bot.library- The library that the bot is using.Creator- The Discord username of the creator.website- The website of the bot.discord- The Discord invite link of the bot.server_location- The location of the server that the bot is running on.
name- The name of the application. This is used to identify the application in PM2. The default value isDiscord_Bot_Opserv_Integration. This should not be changed unless you are developing the application.script- The script that is run to start the application. The default value isbot.js. This should not be changed unless you are developing the application.NODE_ENV- The environment that the application is running in. This can be set to development or production. This is used to change the logging output between file (production) and console (development). The default value is production. This should not be changed unless you are developing the application.NODE_EXTRA_CA_CERTS- The path to the SSL certificate. The default value is<path-to-nodecerts>/nodecerts/cabundle.pem. This file should be the cabundle.pem file for the website that the application is running on.TOKEN- The Discord bot token. This is used to authenticate the bot with Discord. This should be set to the Discord bot token that you created.DB1- This should be the connection to the Xenforo database.DB_HOST1- This should be set to the host URL of the database.DB_NAME1- This should be set to the name of the database.DB_PORT1- This should be set to the port of the database.DB_USER1- This should be set to the username of the database.DB_PASS1- This should be set to the password of the database.
DB2- This should be the connection to the Bot database.DB_HOST2- This should be set to the host URL of the database.DB_NAME2- This should be set to the name of the database.DB_PORT2- This should be set to the port of the database.DB_USER2- This should be set to the username of the database.DB_PASS2- This should be set to the password of the database.
info- Displays information about the bot.rolecall- Displays the roles that the bot has.serverinfo- Displays information about the server.userinfo- Displays information about the user.uptime- Displays the uptime of the bot.
lock- Locks down the channel that the command was run in.
emit- Emits an event.getOps- Gets the operations from the Xenforo DB.getOpsList- Sends the operations lists to the different games announcement channels.lockdown- Locks down the server.notify- Sends operation notifications for all operations starting in the next 30 minutes.setAnnouncementChannel- Sets the announcement channel for the specified game.setGameChannel- Sets the game channel for the specified game.setLogChannel- Sets the log channel for the bot.
systeminfo- Displays information about the system that the bot is running on.
ping- Pings the bot and a random API endpoint.
The application uses the winston logger to log messages to the console and to a log file. The log file is named DiscordIntegration.log.
- Fork the repository.
- Create a new branch for your changes.
- Make your changes.
- Create a pull request.
- Enjoy!
If you have any questions, feel free to contact me at:
- WMKR Discord
[WMKR] Patrick - WMKR Forums
Patrick.
