ModBot is an automated moderation bot designed for the University of Portsmouth Discord Server to tackle the manual work of solving or detecting problems within the server.
Before even getting this bot to function on your server, you will need to first create it through developer's portal page, setup some permissions for it and then invite it into your server. Here are the steps:
-
Navigate to Discord Developer Portal and sign in
-
On the
Applicationstab, click onNew Applicationtop right next to your discord avatar -
Name the bot however you want (For example: portBot)
-
[IMPORTANT] Navigate over these sections to copy and save the information that will be required from this page
- Navigate to
OAuth2page and look atClient Informationsection - Press the
Copybutton under theClient ID, this ID will be used to allow you to identify and interact with your bot through Node.js code. Make note of this ID - Navigate to
Botpage and look atTOKENsection. Do note that this token can only be viewed once for security purposes. NEVER under any circumstances NEVER EVER expose this token. It is there to ensure the authorisation of your bot's communication between it and Discord. PressReset Tokenand make note of the token.
- Finally, navigate to your discord's server where you want to assign your bot to be there. Right-click it and click
Copy Server ID. If you can't see this button, navigate to your discord account settings --> Extended settings --> Developer Mode - ON. Make note of the server ID.
- Navigate to
-
Navigate to
Bottab, scroll down toAuthorization FlowandPrivileged Gateway Intentsand ensure these permission are configured as listed:- Public Bot - OFF
- SERVER MEMBERS INTENT - ON
- MESSAGE CONTENT INTENT - ON
-
Navigate to
OAuth2tab, scroll down toOAuth2 URL Generatorand make sure that at least thebotandapplications.commandsare ticked -
Once configured, copy the provided link at the bottom of the page, then paste that into a new tab in browser, choose the server you want the bot to join and Woilah!
-
You should be able to look at your server and see the bot you just created on the member's list. If so, move on to
Integrating Virustotal API into botsection of this spec.
- Navigate to Virustotal Official Page and sign in/up Note: Use the public/free API for now.
- Once signed in, click at the top right of the page your profile name and then
API Keybutton. - You will be presented with the information about your key, access level, rate and quota. However, what you'll need is the
API KEYsection at the top of the page. Click on the clipboard icon to the right of the hidden API key and make note of it for later stage. Note: Similarly with the Bot's token, DO NOT expose this key under any circumstance. It is only used by owners and trusted persona. - Once done, move on to
Getting Startedsection
- User Registration: Allows new users to register by providing their student ID, first name, and last name. The bot automatically assigns them a nickname and role based on their registration information.
- Sentiment Analysis: Utilizes sentiment analysis to identify and flag negative messages for review by server administrators.
- Custom Bad Word Filtering: Automatically detects and filters out messages containing offensive language based on a customizable list of bad words.
- Malicious Link Scanner With the use of Virustotal's public API, this feature lets the bot scan any possible web-link, analyse its detection rate and perform actions based on the severity of the resulted scan.
To get started with ModBot, follow these steps:
-
Clone the Repository: Clone this repository to your local machine using the following command in terminal:
git clone https://github.com/NikBit101/modbot.git -
Install Dependencies: Navigate to the project directory and install the required dependencies using npm:
- The 'npm install' command and its required dependencies are already pre-installed and using this method will active the installation
cd modbot npm start OR npm install
- Configure the Bot/API:
-
Create a
config.jsonfile in the project root directory and add your bot token:{ "clientId": "YOUR_BOT_ID", "guildId": "YOUR_SERVER_ID", "token": "YOUR_DISCORD_BOT_TOKEN" } -
Configure other settings such as role names, channel IDs, etc., as needed.
-
Additionally, create a
channel-config.jsonfile in thecommands/registrationfolder path and add your channel's IDs for registration part:{ "get-access-id": "YOUR_SERVER_CHANNEL_ID", "bot-emergency-id": "YOUR_SERVER_CHANNEL_ID" }To get the ID of your channel, right-click it and press
Copy channel ID, paste it to the key value above.Note: Make sure that the bot's role is highest on the list of roles. That is to avoid possible errors of unauthorised permissions for the bot due to it being on low priority in terms of role list.
-
Lastly, create a
vtConfig.jsonfile in the project root directory and add your Virustotal's API key like so:{ "apiKey": "YOUR_VIRUSTOTAL_API_KEY" }
-
Run the Bot: Start the bot by running the following command in terminal:
npm start -
(Optional) Deploy Slash Commands: If you make changes to slash commands, you can deploy them using the following command in terminal:
node deploy_commands.jsDo note that the command
npm startalready does that for you.
Once the bot is running and configured, different users can interact with it using various commands:
- /addword: Add a word to the custom dictionary of bad words ('Server Admin' role only).
- /deleteword: Remove a word from the custom dictionary of bad words ('Server Admin' role only).
- /reg: Register your student information to access the server. (only new members within '#get-access' channel)
For detailed information on available commands and their usage, refer to the bot's help command or documentation.
Do also note that the bot currently has 2 roles within the code that it can scan through - admin and student. This can be set accordingly based on server roles and rules.
If you encounter any issues or have questions about ModBot, feel free to open an issue on the GitHub repository.
This project is licensed under the ISC License.