File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,7 @@ import {
55 PermissionFlagsBits ,
66 SlashCommandBuilder ,
77} from 'discord.js'
8- import {
9- getMatchIdFromChannel ,
10- getUsersInMatch ,
11- getUserTeam ,
12- } from '../../utils/queryDB'
8+ import { getUsersInMatch , getUserTeam } from '../../utils/queryDB'
139import { pool } from '../../db'
1410import { endMatch } from '../../utils/matchHelpers'
1511
@@ -38,11 +34,11 @@ export default {
3834 ) ,
3935 async execute ( interaction : ChatInputCommandInteraction ) {
4036 try {
41- const matchId = await getMatchIdFromChannel ( interaction . channelId )
37+ const matchId = interaction . options . getInteger ( 'match-id' )
4238 const userId = interaction . options . getString ( 'user' , true )
4339 if ( ! matchId ) {
4440 await interaction . reply ( {
45- content : 'No active match found in this channel .' ,
41+ content : 'No match found.' ,
4642 flags : MessageFlags . Ephemeral ,
4743 } )
4844 return
Original file line number Diff line number Diff line change @@ -60,8 +60,16 @@ export async function partyDeleteCronJob() {
6060// increment elo search globally across all queues
6161export async function incrementEloCronJobAllQueues ( ) {
6262 const speedDefault = 2
63+ let isRunning = false
6364
6465 setInterval ( async ( ) => {
66+ // Skip this iteration if the previous one is still running
67+ if ( isRunning ) {
68+ console . log ( 'Matchmaking already running, skipping this iteration' )
69+ return
70+ }
71+
72+ isRunning = true
6573 try {
6674 // get all active queues
6775 const activeQueues = await getActiveQueues ( )
@@ -166,6 +174,9 @@ export async function incrementEloCronJobAllQueues() {
166174 }
167175 } catch ( err ) {
168176 console . error ( 'Error in global matchmaking:' , err )
177+ } finally {
178+ // Always release the lock, even if an error occurred
179+ isRunning = false
169180 }
170181 } , speedDefault * 1000 )
171182}
You can’t perform that action at this time.
0 commit comments