Skip to content

Commit e10e68c

Browse files
committed
fix(xp): 🔊 add logging and check for edge case when calculating xp
1 parent aabce94 commit e10e68c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/modules/xp/xpForMessage.util.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ export async function shouldCountForStats(
8080
return true; // this probably won't happen
8181
}
8282
for (const msg of messages) {
83+
if (!msg) {
84+
logger.warn(
85+
`Message in cache is undefined, skipping similarity check`,
86+
messages,
87+
);
88+
continue;
89+
}
90+
if (!msg.author) {
91+
logger.warn(
92+
`Message in cache has no author, skipping similarity check`,
93+
msg,
94+
);
95+
continue;
96+
}
8397
if (msg.author.id !== author.id || msg.id === message.id) continue;
8498
if (similarityProportion(msg.content, message.content) > maxSimilarity) {
8599
logger.debug(

0 commit comments

Comments
 (0)