-
Notifications
You must be signed in to change notification settings - Fork 0
Development Setup
Set up a development environment for contributing to the bot.
Before starting, ensure you have:
- ✅ Node.js 18+ (Download)
- ✅ npm (comes with Node.js)
- ✅ Git (Download)
- ✅ Code Editor (VS Code recommended)
- ✅ GitHub Account
- ✅ Discord Account
- Go to GitHub Repository
- Click "Fork" (top right)
- Fork to your account
git clone https://github.com/YOUR_USERNAME/MC-Server-Status-Bot.git
cd MC-Server-Status-Bot
cd "Mc Server Stats Bot"npm installSee Discord Bot Setup to create a test bot.
Important: Use a separate test bot, not your production bot!
Create global-config.json:
{
"token": "YOUR_TEST_BOT_TOKEN_HERE",
"language": "en"
}node index.jsExpected output:
[INFO] Bot started successfully
[INFO] Logged in as TestBot#1234
[INFO] Ready to serve 1 guilds
Extensions:
- ESLint - Code linting
- Prettier - Code formatting
- GitLens - Git integration
- Discord.js Snippets - Code snippets
Auto-restart on file changes:
# Install globally
npm install -g nodemon
# Run bot with auto-restart
nodemon index.js- Create a Discord server for testing
- Invite your test bot
- Create test channels:
#bot-testing#status-test#debug
Option 1: Local Server
- Run Minecraft server locally
- Test IP:
localhost:25565
Option 2: Public Test Server
- Use public test servers
- Example:
mc.hypixel.net
Option 3: Mock Server
- Use debug tools to simulate responses
Your workspace should look like:
MC-Server-Status-Bot/
├── .git/
├── Mc Server Stats Bot/
│ ├── node_modules/
│ ├── classes/
│ ├── configs/
│ ├── texts/
│ ├── Debug/
│ ├── index.js
│ ├── package.json
│ └── global-config.json ← You create this
└── README.md
Don't commit:
-
global-config.json(has your token!) -
node_modules/(too large) -
configs/*.json(test data) -
.envfiles
Check .gitignore:
node_modules/
global-config.json
configs/*.json
*.log
.envRun all diagnostics:
node Debug/master-debug.jsValidate token:
node Debug/token-validator.jsTest network:
node Debug/network-test.jsCheck configs:
node Debug/config-validator.jsTest commands:
node Debug/command-tester.jsWindows:
Test_all_debug_tools.batLinux/Mac:
chmod +x Test_all_debug_tools.sh
./Test_all_debug_tools.shAdd debug logs:
console.log('[DEBUG] Server status:', status);
console.error('[ERROR] Failed to query:', error);Create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Bot",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}/Mc Server Stats Bot/index.js"
}
]
}Use breakpoints:
- Click left of line number
- Press F5 to start debugging
- Code pauses at breakpoint
Enable debug logging:
client.on('debug', info => {
console.log('[Discord.js]', info);
});Install Prettier:
npm install --save-dev prettierCreate .prettierrc:
{
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}- 2 spaces indentation
- Single quotes for strings
- Semicolons required
- camelCase for variables
- PascalCase for classes
# 1. Start of day - sync with main
git checkout main
git pull upstream main
git push origin main
# 2. Create feature branch
git checkout -b feature/my-feature
# 3. Make changes
# ... edit files ...
# 4. Test changes
node index.js
# Test in Discord
# 5. Commit changes
git add .
git commit -m "feat: add new feature"
# 6. Push to your fork
git push origin feature/my-feature
# 7. Create PR on GitHubAdd upstream remote (once):
git remote add upstream https://github.com/Gamer100309/MC-Server-Status-Bot.gitUpdate your fork:
git checkout main
git pull upstream main
git push origin mainBefore submitting code:
- Bot starts without errors
- All commands work (
/setup,/reload, etc.) - Server monitoring works
- Embeds display correctly
- Buttons/menus function
- Server offline handling
- Invalid IP/port handling
- Network timeout handling
- Permission errors handling
- Invalid config handling
- No console errors
- No unused variables
- Code follows style guide
- Comments added where needed
- No debug code left
- README updated if needed
- Wiki updated if needed
- Code comments added
- Changelog updated
Solution:
npm installSolution:
- Check
global-config.json - Verify token is correct
- No extra spaces
Solution:
# Find and kill process
# Windows:
netstat -ano | findstr :3000
taskkill /PID <PID> /F
# Linux/Mac:
lsof -ti:3000 | xargs killSolutions:
- Check token is valid
- Check internet connection
- Check Discord status
- Verify bot is running
- Discord Developer Portal
- JSONLint - Validate JSON
- Regex101 - Test regex
- Carbon - Code screenshots
// ❌ Bad
const x = await fetch();
const arr = [];
// ✅ Good
const serverStatus = await fetchServerStatus();
const onlineServers = [];// ❌ Bad
try {
doSomething();
} catch (e) {}
// ✅ Good
try {
doSomething();
} catch (error) {
logger.error('Failed to do something:', error);
// Handle error appropriately
}// ❌ Bad - no comment
if (a && (b || c) && !d) {
// ...
}
// ✅ Good - explains logic
// Check if user has permission AND
// (is admin OR has setup role) AND
// is not banned
if (hasPermission && (isAdmin || hasSetupRole) && !isBanned) {
// ...
}// Test with:
// - Empty strings
// - null/undefined
// - Very large numbers
// - Special characters
// - Network failuresNow that your environment is set up:
- Explore the code - Read through existing files
- Find an issue - Check GitHub issues
- Make changes - Start small
- Test thoroughly - Use all debug tools
- Submit PR - Follow contribution guidelines
- Project Structure - Code organization
- Contributing Code - Contribution guidelines
- Debug Tools - Testing utilities