How to self-host Member Counter

(With screenshots!)

Recommendations

  • Have patience and read carefully this guide

  • Be familiarized with the CLI (cmd.exe, bash, zsh)

  • If you need help, feel free to ask in this discord server in #support , but READ THE WHOLE GUIDE FIRST!

Creating a bot account

Go to the Discord Developer Portal, and click "New Application", type a name and click the "Create" button

Now go to the bot tab, and click "Add Bot", and confirm by clicking "Yes, do it!"

Now enable all the privileged gateway intents, change the bot icon if you wish and click "Save Changes", and copy the bot token by clicking "Copy" under the "Token" section, save it in a safe place for future steps

Install docker

Download and install Docker and Docker Compose for your OS

After installing docker and docker-compose, you should run the following command:

docker-compose disable-v2

Install git

Download and install git for your OS: https://git-scm.com/download

Install Member Counter

Open your terminal (cmd.exe, Terminal.app, etc) and run this command to download Member Counter

git clone -b master https://github.com/eduardozgz/member-counter-bot.git

Now open the downloaded directory

cd member-counter-bot

Configuring Member Counter

Open the bot folder in your terminal and create a .env file from the .env.example file

copy .env.example .env

A new .envfile will appear in the folder, open it with your favorite text editor (like notepad.exe, vim, vscode, etc)

You might have to toggle the hidden files visibility in your file explorer

You will see a bunch of variables to set, but at least, you only need to set one: DISCORD_CLIENT_TOKEN (in the second line), after the equal character (=) paste here the bot token, and save the file

.env
# Minimal config:
    DISCORD_CLIENT_TOKEN=PASTE HERE THE TOKEN

# General discord related configuration
    # Don't set DISCORD_CLIENT_ID manually, this will be automatically set at runtime
    # DISCORD_CLIENT_ID=
    DISCORD_DEFAULT_LANG=en_US
# and more variables...

Optional configuration

In order to use counters like {youtubeSubscribers} or {twitterFollowers} you must set the following variables:

  • YOUTUBE_API_KEY Paste here your YouTube API key, you can get it here

  • TWITCH_CLIENT_ID and TWITCH_CLIENT_SECRET Paste here your Twitch app credentials, you can get them here

  • MEMERATOR_API_KEY Paste here your Memerator API key, you can get it here, remember to check mark "Get Profiles - View Profiles."

  • TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET Paste here your Twitter API credentials, you can get them here

Start Member Counter

Open again your terminal and use this command

docker-compose up

This step will take a long time, be patient

If you see a message like this, that means you successfully installed Member Counter, else, it will give you errors that you must fix (stop the bot with Ctrl+C and check the previous steps)

Member-Counter-App | Database connection ready
Member-Counter-App | Bot ready
Member-Counter-App | Invite link: https://discord.com/oauth2/authorize?client_id=787989722009174066&permissions=269864023&scope=bot

Invite the bot to your discord server using the provided link, and check commands like @Member Counter help, @Member Counter status

If the bot is working well, let's make the bot auto start when your PC or server boots up, focus your terminal window and hit Ctrl+C to stop the bot and then run it again in the background with this:

docker-compose up -d

The bot will run in background, to stop it you can use

docker-compose down

Updating Member Counter

Open the bot's folder in a terminal, and stop and destroy the bot

Don't worry, all the DB data is stored in ./storage

docker-compose rm -s -f

Download the latest version

git pull

Rebuild and start everything again except the bot

docker-compose up -d --force-recreate --build --scale member-counter-bot=0

Run the bot image, but running the update scripts, not the actual bot

docker-compose run --rm --name bot_update --entrypoint sh member-counter-bot -c 'for file in /app/res/updateScripts/*; do $file; done'

Finally, start the bot

docker-compose up -d --scale member-counter-bot=1

Last updated