v1.2.11: Add tournaments command with filtering and improve error handling

Features:
- Add /tournaments command with status and game filters
- Add tournament API integration to PlayerService
- Add beautiful tournament embed builders with prize pools
- Protect sync-games from overwriting manual customizations
- Improve error handling with proper MessageFlags

Changes:
- Add getTournamentsData() and getTournamentData() to PlayerService
- Add tournament command handler with pagination support
- Add tournament embed builders with rich formatting
- Update deployment docs for v1.2.10 features
- Add issue tracker documentation
- Add tournament testing script
- Fix ephemeral flags throughout CommandHandler
- Improve permission checks with PermissionFlagsBits

Version: 1.2.11
This commit is contained in:
VinceC
2025-10-02 06:24:54 -05:00
parent 546127f91c
commit dd8aa456d9
11 changed files with 502 additions and 60 deletions

View File

@@ -0,0 +1,90 @@
// Test script for tournaments functionality
require('dotenv').config();
const PlayerService = require('../services/PlayerService');
async function testTournamentsAPI() {
console.log('🏆 Testing Tournaments API Functions...\n');
const playerService = new PlayerService();
try {
// Test 1: Get all tournaments
console.log('📋 Test 1: Fetching all tournaments...');
console.log('=' .repeat(50));
const tournamentsData = await playerService.getTournamentsData();
if (tournamentsData && tournamentsData.success !== false) {
console.log('✅ Successfully fetched tournaments data!');
console.log(`📊 Response structure:`, Object.keys(tournamentsData));
// Show some basic info about the tournaments
if (Array.isArray(tournamentsData.tournaments)) {
console.log(`🎯 Found ${tournamentsData.tournaments.length} tournaments`);
// Show first few tournaments as examples
const sampleSize = Math.min(3, tournamentsData.tournaments.length);
console.log(`\n📖 Sample tournaments (showing ${sampleSize}):`);
for (let i = 0; i < sampleSize; i++) {
const tournament = tournamentsData.tournaments[i];
console.log(` ${i + 1}. ${tournament.name || tournament.title || 'Unknown'} (ID: ${tournament.id || 'N/A'})`);
}
} else if (Array.isArray(tournamentsData)) {
console.log(`🎯 Found ${tournamentsData.length} tournaments (direct array)`);
const sampleSize = Math.min(3, tournamentsData.length);
console.log(`\n📖 Sample tournaments (showing ${sampleSize}):`);
for (let i = 0; i < sampleSize; i++) {
const tournament = tournamentsData[i];
console.log(` ${i + 1}. ${tournament.name || tournament.title || 'Unknown'} (ID: ${tournament.id || 'N/A'})`);
}
} else {
console.log('📊 Response data:', JSON.stringify(tournamentsData, null, 2));
}
} else {
console.log('❌ Failed to fetch tournaments data');
console.log('Error:', tournamentsData?.error || 'Unknown error');
}
console.log('\n' + '=' .repeat(50));
// Test 2: Try to get specific tournament data (if we have any tournament IDs)
console.log('\n🎯 Test 2: Testing single tournament fetch...');
console.log('=' .repeat(50));
// Try with a sample tournament ID (you might need to adjust this based on actual data)
const testTournamentId = '1'; // Start with ID 1 as a common starting point
console.log(`📋 Fetching tournament with ID: ${testTournamentId}`);
const singleTournament = await playerService.getTournamentData(testTournamentId);
if (singleTournament && singleTournament.success !== false) {
console.log('✅ Successfully fetched single tournament data!');
console.log('📊 Tournament details:');
console.log(` Name: ${singleTournament.name || singleTournament.title || 'Unknown'}`);
console.log(` Game: ${singleTournament.game || singleTournament.game_name || 'Unknown'}`);
console.log(` Status: ${singleTournament.status || 'Unknown'}`);
} else {
console.log(`❌ Failed to fetch tournament with ID: ${testTournamentId}`);
console.log('Error:', singleTournament?.error || 'Unknown error');
console.log('💡 This might be normal if tournament ID 1 doesn\'t exist');
}
} catch (error) {
console.error('❌ Test failed with error:', {
message: error.message,
stack: error.stack
});
}
console.log('\n🏁 Tournament API testing completed!');
}
// Run the test
if (require.main === module) {
testTournamentsAPI().catch(console.error);
}
module.exports = { testTournamentsAPI };