Skip to content

Latest commit

 

History

History
174 lines (111 loc) · 6.07 KB

CONTRIBUTING.md

File metadata and controls

174 lines (111 loc) · 6.07 KB

Contributing to the bot

Contributions are always welcome, no matter how big or small!

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

Code of Conduct

This project and everyone participating in it is governed by our Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to our Discord server.

Fork and clone this repository

$ git clone https://github.com/YOUR-GITHUB-USERNAME/KLE-bot
  • Having cloned the copy to your local machine, enter into the KLE-bot directory using the cd command.
$ cd KLE-bot

Setup

Install Node.js

The bot is built on node.js. Install it from here.

Setup local MongoDB server

The bot uses MongoDB as its database. In order to install MongoDB, refer the guide here: https://docs.mongodb.com/guides/server/install/

Create the bot on Discord

For an illustrated guide, refer this.

  • Go to Discord Developer Portal and login with your Discord Account.
  • Create a New Application.
  • Click on Add Bot in the Bot section.
  • You’ll get your Bot API token under the token title.
  • Enable Presence Intent and Server Members Intent.

Add bot to yout Test Server

  • Go to OAuth2 section in your application
  • Select bot in the scopes menu and Administrator in bot permission menu.
  • A Link will be generated in the scope menu, copy it and paste it in your browser's address bar.
  • Select your test server from the drop down box...

.env file

For the environment variables, create a .env file.
You may rename the .env.example file to .env and fill the values accordingly, instead.

Note: Specify the environment variables according to your need i.e. you might not require some of them depending upon your use-case. To help you, for each environment variable, the reasons and references for it have been provided here.

Bot token

First of all, you need to specify your Bot token to perform any action through your bot.

BOT_TOKEN = <Your-Bot-Token>
MongoDB path

The path to your MongoDB server is required for establising the connection.

mongoPath = "mongodb://localhost:27017/<Your-DB-Name>"
Discord-related environment variables

To get the Server, Channel and User IDs on Discord, refer this article.

  • The Server ID is required to handle many server-related actions.

    SERVER_GUILD_ID = <Your-Test-Server-ID>
    
  • Currently, as part of the "JIITian-verification-process", the bot only allow members to initiate the process through a specific channel on the server.

    VERIFY_CHANNEL_ID = <Verify-Channel-ID>
    
  • In case there is any error, the bot logs the error message to a specified channel on the server.

    ERROR_LOG_CHANNEL = <Error-Log-Channel-ID>
    
  • To get the "Member" role and view the other channels, members have to react to any message on a specified channel.

    RULES_CHANNEL_ID = <Rules-Channel-ID>
    
  • To link Discord usernames to CF handles the bot depends upon the TLE bot. This also means that you require TLE to be in your Test server for accomplishing this task.

    TLE_ID = <TLE-Bot-Discord-User-ID>
    
Email Credentails

The verification process involves sending an email to the institute email id of the member who has requested verification. For this reason an email account is required which will be used to send the email.

SENDER_MAIL_ID = <Email-ID>
SENDER_PASSWORD = <Email-Password>
GitHub Token

The bot has a !paste command which uses gists and for that you require a GitHub personal access token (create). You need to atleast select the "gist" scope for the token you will create.

GITHUB_TOKEN = <GitHub-Token>
Codeforces API key and secret

The bot fetches the ranklist of Codeforces contests using the Codeforces API. Follow the steps provided here to generate the key and the secret.

CF_API_KEY = <Codeforces-API-key>
CF_API_SECRET = <Codeforces-API-Secret>

Build & Execute the bot

  • Run following commands from the terminal.
npm install
npm start
  • The bot will become online on your Test Server!

Pull Request Process

  1. Ensure any install or build dependencies are removed before the end of the layer when doing a build.
  2. Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
  3. Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is SemVer.
  4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request one of the reviewers to merge it for you.