diff --git a/src/commands/CommandHandler.js b/src/commands/CommandHandler.js index bbbf190..791f5cb 100644 --- a/src/commands/CommandHandler.js +++ b/src/commands/CommandHandler.js @@ -1,4 +1,4 @@ -const { ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js'); +const { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } = require('discord.js'); const EmbedBuilders = require('../utils/embedBuilders'); class CommandHandler { @@ -206,8 +206,44 @@ class CommandHandler { const teamMessage = isOnTeam ? `\nThey are on a team for ${gameFilter} but haven't played any matches yet.` : ''; + + // Create a basic embed with user info + const basicEmbed = new EmbedBuilder() + .setTitle(`User: ${playerData.username || 'Unknown'}`) + .setDescription(playerData.profile?.bio || 'No bio available') + .setColor('#0099ff') + .setImage('https://www.vrbattles.gg/assets/images/Qubi/vrwearcubesatad.png'); + + // Add avatar if available + if (playerData.profile?.avatar) { + basicEmbed.setThumbnail( + `https://www.vrbattles.gg/assets/uploads/profile/${playerData.profile.avatar}` + ); + } + + // Add basic profile fields + const profileFields = []; + const profile = playerData.profile || {}; + if (profile.country) profileFields.push({ name: 'Country', value: profile.country, inline: true }); + if (profile.level) profileFields.push({ name: 'Level', value: profile.level.toString(), inline: true }); + if (profile.xp) profileFields.push({ name: 'Total XP', value: profile.xp.toString(), inline: true }); + if (profile.prestige) profileFields.push({ name: 'Prestige', value: profile.prestige.toString(), inline: true }); + + if (profileFields.length > 0) { + basicEmbed.addFields(profileFields); + } + + // Add message about no game stats + basicEmbed.addFields({ + name: `${gameFilter} Status`, + value: `❌ No match history found for ${gameFilter}${teamMessage}` + }); + + const row = this.createActionRow(playerData.username); + await interaction.editReply({ - content: `✅ User found, but they haven't played ${gameFilter} yet.${teamMessage}` + embeds: [basicEmbed], + components: [row] }); return; } @@ -281,21 +317,22 @@ class CommandHandler { // Input validation if (!teamName || typeof teamName !== 'string') { await interaction.editReply({ - content: '❌ Invalid team name provided.' + content: '❌ Invalid team name provided.', + ephemeral: false }); return; } - // Enhanced sanitization - only allow alphanumeric characters, spaces, and specific symbols - // Limit the length to prevent buffer overflow attacks + // Enhanced sanitization const sanitizedTeamName = teamName - .replace(/[^a-zA-Z0-9\s\-_.]/g, '') // Remove any characters that aren't alphanumeric, space, hyphen, underscore, or period + .replace(/[^a-zA-Z0-9\s\-_.]/g, '') .trim() - .slice(0, 100); // Limit length to 100 characters + .slice(0, 100); if (!sanitizedTeamName) { await interaction.editReply({ - content: '❌ Team name must contain valid characters (letters, numbers, spaces, hyphens, underscores, or periods).' + content: '❌ Team name must contain valid characters (letters, numbers, spaces, hyphens, underscores, or periods).', + ephemeral: false }); return; } @@ -309,12 +346,12 @@ class CommandHandler { timestamp: new Date().toISOString() }); - // Game filter is pre-validated by Discord's slash command choices const teamData = await this.playerService.findTeamByName(sanitizedTeamName, gameFilter); if (!teamData || !teamData.success || !teamData.teams || teamData.teams.length === 0) { await interaction.editReply({ - content: '❌ No teams found matching your search criteria.' + content: '❌ No teams found matching your search criteria.', + ephemeral: false }); return; } @@ -323,7 +360,8 @@ class CommandHandler { await interaction.editReply({ embeds: embeds, - components: [] + components: [], + ephemeral: false }); } catch (error) { this.logger.error('Error in handleFindTeam:', { @@ -334,7 +372,8 @@ class CommandHandler { timestamp: new Date().toISOString() }); await interaction.editReply({ - content: '❌ An error occurred while searching for teams.' + content: '❌ An error occurred while searching for teams.', + ephemeral: false }); } } @@ -344,11 +383,7 @@ class CommandHandler { new ButtonBuilder() .setLabel('🔵 View Profile') .setStyle(ButtonStyle.Link) - .setURL(`https://www.vrbattles.gg/profile/${username}`), - new ButtonBuilder() - .setLabel('🟡 Join Main Discord') - .setStyle(ButtonStyle.Link) - .setURL('https://discord.gg/j3DKVATPGQ') + .setURL(`https://www.vrbattles.gg/profile/${username}`) ); } }