NameSync is a Node.js-based Discord bot that syncs verified NamelessMC usernames with Discord nicknames. It periodically polls the NamelessMC API and updates guild member nicknames accordingly.
- ✅ Polls the NamelessMC API every 60 seconds
- 🔁 Automatically updates Discord nicknames for verified users
- ♻️ Auto-restarts every 5 minutes using
pm2to ensure reliability - 🔒 Secure API key handling with
.envfile - 🛠️ Slash command for manually checking the total number of users
-
Clone the repo:
git clone https://github.com/Ker35/NameSync.git cd NameSync -
Install dependencies:
npm installAlso best to install pm2 (globally) separately
npm install pm2 -g -
Copy environment variables file and configure it:
mv .env.example .envThen open
.envand fill in your:DISCORD_TOKENGUILD_IDNOTIFY_CHANNEL_IDNAMEMC_API_URLNAMEMC_API_KEYROLE_MAP
⚠️ Important:In ROLE_MAP, each group name (e.g., Member, Mod) must exactly match the group name on your website - including capitalization and spelling or role syncing will not work correctly.
-
Run using PM2 (auto-restarts every 5 minutes):
npm run pm2-start -
Useful PM2 commands:
- View logs:
pm2 logs NameSync - Restart bot:
pm2 restart NameSync - Stop bot:
pm2 stop NameSync - Delete bot process:
pm2 delete NameSync
- View logs:
If you added a slash command to show NamelessMC user totals, make sure to register your command with Discord using the Discord API or relevant tools.
index.js– main bot logic.env– environment variables (excluded by.gitignore)package.json– dependency and script definitionsLICENSE.md– usage and distribution termsREADME.md– you're reading it!
Feel free to fork and make pull requests. If you improve it, we’d love to see it!
This project is licensed under the Modified MIT License.
See LICENSE.md for more information.