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

Commit

Permalink
fix: log updates to admin channel
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiejaoude committed May 15, 2024
1 parent 24d3796 commit 65b1a6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ EDDIEBOT_MONGO_CONNECTION_STRING=
DEBUG_HOOK=
HOME_GUILD=
NODE_ENV="development"
ADMIN_CHANNEL=
21 changes: 21 additions & 0 deletions src/events/onUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ export const onUpdate = async (

await checkLinks(bot, newMessage);

// log to admin channel updates
const oldContent = oldMessage.content;
const newContent = newMessage.content;

if (oldContent !== newContent) {
const logChannel = bot.channels.cache.get(process.env.ADMIN_CHANNEL!);

Check warning on line 36 in src/events/onUpdate.ts

View workflow job for this annotation

GitHub Actions / lint

Forbidden non-null assertion

Check warning on line 36 in src/events/onUpdate.ts

View workflow job for this annotation

GitHub Actions / lint

Forbidden non-null assertion
if (logChannel && logChannel.isTextBased()) {
const logEmbed = new EmbedBuilder()
.setTitle(`Message Updated by "${newMessage.author?.username}"`)
.setDescription(`Message updated in ${newMessage.channel} channel`)
.addFields(
{ name: 'Old Message', value: oldContent! },

Check warning on line 42 in src/events/onUpdate.ts

View workflow job for this annotation

GitHub Actions / lint

Forbidden non-null assertion

Check warning on line 42 in src/events/onUpdate.ts

View workflow job for this annotation

GitHub Actions / lint

Forbidden non-null assertion
{ name: 'New Message', value: newContent! },

Check warning on line 43 in src/events/onUpdate.ts

View workflow job for this annotation

GitHub Actions / lint

Forbidden non-null assertion

Check warning on line 43 in src/events/onUpdate.ts

View workflow job for this annotation

GitHub Actions / lint

Forbidden non-null assertion
{ name: 'Author', value: newMessage.author.toString() },
{ name: 'Channel', value: newMessage.channel.toString() },
)
.setTimestamp();
await logChannel.send({ embeds: [logEmbed] });
}
}

try {
const triggeredWarnings: EmbedBuilder[] = [];
const cleaned = await sentenceTypoFixer(
Expand Down

0 comments on commit 65b1a6c

Please sign in to comment.