-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Plugin] ReplyPingControl #1975
base: main
Are you sure you want to change the base?
Changes from 6 commits
a7d9fdb
1c047ae
f71bcef
66b49a2
5026f3f
5d2cefb
b2ddee9
6694e3b
cab9e55
c5fb9f8
fb6cdc0
27660e1
de38925
b789094
e5ffb34
191bb3c
c65f3db
df0a29f
0e494fc
400e970
4ac6d97
b20501d
ef4ab95
5b2fe0a
a9a4d19
4b02352
3afece4
338b969
90608ab
f4fca14
60f1416
97f7f97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this line is redundant and can be removed. was this maybe added due to being in a third party repo? unless you deliberately want it here, then you can leave it, but i would suggest adding your name |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Vencord, a Discord client mod | ||
* Copyright (c) 2023 Vendicated, MrDiamond, 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"; | ||
|
||
ant0n-0x0000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
export const settings = definePluginSettings({ | ||
alwaysPingOnReply: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think it would be better to change this to a select between the following 3 options:
this way people won't enable this plugin then cry that they never get notifications, and it also allows you to use the plugin to just enable reply pings for individual people who always turn it off without changing behaviour for other people's replies |
||
type: OptionType.BOOLEAN, | ||
description: "Always get pinged when someone replies to your messages", | ||
default: false, | ||
ant0n-0x0000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
}); | ||
|
||
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\((\i)\)\{/, | ||
replace: "$&$self.modifyMentions($1);" | ||
} | ||
} | ||
], | ||
|
||
modifyMentions(message: MessageJSON) { | ||
const isReplyToCurrentUser = this.isReplyToCurrentUser(message); | ||
if (settings.store.alwaysPingOnReply && isReplyToCurrentUser) { | ||
|
||
ant0n-0x0000 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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: MessageJSON) { | ||
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() { | ||
return UserStore.getCurrentUser() as unknown as UserJSON; | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or something like that