A simple Discord bot that:
- Updates its nickname to show OMFG token price with a trend arrow (🟢▲ for up, 🔴▼ for down, ⏺ for flat).
- Rotates its presence between Total Supply and Circulating Supply.
- Automatically adds/removes Up and Down roles to color the bot’s name based on price trend.
- Removes both roles on flat movement so it’s not misleading during long flat periods.
- Price Source: Jupiter Price API v3
- Supply Source: OmniPair API (
/api/token
) - Trend Sensitivity: Configurable flat percentage threshold
- Role Control: Automatically manage two colored roles for trend indication
- Self-check: Optional hierarchy/permissions check and optional live role flip test
- Node.js 18+
- A Discord bot application with a bot token
- Two roles in your server:
- Up role (green or whatever up color you want)
- Down role (red or whatever down color you want)
- Correct role order:
- Bot’s highest “control” role (no color, Manage Roles + Change Nickname)
- Up role
- Down role
- (No other colored roles above these if you want the color change to be visible)
git clone <your-repo-url>
cd <your-repo-folder>
npm install
DISCORD_TOKEN=YOUR_BOT_TOKEN
GUILD_ID=YOUR_SERVER_ID
OMFG_MINT=omfgRBnxHsNJh6YeGbGAmWenNkenzsXyBXm3WDhmeta
JUP_PRICE_URL=https://lite-api.jup.ag/price/v3
OMNIPAIR_API=https://api.omnipair.fi/api/token
PRICE_REFRESH_MS=60000
PRESENCE_ROTATE_MS=30000
NICK_TEMPLATE={arrow} ${price}
PRESENCE_TEMPLATE_TOTAL=Total: {total}
PRESENCE_TEMPLATE_CIRC=Circulating: {circ}
UP_ROLE_ID=YOUR_UP_ROLE_ID
DOWN_ROLE_ID=YOUR_DOWN_ROLE_ID
FLAT_PCT=0.05 # ±% change considered flat
PRICE_DECIMALS=2 # decimals for price >= $1
SUBDOLLAR_DECIMALS=6 # decimals for price < $1
RUN_ROLE_HIERARCHY_CHECK=true
RUN_ROLE_FLIP_TEST=false
How to get IDs:
- Enable Developer Mode in Discord → Right-click server → Copy ID (GUILD_ID)
- Right-click the role → Copy ID (UP_ROLE_ID / DOWN_ROLE_ID)
- Your bot token is from https://discord.com/developers/applications → Bot tab.
The bot needs:
- Manage Roles (to add/remove Up/Down roles)
- Change Nickname (to update its nickname)
Invite link:
https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot&permissions=335544320
Replace YOUR_CLIENT_ID
with your bot’s Application ID.
Dev mode (auto-restart with tsx):
npm run dev
Production build:
npm run build
npm start
-
Every
PRICE_REFRESH_MS
ms:- Fetches OMFG price from Jupiter.
- Compares to previous price to determine trend (
up
,down
, orflat
). - Updates nickname with arrow + price.
- Applies Up/Down roles accordingly, or removes both if flat.
-
Every
PRESENCE_ROTATE_MS
ms:- Fetches Total and Circulating supply from OmniPair API.
- Rotates presence between showing total and showing circulating.
Variable | Description |
---|---|
DISCORD_TOKEN |
Bot token from Discord Developer Portal |
GUILD_ID |
Server ID |
OMFG_MINT |
Mint address for OMFG token |
JUP_PRICE_URL |
Jupiter Price API endpoint |
OMNIPAIR_API |
OmniPair API endpoint for supply |
PRICE_REFRESH_MS |
How often to update nickname & roles (ms) |
PRESENCE_ROTATE_MS |
How often to rotate presence (ms) |
NICK_TEMPLATE |
Template for nickname ({arrow} , {price} placeholders) |
PRESENCE_TEMPLATE_TOTAL |
Presence text for total supply |
PRESENCE_TEMPLATE_CIRC |
Presence text for circulating supply |
UP_ROLE_ID |
Role ID for "Up" color |
DOWN_ROLE_ID |
Role ID for "Down" color |
FLAT_PCT |
% change considered flat |
PRICE_DECIMALS |
Decimals for price >= $1 |
SUBDOLLAR_DECIMALS |
Decimals for price < $1 |
RUN_ROLE_HIERARCHY_CHECK |
Check role order/permissions on startup |
RUN_ROLE_FLIP_TEST |
Test adding/removing roles on startup |
- Bot not changing nickname → Ensure it has Change Nickname permission and its highest role is above itself.
- Bot not changing colors → Ensure it has Manage Roles permission and that Up/Down roles are below its highest role but above any other colored roles.
- No color change visible → Discord uses the highest colored role; remove or move other colored roles above the bot.
- Rate limits → Keep refresh intervals reasonable (≥ 60s is safe).