Remove member repetition bugfixes

This commit is contained in:
Cadence Ember
2026-03-20 00:17:40 +13:00
parent e8d9a5e4ae
commit 8c87d93011
2 changed files with 13 additions and 1 deletions

View File

@@ -19,7 +19,18 @@ async function removeMember(userID, guildID) {
}
})()
for (const m of membership) {
await api.leaveRoom(m.room_id, m.mxid)
try {
await api.leaveRoom(m.room_id, m.mxid)
} catch (e) {
if (String(e).includes("not in room")) {
// no further action needed
} else {
throw e
}
}
// Update cache to say that the member isn't in the room any more
// You'd think this would happen automatically when the leave event arrives at Matrix's event dispatcher, but that isn't 100% reliable.
db.prepare("DELETE FROM sim_member WHERE room_id = ? AND mxid = ?").run(m.room_id, m.mxid)
}
}

View File

@@ -125,6 +125,7 @@ module.exports = {
// Send in order
for (let i = Math.min(messages.length, latestBridgedMessageIndex)-1; i >= 0; i--) {
const message = messages[i]
if (message.type === DiscordTypes.MessageType.UserJoin) continue // since join announcements don't become events, it would be a repetition to act on them during backfill
if (!members.has(message.author.id)) members.set(message.author.id, await client.snow.guild.getGuildMember(guild.id, message.author.id).catch(() => undefined))
await module.exports.MESSAGE_CREATE(client, {