Skip to content
This repository has been archived by the owner on Oct 10, 2024. It is now read-only.

Commit

Permalink
fix: invalid link deletes message, so stop checking (#813)
Browse files Browse the repository at this point in the history
* fix: invalid link deletes message, so stop checking

* fix: onDelete handles cleanup, so no db work needed in OnUpdate
  • Loading branch information
dan-mba authored Jul 2, 2024
1 parent df216ec commit 450dcf0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/events/onMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const onMessage = async (bot: ExtendedClient, message: Message) => {
await adminChannel.send({
embeds: [linkMessage],
});
return; // Return as message is deleted
}

const cleaned = await sentenceTypoFixer(
Expand Down
11 changes: 10 additions & 1 deletion src/events/onUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,16 @@ export const onUpdate = async (
return;
}

await checkLinks(bot, newMessage);
const linkMessage = await checkLinks(bot, newMessage);
if (linkMessage) {
const adminChannel = bot.channels.cache.get(process.env.ADMIN_CHANNEL!);
if (adminChannel && adminChannel.isTextBased()) {
await adminChannel.send({
embeds: [linkMessage],
});
}
return; // Return as message is deleted
}

// log to admin channel updates
const oldContent = oldMessage.content;
Expand Down

0 comments on commit 450dcf0

Please sign in to comment.