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

Commit

Permalink
feat: delete notification on messageDelete (#557)
Browse files Browse the repository at this point in the history
* feat: delete notification on messageDelete

* chore: add interface
  • Loading branch information
Cahllagerfeld authored Jun 23, 2021
1 parent ba3bb2f commit 309e92d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/alexjs/alex.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,21 @@ export class AlexHandler {
// when edit results in no new and no old
return;
}

@On({ event: 'messageDelete' })
onMessageDelete(deletedMessage: Message) {
const deletedNotification = this.savedNotifications.find(
(message: Notifications) =>
message.messageId === deletedMessage.id &&
message.channelId === deletedMessage.channel.id,
);
if (deletedNotification) {
this.savedNotifications = this.savedNotifications.filter(
(notification: Notifications) =>
notification.channelId !== deletedNotification.channelId &&
notification.messageId !== deletedNotification.messageId,
);
}
return;
}
}

0 comments on commit 309e92d

Please sign in to comment.