mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 23:38:32 +00:00
Fixed validation fail if at least one ID was valid
This commit is contained in:
parent
400e9705e5
commit
4ac6d97ec8
1 changed files with 5 additions and 4 deletions
|
@ -24,12 +24,13 @@ export const settings = definePluginSettings({
|
||||||
default: "",
|
default: "",
|
||||||
disabled: () => settings.store.alwaysPingOnReply,
|
disabled: () => settings.store.alwaysPingOnReply,
|
||||||
onChange: newValue => {
|
onChange: newValue => {
|
||||||
const newWhitelist = parseWhitelist(newValue);
|
const originalIDs = newValue.split(",").map(id => id.trim()).filter(id => id !== "");
|
||||||
|
const validatedIDs = originalIDs.filter(isValidUserId);
|
||||||
|
|
||||||
if (newWhitelist.length === 0 && newValue.trim() !== "") {
|
if (originalIDs.length !== validatedIDs.length) {
|
||||||
showToast("Invalid User ID: One or more User IDs in the whitelist are invalid. Please check your input.");
|
showToast("Invalid User ID: One or more User IDs in the whitelist are invalid. Please check your input.");
|
||||||
} else {
|
} else {
|
||||||
cachedWhitelist = newWhitelist;
|
cachedWhitelist = validatedIDs;
|
||||||
showToast("Whitelist Updated: Reply ping whitelist has been successfully updated.");
|
showToast("Whitelist Updated: Reply ping whitelist has been successfully updated.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +79,7 @@ export default definePlugin({
|
||||||
function parseWhitelist(value: string) {
|
function parseWhitelist(value: string) {
|
||||||
return value.split(",")
|
return value.split(",")
|
||||||
.map(id => id.trim())
|
.map(id => id.trim())
|
||||||
.filter(id => id !== "" && isValidUserId(id));
|
.filter(id => id !== "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidUserId(id: string) {
|
function isValidUserId(id: string) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue