Installation - TamaniWolf/ClanBot Wiki

Original URL: https://github.com/TamaniWolf/ClanBot/wiki/Installation

Installation and setup

Prerequisites

This bot is built on Node.js. If you do not yet have Node installed, download and install the latest LTS version from the official website for your platform:

https://nodejs.org/en/download/

I recommend Node v14+.

Installation

To set up Clanbot, download the latest repository ZIP and unzip it

Once unzipped, enter the directory and install the dependencies:

cd ClanBot
npm install

I recommend to use pnpm for space efficiency of the dependencies:

cd ClanBot
npm i g- pnpm
pnpm i -g <package>

And to get the dependence packages in the bot:

pnpm update

Getting required tokens

You will need: DISCORD_BOT_TOKEN TWITCH_CLIENT_ID TWITCH_CLIENT_SECRET TWITCH_OAUTH_TOKEN

Note that you will need to set up some external applications:

Discord bot application

Your Discord bot needs to be registered as an application, and you will need a bot token (DISCORD_BOT_TOKEN in .env).

Follow this guide for more information.

Twitch application

To connect to the Twitch API, you will need to register a new application in the Twitch Developers Console.

Click on 'Register Your Application' and give it a name, For the OAuth Redirect URLs, use http://localhost, and select a Category (I recommand to use other, Chat Bot or Application Integration), Confirm that you arn't a Robot and click 'Create'.

You will need to grab the Application Client ID from there and put it to TWITCH_CLIENT_ID in .env).

Twitch OAuth token

To make things more complicated, all requests to the Twitch API need to be authenticated with an OAuth grant generated by your own application.

To begin the authorization flow, you'll need to complete the authorization prompt yourself:

https://id.twitch.tv/oauth2/authorize?client_id=<YOUR_CLIENT_ID_HERE>&response_type=token&redirect_uri=http://localhost

Replace <YOUR_CLIENT_ID_HERE> with your Application Client ID and hit enter, You will be redirected and asked to authorize on which you will need to click.

You can grab the access_token=<YOUR_ACCESS_TOKEN>=&token_type=bearer from the redirect URL in your browser, and store it as TWITCH_OAUTH_TOKEN in .env .

You will also need the client_secret. You will find it at the Twitch developer console, in the Application where you need to generate one by clicking on New Secret.

Configuration

To configure ClanBot, use the included config.json and .env and enter or customize the values in the file.

{
  "twitch_channels": "<REPLACE_ME>, <REPLACE_ME_2>",
  "twitch_check_interval_ms": 60000,
  "twitch_use_boxart": false,
  "set": {
    "profilenewjoin": false,
    "profilenewcommand": false
  }
}
//For Settings in .env use (process.env.) and (config.) in Config.json
//-- Clan Assistant --//
TOKEN = <REPLACE_ME>
PREFIX = c.
IP = <REPLACE_ME>
MCSNAME = <REPLACE_ME>

//-Twitch
TWITCH_CHANNELS = <REPLACE_ME>, <REPLACE_ME_2>
DISCORD_ANNOUNCE_CHANNEL = <REPLACE_ME>
TWITCH_CLIENT_ID = <REPLACE_ME>
TWITCH_CLIENT_SECRET = <REPLACE_ME>

Configuration options explained:

Key Required? Description
.env
TOKEN Your bot token, via Discord developer portal.
PREFIX Your bot prefix, to execute commands.
IP The IP of your or another Minecraft server.
MCSNAME Namne of the Minecraft server.
TWITCH_CHANNELS Comma-separated list of all channels you want to monitor and send live notifications for.
DISCORD_ANNOUNCE_CHANNEL Channel name to post stream announcements in. Make sure the bot has permissions to post here.
TWITCH_CLIENT_ID Client ID for your Twitch app, via developer portal.
TWITCH_CLIENT_SECRET Client Secret of your Twitch app, via developer portal.
config.json
discord_mentions This maps channel names to the Discord @ you want to send, such as a role or everyone. If a channel is missing here, no @ is used. Note: once the message is updated, the @ is always removed to prevent spamming users with notifications.
twitch_check_interval_ms How often to poll the Twitch API and send or update live embeds.
twitch_use_boxart If true, use alternate Live Embed style that includes game boxart as a thumbnail image if available.
profilenewjoin Controlled by command! Turn ON/OFF if user profile is created on join.
profilenewcommand Controlled by command! Turn ON/OFF command to create user profile.
lang Set's the language the bot will "speak" in the chat

Starting ClanBot

Once the application has been configured, start it using node from the installation directory:

node .

Or with pm2.

pm2 start clanbot.js

Or on Linux with script

./start.sh

Inviting ClanBot

Send the following link to the admin of a Discord server to let them invite the Bot:

https://discordapp.com/oauth2/authorize?client_id=BOT_CLIENT_ID&scope=bot

Swap BOT_CLIENT_ID in the URL above for your Discord app's client id, which you can find in the app details.