Update index.ts

This commit is contained in:
ant0n 2023-11-11 18:04:46 +00:00 committed by GitHub
parent b2ddee9d83
commit 6694e3b8db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
/* /*
* Vencord, a Discord client mod * Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated, MrDiamond, ant0n, and contributors * Copyright (c) 2023 Vendicated, Mr Diamond, ant0n and contributors
* SPDX-License-Identifier: GPL-3.0-or-later * SPDX-License-Identifier: GPL-3.0-or-later
*/ */
@ -28,20 +28,21 @@ export default definePlugin({
{ {
find: "_channelMessages", find: "_channelMessages",
replacement: { replacement: {
match: /receiveMessage\((\i)\)\{/, match: /receiveMessage\((\w+)\)\{/,
replace: "$&$self.modifyMentions($1);" replace: "$&$self.modifyMentions($1);"
} }
} }
], ],
modifyMentions(message: MessageJSON) { modifyMentions(message: MessageJSON) {
const isReplyToCurrentUser = this.isReplyToCurrentUser(message);
if (settings.store.alwaysPingOnReply && isReplyToCurrentUser) {
if (!this.isReplyToCurrentUser(message)) return;
if (settings.store.alwaysPingOnReply) {
if (!message.mentions.some(mention => mention.id === UserStore.getCurrentUser().id)) { if (!message.mentions.some(mention => mention.id === UserStore.getCurrentUser().id)) {
message.mentions.push(this.getCurrentUserMention()); message.mentions.push(this.getCurrentUserMention());
} }
} else if (!settings.store.alwaysPingOnReply && isReplyToCurrentUser) { } else {
message.mentions = message.mentions.filter(mention => mention.id !== UserStore.getCurrentUser().id); message.mentions = message.mentions.filter(mention => mention.id !== UserStore.getCurrentUser().id);
} }