-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Log bulk message deletes. (#397)
- Loading branch information
Showing
9 changed files
with
61 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
source/library/stores/journalling/discord/message-delete-bulk.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { mention } from "logos:core/formatting"; | ||
import type { EventLogger } from "logos/stores/journalling/loggers"; | ||
import { JournallingStore } from "logos/stores/journalling.ts"; | ||
import { isDefined } from "logos:core/utilities.ts"; | ||
|
||
const logger: EventLogger<"messageDeleteBulk"> = (client, [payload], { guildLocale }) => { | ||
const messages = payload.ids | ||
.toReversed() | ||
.map((messageId) => client.entities.messages.latest.get(messageId)) | ||
.filter(isDefined); | ||
const messageLog = JournallingStore.generateMessageLog(client, { messages }); | ||
|
||
const strings = constants.contexts.messageDeleteBulk({ localise: client.localise, locale: guildLocale }); | ||
return { | ||
embeds: [ | ||
{ | ||
title: `${constants.emojis.events.message.deleted} ${strings.title}`, | ||
color: constants.colours.failure, | ||
description: strings.description({ | ||
messages: client.pluralise("events.messageDeleteBulk.description.messages", guildLocale, { | ||
quantity: messages.length, | ||
}), | ||
channel: mention(payload.channelId, { type: "channel" }), | ||
}), | ||
}, | ||
], | ||
files: [{ name: "log.txt", blob: new Blob([messageLog]) } as Discord.FileContent], | ||
}; | ||
}; | ||
|
||
export default logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters