This repository contains bot.js
, a Discord bot that provides fitness accountability, partner matching, AI coaching, and automated content posting. The bot integrates with OpenAI and optionally stores AI telemetry in MongoDB.
- Ensure
OPENAI_API_KEY
andDISCORD_TOKEN
are configured before starting the bot. - Optional:
MONGO_URI
to persist audit logs to MongoDB (Atlas or Railway plugin). - Default AI model is
gpt-3.5-turbo
unless you setOPENAI_MODEL
.
- Install dependencies:
npm install
- Create a
.env
file in the repo root with the following keys (example):
OPENAI_API_KEY=sk-...
DISCORD_TOKEN=bot-token-here
OPENAI_MODEL=gpt-3.5-turbo
FALLBACK_OPENAI_MODEL=gpt-3.5-turbo
MONGO_URI=mongodb+srv://user:[email protected]/mydb
BOT_OWNER_ID=your-discord-id
- Syntax-check the bot (quick):
node --check bot.js
- Start the bot:
node bot.js
Notes:
- If you run the bot locally and want to test admin commands, use an account with Administrator rights in a test server and set
BOT_OWNER_ID
if you want owner-only privileges.
-
Railway provides a plugin to host MongoDB for you. When you add the MongoDB plugin to a Railway project, Railway deploys a managed MongoDB instance and exposes a connection string. To use it:
- Open your Railway project dashboard.
- Click the MongoDB plugin/resource you added.
- In the plugin details you will see a connection string or Environment Variable — copy that value and paste it into the
MONGO_URI
environment variable for your service. - Restart the Railway service.
-
The bot writes audit logs to
data/ai_health.json
locally. IfMONGO_URI
is set, the bot also writes the same events to theai_health
collection in MongoDB.
- Not necessarily. Railway offers a MongoDB plugin that provisions a managed MongoDB instance for your project. If you added that plugin, Railway will have deployed a Mongo instance for you and exposed a connection string.
- Check your Railway project under the Plugins/Resources section. If you see MongoDB listed there and it shows "deployed" or similar, Railway has already provisioned it. Click it and find the connection string. Use that as
MONGO_URI
. - Alternatively, you can sign up for MongoDB Atlas (free tier) and create a cluster yourself. Both options work.
- In Railway project, open the MongoDB plugin/resource you created.
- Find the connection string — Railway usually shows it as an environment variable or a URI. Copy it.
- In your Railway Service, open Environment Variables and add
MONGO_URI
with that connection string value. - Restart the Railway service.
- Set
ADMIN_DASH_SECRET
in Railway env variables (pick a strong random string). For local testing, add it to.env
. - Visit:
https://<your-railway-service-url>/admin/ai-health?secret=<ADMIN_DASH_SECRET>
- Or via curl (JSON):
curl -H "Accept: application/json" "https://<your-railway-service-url>/admin/ai-health?secret=<ADMIN_DASH_SECRET>&n=50"
- The dashboard shows recent
ai_health
events from Mongo (if connected) or the localdata/ai_health.json
fallback.
If you want, I can add a small login or GitHub-Auth protected page, but for now the secret-based route is a simple lightweight solution.
!setmodel <model> [--save] [--force]
— change primary model at runtime.--save
writes to.env
in the repo (local only).--force
bypasses validation.!setfallback <model> [--save]
— change fallback model.!getmodel
— show current and fallback models.!testai
— quick AI health check (60s cooldown per guild).!getaihealth [N]
— show recent AI telemetry (admins only).
- The repository contains a GitHub Actions CI workflow that runs
npm install
andnode --check bot.js
on push/PR to catch syntax issues. - A lightweight automation is provided to create a GitHub issue on every push to
main
reminding you to set environment variables in Railway. This is a safer alternative to giving a bot direct access to your Railway API keys.
- Never commit real API keys to the repository. Use Railway environment variables in production. The
.env
file is for local testing only.
- If AI features fail, check
data/ai_health.json
, the pinned message in#logging
in your server, and the logs in Railway.
If you want, I can add a small admin web dashboard to view ai_health
entries (requires a backing persistent store and simple authentication).
A Discord bot for fitness accountability, workout tracking, and gym community management.
- Daily Check-ins: Track your workout progress with daily check-ins
- Accountability Partners: Get paired with accountability partners to stay motivated
- Fitness Leaderboard: Compete with others on the fitness leaderboard
- AI Coaching: Get personalized coaching advice using OpenAI integration
- Birthday Tracking: Never miss a community member's birthday
- Habit Tracking: Track your fitness habits and streaks
- Fitness Challenges: Create and participate in community fitness challenges
- Role Rewards: Earn special roles based on your fitness achievements
- Sports Updates: Get the latest news on sports, MMA, and boxing
- Health News: Daily health news updates
- Wealth Tips: Daily financial advice for overall well-being
- Node.js 20.x
- Discord Bot Token
- OpenAI API Key
- (Optional) News API Key
- (Optional) YouTube API Key
- Clone the repository:
git clone https://github.com/abelsvj-afk/GymBroBot.git
cd GymBroBot
- Install dependencies:
npm install
- Create a
.env
file in the root directory with the following variables:
DISCORD_TOKEN=your_discord_bot_token
OPENAI_API_KEY=your_openai_api_key
NEWS_API_KEY=your_news_api_key (optional)
YOUTUBE_API_KEY=your_youtube_api_key (optional)
- Start the bot:
npm start
For optimal functionality, create the following channels in your Discord server:
#general
- General chat and birthday announcements#welcome
- Welcome new members#announcements
- Important bot announcements#daily-check-ins
- For workout check-ins#tips-and-guide
- Fitness tips and guides#faith
- Faith-based discussions#mens-style
- Style advice#open-up
- Mental health support#health
- Health news and discussions#wealth
- Financial advice#sports
- Sports updates#fitness
- Fitness discussions#leaderboard
- Automated fitness leaderboard#accountability-lounge
- For finding accountability partners
!coach [topic]
- Get AI coaching advice on a specific topic!progress
- View your fitness progress stats
/partner queue
- Join the accountability partner queue/partner cancel
- Cancel your partner queue request/partner end
- End your current partner pairing/partner status
- Check the partner queue status!findpartner
- Alternative to join the partner queue!endpartner
- End your current partner pairing (in partner channel)
setbirthday MM-DD
- Set your birthday for reminders
/strike add @user [reason]
- Add a strike to a user (mod only)/strike check @user
- Check a user's strikes (mod only)/strike clear @user
- Clear a user's strikes (mod only)
!challenge create [challenge text]
- Create a new fitness challenge!challenge join [challenge ID]
- Join an existing challenge!challenges
- List all active challenges
This bot is designed to be deployed on platforms like Railway, Heroku, or any other Node.js hosting service.
- Connect your GitHub repository to Railway
- Add the required environment variables
- Deploy the main branch
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.