Skip to content

A Discord bot to assign roles based on League of Legends Rank

Notifications You must be signed in to change notification settings

simwai/lol-ranks-bot

Repository files navigation

lol-ranks-bot

A Discord bot that allows users to verify their League of Legends summoner name and assigns roles based on their rank/elo in the game. Users must initiate the verification process themselves, and upon successful verification, the bot will grant them the appropriate rank role within the Discord server.

VS Code ESLint Prettier License: CC BY-NC 4.0

Prerequisites

Before you begin, ensure you have met the following requirements:

  • Node.js (v16.0 or higher)
  • NPM (usually comes with Node.js)
  • Docker and Docker Compose (for Docker deployment)
  • PM2 (for PM2 deployment)

Install Node.js (v16.0 or higher) and NPM from Node.js official website.
Install Docker and Docker Compose on your server. Follow the official Docker guide for installation instructions.

Local Development Setup

Follow these steps to set up the bot for development purposes on your local machine:

  1. Clone the repository:
    • Navigate to the directory where you want to clone the repository.
    • Run git clone https://github.com/simwai/lol-ranks-bot.git.
    • Navigate to the cloned directory by running cd lol-ranks-bot.
  2. Install dependencies by running npm install.
  3. Copy config.json.example and name it config.json.
  4. Adjust the config values by editing config.json.
  5. Start the bot by running npm run-script start.

Server Deployment

Docker Deployment

To deploy the bot on a server using Docker, follow these steps:

  1. Clone the repository:
    • Navigate to the directory where you want to clone the repository.
    • Run git clone https://github.com/simwai/lol-ranks-bot.git.
    • Navigate to the cloned directory by running cd lol-ranks-bot.
  2. Copy config.json.example and name it config.json.
  3. Adjust the config values by editing config.json.
  4. Run docker compose up -d to build the Docker image and start the bot in detached mode.
  5. To stop the bot, run docker compose down.

PM2 Deployment

To deploy the bot on a server using PM2, follow these steps:

  1. Install PM2 globally by running npm install pm2 -g.
  2. Clone the repository:
    • Navigate to the directory where you want to clone the repository.
    • Run git clone https://github.com/simwai/lol-ranks-bot.git.
    • Navigate to the cloned directory by running cd lol-ranks-bot.
  3. Install dependencies by running npm install.
  4. Copy config.json.example and name it config.json.
  5. Adjust the config values by editing config.json.
  6. Start the bot using PM2 by running pm2 start src/index.js --name lol-ranks-bot.
  7. To ensure PM2 restarts the bot after reboots, run pm2 save

How the Bot Works

  • Users trigger the verification process by a command in Discord.
  • The bot verifies the user's League of Legends summoner name.
  • Once verified, the bot checks the user's rank/elo in League of Legends.
  • The bot assigns a corresponding rank role and verified role to the user in the Discord server based on their League of Legends rank/elo.
  • The bot keeps the lol ranks of the verified users up-to-date by running periodically.
  • The bot does not automatically assign roles to all users; each user must initiate the verification process.

Settings

  • channels = Set the ID of the channels that will be used for the Bot to send the messages (optional)

    • help - Default channel to help members with bot-related issues
  • guildID = ID of your server (Tutorial)

  • discordToken = Tokens of your bot, used to authorize API requests and carry all of your bot user’s permissions (Tutorial)

  • riotToken = Riot development API key (Tutorial)

  • status = The Discord bot status

  • ranks = The names of your rank roles on your Discord server

  • rankIconNames = The names of you rank icons on your Discord server

  • region = The LoL API endpoint region

  • timeZone = Your timezone, you can find all timezones here

  • language = Select your general language according to the filename inside the locales folder (name only, no extension)

  • eloRoleLanguage = Select your rank role language

  • verifiedRoleLanguage = Select your verified role language

  • enableCronJob = Enables automatic update of ranks every X time, defined in cronTab

  • cronTab = Defines how often the ranks will be updated if enableCronJob is true

  • concurrentRequests = Defines the number of concurrent requests to the API (See Rate Limits after login)

  • requestTime = Set the request time in milliseconds

  • setVerifiedRole = Sets the verified role, when somebody has got an elo role

  • enableVerification = Enables summoner name verification

  • enableTierUpdateMessages = Enable bot to send messages on configured channel for rank up/down

  • To enable rank icons on messages (like this Challenger Icon) you need to add custom emojis on your server (Tutorial)). The icons are inside the assets/img folder (Please do not change the name of the icons or the bot will not be able to identify them)

LICENSE

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Creative Commons License