if (baseEntry.characterName) { console.log(`[vote] voteId=${voteId} yes keys:`, [...state.yes.keys()], 'no keys:', [...state.no.keys()]); for (const [otherId, entry] of [...state.yes.entries(), ...state.no.entries()]) { if (otherId !== userId && entry.characterName === baseEntry.characterName) { // Check if this user is the owner of the character const borrowerKey = entry.borrowedFrom ? entry.userKey : null; const ownerKey = entry.borrowedFrom ?? entry.userKey; const isOwner = user.userKey === ownerKey; console.log(`[conflict] user.userKey=${user.userKey} entry.userKey=${entry.userKey} borrowedFrom=${entry.borrowedFrom} ownerKey=${ownerKey} isOwner=${isOwner}`); if (isOwner && baseEntry.userKey) { // Owner trying to reclaim — show conflict embed const allChars = getCharacters(baseEntry.userKey); const borrowedChar = allChars.find((c) => c.name === baseEntry.characterName); if (borrowedChar) { await showConflictEmbed(interaction, baseEntry.userKey, entry.userKey, borrowedChar, allChars); return; } } await pollReplyAndDelete(interaction, `❌ **${baseEntry.characterName}** is already in the poll by another player.` ); return; } } } if (votedYes) { const previousNo = state.no.get(voteId); state.no.delete(voteId); state.yes.set(voteId, { ...baseEntry, votedAt: now, previousNoAt: previousNo?.votedAt, publicMessage: publicMsg ?? undefined, }); } else { const previousYes = state.yes.get(voteId); state.yes.delete(voteId); state.no.set(voteId, { ...baseEntry, votedAt: now, previousYesAt: previousYes?.votedAt, publicMessage: publicMsg ?? undefined, }); }