This commit is contained in:
thororen1234 2024-06-01 14:32:22 -04:00
parent 268e053d68
commit 7da91d94d8
77 changed files with 3175 additions and 1964 deletions

View file

@ -1,17 +1,15 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2023 Vendicated and contributors
* Copyright (c) 2023 Vendicated, MrDiamond, ant0n, and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { definePluginSettings } from "@api/Settings";
import { Devs, EquicordDevs } from "@utils/constants";
import definePlugin, { OptionType } from "@utils/types";
import { MessageStore, showToast, UserStore } from "@webpack/common";
import { MessageStore, UserStore } from "@webpack/common";
import { MessageJSON } from "discord-types/general";
let cachedWhitelist: string[] = [];
export const settings = definePluginSettings({
alwaysPingOnReply: {
type: OptionType.BOOLEAN,
@ -23,20 +21,6 @@ export const settings = definePluginSettings({
description: "Comma-separated list of User IDs to always receive reply pings from",
default: "",
disabled: () => settings.store.alwaysPingOnReply,
onChange: newValue => {
const originalIDs = newValue.split(",")
.map(id => id.trim())
.filter(id => id !== "");
const isInvalid = originalIDs.some(id => !isValidUserId(id));
if (isInvalid) {
showToast("Invalid User ID: One or more User IDs in the whitelist are invalid. Please check your input.");
} else {
cachedWhitelist = originalIDs;
showToast("Whitelist Updated: Reply ping whitelist has been successfully updated.");
}
}
}
});
@ -56,18 +40,18 @@ export default definePlugin({
modifyMentions(message: MessageJSON) {
const user = UserStore.getCurrentUser();
if (message.author.id === user.id)
return;
if (message.author.id === user.id) return;
const repliedMessage = this.getRepliedMessage(message);
if (!repliedMessage || repliedMessage.author.id !== user.id)
return;
if (!repliedMessage || repliedMessage.author.id !== user.id) return;
const isWhitelisted = cachedWhitelist.includes(message.author.id);
const whitelist = settings.store.replyPingWhitelist.split(",").map(id => id.trim());
const isWhitelisted = settings.store.replyPingWhitelist.includes(message.author.id);
if (isWhitelisted || settings.store.alwaysPingOnReply) {
if (!message.mentions.some(mention => mention.id === user.id))
if (!message.mentions.some(mention => mention.id === user.id)) {
message.mentions.push(user as any);
}
} else {
message.mentions = message.mentions.filter(mention => mention.id !== user.id);
}
@ -78,13 +62,3 @@ export default definePlugin({
return ref && MessageStore.getMessage(ref.channel_id, ref.message_id);
},
});
function parseWhitelist(value: string) {
return value.split(",")
.map(id => id.trim())
.filter(id => id !== "");
}
function isValidUserId(id: string) {
return /^\d+$/.test(id);
}