mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 23:38:32 +00:00
Added README.md
Added index.ts Added MrDiamond to Devs
This commit is contained in:
parent
96126fa39f
commit
a7d9fdb1bf
3 changed files with 73 additions and 0 deletions
10
src/plugins/replyPingControl/README.md
Normal file
10
src/plugins/replyPingControl/README.md
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
# ReplyPingControl
|
||||||
|
|
||||||
|
Overrides notification settings for received reply pings to either always notify, or never notify.
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
- **Enabled**: You will always be notified when someone replies to your messages, regardless of if the sender has reply pings enabled.
|
||||||
|
- **Disabled (Default)**: You will not receive notification pings for replies, regardless of if the sender has reply pings enabled.
|
||||||
|
|
||||||
|
## License
|
||||||
|
This project is licensed under the GPL-3.0-or-later License - see file for details.
|
59
src/plugins/replyPingControl/index.ts
Normal file
59
src/plugins/replyPingControl/index.ts
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2023 Vendicated, Mr Diamond, ant0n and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
|
import { MessageStore, UserStore } from "@webpack/common";
|
||||||
|
|
||||||
|
export const settings = definePluginSettings({
|
||||||
|
alwaysPingOnReply: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Always get pinged when someone replies to your messages",
|
||||||
|
default: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "ReplyPingControl",
|
||||||
|
description: "Control whether to always or never get pinged on message replies",
|
||||||
|
authors: [Devs.ant0n, Devs.MrDiamond],
|
||||||
|
settings,
|
||||||
|
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: "_channelMessages",
|
||||||
|
replacement: {
|
||||||
|
match: /receiveMessage\((\w+)\)\{/,
|
||||||
|
replace: "$&$self.modifyMentions($1);"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
modifyMentions(message) {
|
||||||
|
const isReplyToCurrentUser = this.isReplyToCurrentUser(message);
|
||||||
|
if (settings.store.alwaysPingOnReply && isReplyToCurrentUser) {
|
||||||
|
|
||||||
|
if (!message.mentions.some(mention => mention.id === UserStore.getCurrentUser().id)) {
|
||||||
|
message.mentions.push(this.getCurrentUserMention());
|
||||||
|
}
|
||||||
|
} else if (!settings.store.alwaysPingOnReply && isReplyToCurrentUser) {
|
||||||
|
|
||||||
|
message.mentions = message.mentions.filter(mention => mention.id !== UserStore.getCurrentUser().id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
isReplyToCurrentUser(message) {
|
||||||
|
if (!message.message_reference) return false;
|
||||||
|
const repliedMessage = MessageStore.getMessage(message.channel_id, message.message_reference.message_id);
|
||||||
|
return repliedMessage && repliedMessage.author.id === UserStore.getCurrentUser().id;
|
||||||
|
},
|
||||||
|
|
||||||
|
getCurrentUserMention() {
|
||||||
|
const currentUser = UserStore.getCurrentUser();
|
||||||
|
return { id: currentUser.id, username: currentUser.username, discriminator: currentUser.discriminator };
|
||||||
|
}
|
||||||
|
});
|
|
@ -383,6 +383,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "ant0n",
|
name: "ant0n",
|
||||||
id: 145224646868860928n
|
id: 145224646868860928n
|
||||||
},
|
},
|
||||||
|
MrDiamond: {
|
||||||
|
name: "MrDiamond",
|
||||||
|
id: 523338295644782592n
|
||||||
|
}
|
||||||
} satisfies Record<string, Dev>);
|
} satisfies Record<string, Dev>);
|
||||||
|
|
||||||
// iife so #__PURE__ works correctly
|
// iife so #__PURE__ works correctly
|
||||||
|
|
Loading…
Add table
Reference in a new issue