| 97 | } |
| 98 | }; |
| 99 | const updateReactions = async () => { |
| 100 | await db.delete(dbReactions).where(eq(dbReactions.messageId, msg.id)); |
| 101 | if (!reactions) return; |
| 102 | const emojis = new Set(reactions.map((r) => r.emoji)); |
| 103 | for await (const emoji of emojis) { |
| 104 | const p = emojiSchema.parse(emoji); |
| 105 | await db.insert(dbEmojis).values(p).onDuplicateKeyUpdate({ |
| 106 | set: p, |
| 107 | }); |
| 108 | } |
| 109 | for await (const reaction of reactions) { |
| 110 | const p = reactionSchema.parse(reaction); |
| 111 | await db.insert(dbReactions).values(p).onDuplicateKeyUpdate({ |
| 112 | set: p, |
| 113 | }); |
| 114 | } |
| 115 | }; |
| 116 | await updateReactions(); |
| 117 | void updateAttachments(); |
| 118 | } |