From 119891730de920ae58aefcdadc459ff00dccf067 Mon Sep 17 00:00:00 2001 From: VinceC <33974776+VinceC3@users.noreply.github.com> Date: Thu, 28 Nov 2024 04:59:46 -0600 Subject: [PATCH] match request update --- src/Bot.js | 7 +++++++ src/services/NotificationService.js | 5 ++--- src/utils/componentBuilders.js | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/Bot.js b/src/Bot.js index 5e02baf..a531c5c 100644 --- a/src/Bot.js +++ b/src/Bot.js @@ -23,6 +23,7 @@ class Bot { this.playerService = new PlayerService(logger); this.serverRegistrationService = new ServerRegistrationService(supabase, logger); this.subscriptionCommands = new SubscriptionCommands(supabase, logger); + this.notificationService = new NotificationService(this, supabase); // Initialize command handlers this.commandHandler = new CommandHandler( @@ -36,6 +37,12 @@ class Bot { // Setup event handlers this.client.on('ready', () => { this.logger.info(`Logged in as ${this.client.user.tag}`); + // Start notification service after bot is ready + this.notificationService.start().then(() => { + this.logger.info('Notification service started successfully'); + }).catch(error => { + this.logger.error('Failed to start notification service:', error); + }); }); this.client.on('interactionCreate', this.handleInteraction.bind(this)); diff --git a/src/services/NotificationService.js b/src/services/NotificationService.js index cabbaa7..2b33984 100644 --- a/src/services/NotificationService.js +++ b/src/services/NotificationService.js @@ -1,7 +1,6 @@ - // src/services/NotificationService.js const express = require('express'); -const { createMatchRequestEmbed } = require('../utils/embedBuilders'); +const { createMatchRequestEmbed } = require('../utils/EmbedBuilders'); const { createMatchActionRow } = require('../utils/componentBuilders'); class NotificationService { @@ -57,7 +56,7 @@ class NotificationService { try { const channel = await this.bot.client.channels.fetch(subscription.channel_id); const embed = createMatchRequestEmbed(matchData); - const actionRow = createMatchActionRow(matchData.game_id); + const actionRow = createMatchActionRow(matchData.game_name); await channel.send({ embeds: [embed], diff --git a/src/utils/componentBuilders.js b/src/utils/componentBuilders.js index 7309050..8049b23 100644 --- a/src/utils/componentBuilders.js +++ b/src/utils/componentBuilders.js @@ -15,19 +15,19 @@ const GAME_URLS = { function createMatchActionRow(gameName) { const matchhubUrl = GAME_URLS[gameName] || "https://www.vrbattles.gg/games"; - return new ActionRowBuilder() - .addComponents( - new ButtonBuilder() - .setLabel('View Matchhub') - .setStyle(ButtonStyle.Link) - .setURL(matchhubUrl), - new ButtonBuilder() - .setLabel('Join VRBattles Discord') - .setStyle(ButtonStyle.Link) - .setURL('https://discord.gg/j3DKVATPGQ') - ); + return new ActionRowBuilder().addComponents( + new ButtonBuilder() + .setLabel('🎮 View Matchhub') + .setStyle(ButtonStyle.Link) + .setURL(matchhubUrl), + new ButtonBuilder() + .setLabel('🟡 Join VRBattles Discord') + .setStyle(ButtonStyle.Link) + .setURL('https://discord.gg/j3DKVATPGQ') + ); } module.exports = { - createMatchActionRow + createMatchActionRow, + GAME_URLS }; \ No newline at end of file