diff --git a/bot.js b/bot.js index 22cdabf..444627d 100644 --- a/bot.js +++ b/bot.js @@ -1726,57 +1726,7 @@ bot.on('callback_query', async (query) => { logError('team_swap error:', e.message); bot.answerCallbackQuery(query.id, { text: 'Fout bij wisselen' }).catch(() => {}); } - } else if (data.startsWith('match_ranked_')) { - const matchId = data.split('_')[2]; - try { - await api('/matches/' + matchId + '/type', 'POST', { match_type: 'ranked' }); - - // Haal spelers en match-info op - const players = await api('/players'); - const matchInfo = await api('/matches/' + matchId); - if (!matchInfo) throw new Error('Match not found'); - - const getName = id => { const p = players.find(x => x.id == id); return p ? p.name : '?'; }; - const t1names = (matchInfo.proposed_teams?.team1 || []).map(getName).join(' + '); - const t2names = (matchInfo.proposed_teams?.team2 || []).map(getName).join(' + '); - - // Update het originele bericht - try { - bot.editMessageText( - '\ud83c\udfbe **Match gevonden!**\n\n\ud83d\udcc5 ' + matchInfo.date + ' ' + matchInfo.start + '\n\n\ud83c\udfc6 **Teams:**\n\ud83d\udfe1 ' + t1names + '\n\ud83d\udf35 ' + t2names + '\n\n\ud83d\udccd ' + (matchInfo.location || '?') + '\n\nType: \ud83d\udfdf **Ranked** — score telt mee voor competitie!', - { - chat_id: query.message.chat.id, - message_id: query.message.message_id, - parse_mode: 'Markdown', - reply_markup: { - inline_keyboard: [ - [{ text: '✅ Ja, ik kan!', callback_data: 'match_accept_' + matchId }, - { text: '❌ Nee', callback_data: 'match_reject_' + matchId }], - [{ text: '🔄 Andere teams', callback_data: 'team_swap_' + matchId }] - ] - } - } - ).catch(() => {}); - } catch(e) { /* ignore edit error */ } - - // Stuur DM naar alle spelers - if (matchInfo && Array.isArray(matchInfo.players)) { - for (const pid of matchInfo.players) { - const p = players.find(x => x.id == pid); - if (p && p.telegram_id) { - sendMsg(p.telegram_id, - '\ud83c\udfc6 **Deze match is nu Ranked!**\n\n' + matchInfo.date + ' ' + matchInfo.start + '\n\n' + t1names + ' vs ' + t2names + '\n\nScore telt mee voor de competitie.\nVergeet niet /score in te voeren na de wedstrijd.', - { parse_mode: 'Markdown' } - ); - } - } - } - - bot.answerCallbackQuery(query.id, { text: 'Ranked!' }).catch(() => {}); - } catch (e) { - logError('match_ranked error:', e.message); - bot.answerCallbackQuery(query.id, { text: 'Fout' }).catch(() => {}); - } + } }); @@ -2043,8 +1993,7 @@ async function runMatching() { inline_keyboard: [ [{ text: '✅ Ja, ik kan!', callback_data: 'match_accept_' + match.id }, { text: '❌ Nee', callback_data: 'match_reject_' + match.id }], - [{ text: '🔄 Andere teams', callback_data: 'team_swap_' + match.id }], - [{ text: '🏆 Maak ranked', callback_data: 'match_ranked_' + match.id }] + [{ text: '🔄 Andere teams', callback_data: 'team_swap_' + match.id }] ] } } @@ -2062,8 +2011,7 @@ async function runMatching() { inline_keyboard: [ [{ text: '✅ Ja, ik kan!', callback_data: 'match_accept_' + match.id }, { text: '❌ Nee', callback_data: 'match_reject_' + match.id }], - [{ text: '🔄 Andere teams', callback_data: 'team_swap_' + match.id }], - [{ text: '🏆 Maak ranked', callback_data: 'match_ranked_' + match.id }] + [{ text: '🔄 Andere teams', callback_data: 'team_swap_' + match.id }] ] } }