diff --git a/config.json b/config.json index 797c371..d9e370e 100644 --- a/config.json +++ b/config.json @@ -30,7 +30,8 @@ { "leagueId": "4370", "notifyRoleId": "1244253264787279873", - "channelId": "565267644627025930" + "channelId": "565267644627025930", + "excludedWords": ["practice"] }, { "leagueId": "4407", diff --git a/index.ts b/index.ts index eb637fa..142f409 100644 --- a/index.ts +++ b/index.ts @@ -29,6 +29,7 @@ interface ConfigLeague { leagueId: string; notifyRoleId: string; channelId: string; + excludedWords?: string[]; } type Game = { @@ -80,13 +81,13 @@ async function checkUpcomingGames() { }); const leaguePromises = (config?.leagues || []).map(async (league) => { - await fetchUpcomingLeagueEvents(league.leagueId, league.notifyRoleId, league.channelId); + await fetchUpcomingLeagueEvents(league.leagueId, league.notifyRoleId, league.channelId, league.excludedWords); }); await Promise.all([...teamPromises, ...leaguePromises]); } -async function fetchUpcomingLeagueEvents(leagueId: string, notifyRoleId: string, leagueChannelId: string) { +async function fetchUpcomingLeagueEvents(leagueId: string, notifyRoleId: string, leagueChannelId: string, excludedWords?: string[]) { try { const url=`https://www.thesportsdb.com/api/v1/json/${SPORTSDB_API_KEY}/eventsnextleague.php?id=${leagueId}`; const response = await fetch(url); @@ -95,6 +96,14 @@ async function fetchUpcomingLeagueEvents(leagueId: string, notifyRoleId: string, if (events && events.length > 0) { for (const event of events) { + + if (excludedWords && excludedWords.length > 0) { + const excluded = excludedWords.some(word => event.strEvent.toLowerCase().includes(word.toLowerCase())); + if (excluded) { + continue; + } + } + const gameDate = new Date(event.dateEvent + ' ' + event.strTime); const game = { eventId: event.idEvent,