Self-hosting the bot
Run your own copy of Member Counter with Docker, on your own machine or your own server.
A self-hosted bot is a copy of Member Counter that you run yourself. It logs in with your own Discord bot token and stores its data on your machine. It also serves its own dashboard at http://localhost:3000.
It has every feature: channels update every 5 minutes and every counter works, as long as you turn on the privileged intents in the Discord Developer Portal.
Self-hosting or a custom bot?
Self-hosting and a custom bot give you the same bot. The difference is who runs the machine.
Free. You only pay for the hardware.
Paid, per quota unit per quarter.
You install, update and back it up.
We install, update and back it up.
Full control over your data and over every setting in .env.
Control panel with the settings that matter, on our hosting.
Runs as long as your machine is on.
Runs 24/7 on our infrastructure.
No official support beyond this guide.
Support from the team.
If you want the same result without the maintenance, read How to get a custom bot.
Requirements
You will type commands in a terminal. Read this guide top to bottom before you start: every step depends on the one above it.
Docker, with Docker Compose v2.23.1 or newer
Install Docker. Check your version with docker compose version. Older versions cannot read the compose file.
git
A CPU with AVX support
The database runs mongo:7, and MongoDB 5.0 and newer need AVX. Older processors lack it, and some VMs and NAS boxes hide it from their guests. On Linux, check with grep -o avx /proc/cpuinfo | head -1.
1. Create your Discord application
Your bot needs its own application in the Discord Developer Portal. The steps are the same as for a custom bot:
Creating a Discord bot accountCome back with these four things:
the bot token
the client ID, on the OAuth2 tab
the client secret
a redirect URL added and saved on the OAuth2 tab:
http://localhost:3000/api/auth/callback
2. Download Member Counter
Then open the folder it created:
3. Create your .env file
Every setting lives in one file. Copy the example:
Open the new .env with any text editor. You might have to turn on hidden files in your file explorer to see it.
The variables you must fill in
The file starts with the block of variables you have to fill in yourself. Set these six:
COOKIE_SECRET
A random string of at least 32 characters. On macOS or Linux, openssl rand -base64 32 generates one. Shorter values are rejected on start-up.
DISCORD_CLIENT_ID
Your application's client ID.
DISCORD_CLIENT_SECRET
Your application's client secret.
DISCORD_BOT_INSTANCE_TOKEN
Your bot token.
WEBSITE_URL
Where you will open the dashboard. Leave http://localhost:3000 unless you put the bot behind a reverse proxy or a domain. Never add a trailing slash.
DISCORD_OAUTH2_REDIRECT_URI
Must match the redirect URL you saved in the Developer Portal character for character. Leave http://localhost:3000/api/auth/callback if you kept the default.
Two more you should change
These sit in the second block, the one marked as not needing changes. They have values already, but those defaults are written for the public bot.
PUBLIC_BOTS_IDS
Ships as '["main", "premium", "beta"]'. Your install runs a single bot with the id main, so the other two ids make your dashboard show two bots that are permanently offline. Set it to PUBLIC_BOTS_IDS='["main"]'.
MAIN_DISCORD_CLIENT_ID
Ships as 478567255198662656, the official Member Counter application. /invite builds its link from this value, so until you change it, /invite on your own bot invites ours. Set it to the same value as your DISCORD_CLIENT_ID.
Everything else already works for a single bot on one machine. For extra counters (YouTube, Twitch, Memerator, currency rates), a custom domain, a reverse proxy or sharding, see the configuration reference.
4. Prepare the database
Start only the database services:
Then create the collections and indexes, and apply the schema:
Both commands print their progress and exit.
5. Start the bot for the first time
Start everything, keeping the bot's and the backend's output on screen:
A healthy first start ends with these lines:
Keep the invite link for the next step. The warn line about OPENEXCHANGERATESORG_KEY is harmless.
If the log keeps failing, read the error and check the previous steps:
Disallowed intents
Turn on both privileged intents in step 1.
Invalid token
Check DISCORD_BOT_INSTANCE_TOKEN.
Cookie secret too short
Make COOKIE_SECRET at least 32 characters.
When the log looks right, stop it with Ctrl + C and start it again in the background, so it survives closing the terminal:
6. Invite your bot and open the dashboard
Open the invite link from the log in a browser and add the bot to your server. The link already carries the permissions the bot needs.
Then open your dashboard at http://localhost:3000 and sign in with Discord.

From here the bot works like any other install. Continue with Quick setup.
Day-to-day commands
Run all of these from the bot folder.
docker compose ps
Shows which services are running.
docker compose logs -f bot
Follows the bot's log. Swap bot for backend, frontend or website.
docker compose restart bot
Restarts one service. It does not pick up .env changes; use docker compose up -d for that.
docker compose up -d
Starts everything in the background, and applies .env changes.
docker compose down
Stops and removes the containers.
Back up your data
Back up two things; everything else can be rebuilt:
storage/dbholds your whole database: server settings, templates and channel settings..envholds your secrets and settings.
Run docker compose down before you copy storage/db, so you copy a database that nothing is writing to. To restore, put both back in place and run docker compose up -d. Redis is only a cache, so it needs no backup.
New versions ship as new container images. See Updating a self-hosted bot.
Getting help
Self-hosting is not covered by official support. Ask the community in #support on the support server. Bring the output of docker compose logs --tail 50 bot, and never paste your bot token. To report a bug or improve the bot itself, see How to contribute.
Last updated