From 9f16367673245773bb57e05f2b43943517a3c0af Mon Sep 17 00:00:00 2001 From: fearandesire Date: Sun, 29 Dec 2024 15:47:48 -0500 Subject: [PATCH] fix: sport keys to match guild config sport --- src/utils/guilds/channels/ChannelManager.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/utils/guilds/channels/ChannelManager.ts b/src/utils/guilds/channels/ChannelManager.ts index 8727ae20..9fa6109d 100644 --- a/src/utils/guilds/channels/ChannelManager.ts +++ b/src/utils/guilds/channels/ChannelManager.ts @@ -72,15 +72,19 @@ export default class ChannelManager { */ async processChannels(data: ScheduledChannelsData) { const { channels, guilds } = data; - + // ? Transform Sport Key in all Channels + const transformedChannels = channels.map((channel) => ({ + ...channel, + sport: StringUtils.sportKeyTransform(channel.sport) as SportsServing, + })); // Process each guild separately for (const guild of guilds) { - const eligibleChannels = _.chain(channels) + const eligibleChannels = _.chain(transformedChannels) // First filter by sport .filter((channel) => channel.sport === guild.sport) // Then filter by preferred teams if they exist .filter((channel) => { - if (!guild.preferred_teams?.length) return true; + if (!guild?.preferred_teams?.length) return true; const teamsInMatch = [channel.home_team, channel.away_team]; return _.some(guild.preferred_teams, (team) =>