feature team search
This commit is contained in:
@@ -34,6 +34,9 @@ class CommandHandler {
|
||||
case 'list_subscriptions':
|
||||
await this.subscriptionCommands.handleListSubscriptions(interaction);
|
||||
break;
|
||||
case 'findteam':
|
||||
await this.handleFindTeam(interaction);
|
||||
break;
|
||||
default:
|
||||
await interaction.editReply({
|
||||
content: '❌ Unknown command',
|
||||
@@ -217,6 +220,55 @@ class CommandHandler {
|
||||
}
|
||||
}
|
||||
|
||||
async handleFindTeam(interaction) {
|
||||
try {
|
||||
const teamName = interaction.options.getString('teamname');
|
||||
const gameFilter = interaction.options.getString('game');
|
||||
|
||||
const teamData = await this.playerService.findTeamByName(teamName, gameFilter);
|
||||
if (!teamData || !teamData.success || !teamData.teams || teamData.teams.length === 0) {
|
||||
await interaction.editReply({
|
||||
content: '❌ No teams found matching your search criteria.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const embed = EmbedBuilders.createTeamEmbed(teamData.teams);
|
||||
|
||||
// Create buttons for each team
|
||||
const rows = teamData.teams.slice(0, 5).map(team => {
|
||||
return new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setLabel(`🔵 View ${team.name} (${team.game_mode})`)
|
||||
.setStyle(ButtonStyle.Link)
|
||||
.setURL(`${this.playerService.baseUrl}/teams/${team.id}`),
|
||||
);
|
||||
});
|
||||
|
||||
// Add Discord join button in a separate row
|
||||
rows.push(
|
||||
new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
.setLabel('🟡 Join Discord')
|
||||
.setStyle(ButtonStyle.Link)
|
||||
.setURL('https://discord.gg/j3DKVATPGQ')
|
||||
)
|
||||
);
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [embed],
|
||||
components: rows,
|
||||
});
|
||||
} catch (error) {
|
||||
this.logger.error('Error in handleFindTeam:', {
|
||||
error: error.message,
|
||||
teamname: interaction.options.getString('teamname'),
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
createActionRow(username) {
|
||||
return new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder()
|
||||
|
||||
Reference in New Issue
Block a user