Plugin
OnePingPerDM
If unread messages are sent by a user in DMs multiple times, you'll only receive one audio ping. Read the messages to reset the limit
1
/*2
* FiveCord — a Discord client mod3
* Copyright (c) 2025 FiveCord4
* SPDX-License-Identifier: GPL-3.0-or-later5
*/6
7
import { definePluginSettings } from "@api/Settings";8
import { Devs } from "@utils/constants";9
import definePlugin, { OptionType } from "@utils/types";10
import { MessageJSON } from "@vencord/discord-types";11
import { ChannelType } from "@vencord/discord-types/enums";12
import { ChannelStore, ReadStateStore, UserStore } from "@webpack/common";13
14
const settings = definePluginSettings({15
channelToAffect: {16
type: OptionType.SELECT,17
description: "Select the type of DM for the plugin to affect",18
options: [19
{ label: "Both", value: "both_dms", default: true },20
{ label: "User DMs", value: "user_dm" },21
{ label: "Group DMs", value: "group_dm" },22
]23
},24
allowMentions: {25
type: OptionType.BOOLEAN,26
description: "Receive audio pings for @mentions",27
default: false,28
},29
allowEveryone: {30
type: OptionType.BOOLEAN,31
description: "Receive audio pings for @everyone and @here in group DMs",32
default: false,33
},34
});35
36
export default definePlugin({37
name: "OnePingPerDM",38
description: "If unread messages are sent by a user in DMs multiple times, you039;ll only receive one audio ping. Read the messages to reset the limit",39
tags: ["Notifications", "Customisation"],40
authors: [Devs.FiveCord],41
settings,42
patches: [43
{44
find: ".getDesktopType()===",45
replacement: [46
{47
match: /(\i\.\i\.getDesktopType\(\)===\i\.\i\.NEVER)\)/,48
replace: "$&if(!$self.isPrivateChannelRead(arguments[0]?.message))return;else "49
},50
{51
match: /sound:(\i\?\i:void 0,volume:\i,onClick)/,52
replace: "sound:!$self.isPrivateChannelRead(arguments[0]?.message)?undefined:$1"53
}54
]55
}56
],57
isPrivateChannelRead(message: MessageJSON) {58
const channelType = ChannelStore.getChannel(message.channel_id)?.type;59
if (60
(channelType !== ChannelType.DM && channelType !== ChannelType.GROUP_DM) ||61
(channelType === ChannelType.DM && settings.store.channelToAffect === "group_dm") ||62
(channelType === ChannelType.GROUP_DM && settings.store.channelToAffect === "user_dm") ||63
(settings.store.allowMentions && message.mentions.some(m => m.id === UserStore.getCurrentUser().id)) ||64
(settings.store.allowEveryone && message.mention_everyone)65
) {66
return true;67
}68
return ReadStateStore.getOldestUnreadMessageId(message.channel_id) === message.id;69
},70
});71