mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 23:38:32 +00:00
Update src/plugins/replyPingControl/index.ts
Co-authored-by: rini <nil@dissoc.cc>
This commit is contained in:
parent
cab9e55f3c
commit
c5fb9f8f24
1 changed files with 16 additions and 25 deletions
|
@ -24,37 +24,28 @@ export default definePlugin({
|
||||||
authors: [Devs.ant0n, Devs.MrDiamond],
|
authors: [Devs.ant0n, Devs.MrDiamond],
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
patches: [
|
patches: [{
|
||||||
{
|
|
||||||
find: "_channelMessages",
|
find: "_channelMessages",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /receiveMessage\((\i)\)\{/,
|
match: /receiveMessage\((\i)\)\{/,
|
||||||
replace: "$&$self.modifyMentions($1);"
|
replace: "$&$self.modifyMentions($1);"
|
||||||
}
|
}
|
||||||
}
|
}],
|
||||||
],
|
|
||||||
|
|
||||||
modifyMentions(message: MessageJSON) {
|
modifyMentions(message: MessageJSON) {
|
||||||
|
const user = UserStore.getCurrentUser();
|
||||||
|
|
||||||
if (!this.isReplyToCurrentUser(message)) return;
|
if (this.getRepliedMessage(message)?.author.id !== user.id)
|
||||||
|
return;
|
||||||
|
|
||||||
if (settings.store.alwaysPingOnReply) {
|
if (!settings.store.alwaysPingOnReply)
|
||||||
if (!message.mentions.some(mention => mention.id === UserStore.getCurrentUser().id)) {
|
message.mentions = message.mentions.filter(mention => mention.id !== user.id);
|
||||||
message.mentions.push(this.getCurrentUserMention());
|
else if (!message.mentions.some(mention => mention.id === user.id))
|
||||||
}
|
message.mentions.push(user as any);
|
||||||
} else {
|
|
||||||
|
|
||||||
message.mentions = message.mentions.filter(mention => mention.id !== UserStore.getCurrentUser().id);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isReplyToCurrentUser(message: MessageJSON) {
|
getRepliedMessage(message: MessageJSON) {
|
||||||
if (!message.message_reference) return false;
|
const ref = message.message_reference;
|
||||||
const repliedMessage = MessageStore.getMessage(message.channel_id, message.message_reference.message_id);
|
return ref && MessageStore.getMessage(ref.channel_id, ref.message_id);
|
||||||
return repliedMessage && repliedMessage.author.id === UserStore.getCurrentUser().id;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getCurrentUserMention() {
|
|
||||||
return UserStore.getCurrentUser() as unknown as UserJSON;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue