feat(MessageLogger): add option to ignore channels and guilds (#1420)

This commit is contained in:
Luca Zeuch 2023-07-14 18:21:29 +02:00 committed by GitHub
parent 2bf0c324d7
commit 1340f023a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -152,14 +152,24 @@ export default definePlugin({
type: OptionType.STRING, type: OptionType.STRING,
description: "Comma-separated list of user IDs to ignore", description: "Comma-separated list of user IDs to ignore",
default: "" default: ""
} },
ignoreChannels: {
type: OptionType.STRING,
description: "Comma-separated list of channel IDs to ignore",
default: ""
},
ignoreGuilds: {
type: OptionType.STRING,
description: "Comma-separated list of guild IDs to ignore",
default: ""
},
}, },
handleDelete(cache: any, data: { ids: string[], id: string; mlDeleted?: boolean; }, isBulk: boolean) { handleDelete(cache: any, data: { ids: string[], id: string; mlDeleted?: boolean; }, isBulk: boolean) {
try { try {
if (cache == null || (!isBulk && !cache.has(data.id))) return cache; if (cache == null || (!isBulk && !cache.has(data.id))) return cache;
const { ignoreBots, ignoreSelf, ignoreUsers } = Settings.plugins.MessageLogger; const { ignoreBots, ignoreSelf, ignoreUsers, ignoreChannels, ignoreGuilds } = Settings.plugins.MessageLogger;
const myId = UserStore.getCurrentUser().id; const myId = UserStore.getCurrentUser().id;
function mutate(id: string) { function mutate(id: string) {
@ -171,7 +181,9 @@ export default definePlugin({
(msg.flags & EPHEMERAL) === EPHEMERAL || (msg.flags & EPHEMERAL) === EPHEMERAL ||
ignoreBots && msg.author?.bot || ignoreBots && msg.author?.bot ||
ignoreSelf && msg.author?.id === myId || ignoreSelf && msg.author?.id === myId ||
ignoreUsers.includes(msg.author?.id); ignoreUsers.includes(msg.author?.id) ||
ignoreChannels.includes(msg.channel_id) ||
ignoreGuilds.includes(msg.guild_id);
if (shouldIgnore) { if (shouldIgnore) {
cache = cache.remove(id); cache = cache.remove(id);