Self-hosting the bot
(With screenshots!)
You can get a custom bot for free by self-hosting it, but keep in mind:
✅ Pros of Self-Hosting:
- Full control over your data and customization. 
- No recurring subscription fees. 
- Can be deployed on your own infrastructure. 
⚠️ Cons of Self-Hosting:
- Requires technical expertise for setup and maintenance. 
- You are responsible for updates, security, and backups. 
- Hosting costs (servers, bandwidth, etc.) may apply. 
- If hosting on a personal computer, it must remain powered on 24/7 for the bot to be available at all times, which also increases electricity costs. 
- No official support beyond the provided setup instructions, or for specific additional software installation; self-troubleshooting is required. 
For a hassle-free experience with automatic updates, security patches, and support, consider using our managed custom bots!
Recommendations
- Have patience and read carefully this guide 
- Be familiarized with the CLI (cmd.exe, bash, zsh) 
- If you already know how to use the CLI and you still need help, feel free to ask in this discord server in #support 
Creating a bot account
Go to the Discord Developer Portal, and click "New Application"

A dialog box will appear asking for a name. Type the name of your new bot and click "Create"

Now let's configure your new Discord Bot
- Head over the Bot tab 
- Enable the necessary privileged intents outlined, you can also upload the bot's icon and banner, or change its username 
- Save the changes 
- Click on "Reset Token", you will be prompted if you really want to proceed, click "Yes, do it!", the new token will be revealed, copy it and store it in a safe location 
- Head over the OAuth2 tab 
- Copy the client ID and store it in a safe location 
- Click on "Reset Secret", you will be prompted if you really want to proceed, click "Yes, do it!", the new secret will be revealed, copy it and store it in a safe location 
- Add another redirect URL 
- Paste - http://localhost:3000/api/auth/callback. You can change this to fit your needs
- Save the changes 


Install docker
Download and install Docker for your OS: https://docs.docker.com/engine/install/
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 --depth 1 --recurse-submodules --shallow-submodules -b master https://github.com/member-counter/bot.gitgit clone --depth 1 --recurse-submodules --shallow-submodules -b master [email protected]:member-counter/bot.gitNow open the downloaded directory
cd botConfiguring Member Counter
Open the bot folder in your terminal and create a .env file from the .env.example file
cp .env.example .envA new .env file will appear in the folder, open it with your favorite text editor (like notepad.exe, vim, vscode, etc)
You will see a bunch of variables to set, but you only need to set the following block of variables at the start of the file:
- COOKIE_SECRET: Choose some 32 character long password for encrypting session cookies
- DISCORD_CLIENT_ID: Paste here your Discord Bot Client ID
- DISCORD_CLIENT_SECRET: Paste here your Discord Bot Secret
- DISCORD_BOT_INSTANCE_TOKEN: Paste your Discord Bot Token
- WEBSITE_URL: You will need to change this to allow using the website properly behind a reverse proxy or over other IP/hostname
- DISCORD_OAUTH2_REDIRECT_URI: You will need to change this to allow using the website properly behind a reverse proxy or over other IP/hostname
Optional configuration
In order to use some additional counters, you must set the following variables:
- YOUTUBE_API_KEYPaste here your YouTube API key, you can get it here
- TWITCH_CLIENT_IDand- TWITCH_CLIENT_SECRETPaste here your Twitch app credentials, you can get them here
Prepare the database
docker compose up -d --scale bot=0 --scale website=0Apply database migrations
docker compose run -T db-utils npm run db:migrate upApply the database schema
docker compose run -T db-utils npm run db:pushStart Member Counter
Open again your terminal in the bot directory and use this command
docker compose up --attach website --attach botIf you see a message like this, that means you have 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)
website  |   ▲ Next.js 14.2.3
website  |   - Local:        http://localhost:3000
website  |   - Network:      http://0.0.0.0:3000
website  | 
website  |  ✓ Starting...
website  |  ✓ Ready in 212ms
bot      | info: Bot starting...
bot      | info: Bot ready
bot      | info: Logged in as Member Counter#1234
bot      | info: Invite link: https://discord.com/oauth2/authorize?client_id=1234567890&permissions=269569044&scope=bot
bot      | info: Requesting members
bot      | info: Sending bot stats...
bot      | info: Bot stats has been sent
bot      | info: Members receivedIf 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 -dThe bot will run in background, to stop it you can use
docker compose down
Last updated
