Patch Fixes

This commit is contained in:
thororen1234 2025-04-10 21:45:23 -04:00
parent 02d34de59b
commit db3186d607
No known key found for this signature in database
4 changed files with 59 additions and 45 deletions

View file

@ -45,13 +45,6 @@ export default definePlugin({
replace: "return $1;"
}
]
},
{
find: '"Slate: Unable to find syntax characters"',
replacement: {
match: /((let )(\i)=\i\.indexOf\(\i,(\i)\)),/,
replace: "$1;if ($3 === -1) {return $4;}$2"
}
}
]
});

View file

@ -4,53 +4,55 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import "./style.css";
import "./styles.css";
import { definePluginSettings } from "@api/Settings";
import { classNameFactory } from "@api/Styles";
import { DeleteIcon, PlusIcon } from "@components/Icons";
import { Devs } from "@utils/constants";
import { getIntlMessage } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types";
import { Button, Forms, TextInput } from "@webpack/common";
const cl = classNameFactory("vc-bbr-");
function ReasonsComponent() {
const { reasons } = settings.use(["reasons"]);
const { reasons } = settings.store;
return (
<Forms.FormSection title="Reasons">
{reasons.map((reason: string, index: number) => (
{reasons.map((r, i) => (
<div
className="vc-bbr-reason-wrapper"
key={index}
key={i}
className={cl("reason-wrapper")}
>
<TextInput
type="text"
key={index}
value={reason}
value={r}
onChange={v => {
reasons[index] = v;
settings.store.reasons = [...reasons];
reasons[i] = v;
settings.store.reasons = reasons;
}}
placeholder="Reason"
/>
<Button
color={Button.Colors.RED}
className="vc-bbr-remove-button"
className={cl("remove-button")}
color={Button.Colors.TRANSPARENT}
onClick={() => {
reasons.splice(index, 1);
settings.store.reasons = [...reasons];
reasons.splice(i, 1);
settings.store.reasons = reasons;
}}
look={Button.Looks.BLANK}
size={Button.Sizes.MIN}
>
Remove
<DeleteIcon />
</Button>
</div>
))}
<Button
onClick={() => {
settings.store.reasons = [...reasons, ""];
}}
>
Add new
</Button>
<div className={cl("reason-wrapper")}>
<Button onClick={() => settings.store.reasons.push("")} className={cl("add-button")} size={Button.Sizes.LARGE} color={Button.Colors.TRANSPARENT}>
<PlusIcon /> Add another reason
</Button>
</div>
</Forms.FormSection>
);
}
@ -59,10 +61,10 @@ const settings = definePluginSettings({
reasons: {
description: "Your custom reasons",
type: OptionType.COMPONENT,
default: [""],
default: [] as string[],
component: ReasonsComponent,
},
textInputDefault: {
isTextInputDefault: {
type: OptionType.BOOLEAN,
description: 'Shows a text input instead of a select menu by default. (Equivalent to clicking the "Other" option)'
}
@ -74,9 +76,9 @@ export default definePlugin({
authors: [Devs.Inbestigator],
patches: [
{
find: "#{intl::BAN_MULTIPLE_CONFIRM_TITLE}",
find: "#{intl::BAN_REASON_OPTION_SPAM_ACCOUNT}",
replacement: [{
match: /\[\{name:\i\.\i\.string\(\i\.\i#{intl::BAN_REASON_OPTION_SPAM_ACCOUNT}\).+?\}\]/,
match: /\[(\{((name|value):\i\.\i\.string\(\i\.\i\.\i\),?){2}\},?){3}\]/,
replace: "$self.getReasons()"
},
{
@ -86,17 +88,16 @@ export default definePlugin({
}
],
getReasons() {
const reasons = settings.store.reasons.length
? settings.store.reasons
const storedReasons = settings.store.reasons.filter((r: string) => r.trim());
const reasons: string[] = storedReasons.length
? storedReasons
: [
getIntlMessage("BAN_REASON_OPTION_SPAM_ACCOUNT"),
getIntlMessage("BAN_REASON_OPTION_HACKED_ACCOUNT"),
getIntlMessage("BAN_REASON_OPTION_BREAKING_RULES")
getIntlMessage("BAN_REASON_OPTION_BREAKING_RULES"),
];
return reasons.map(s => ({ name: s, value: s }));
},
getDefaultState() {
return settings.store.textInputDefault ? 1 : 0;
},
getDefaultState: () => settings.store.isTextInputDefault ? 1 : 0,
settings,
});

View file

@ -1,11 +1,31 @@
.vc-bbr-reason-wrapper {
display: grid;
padding: 0;
padding-bottom: 0.5rem;
gap: 0.5rem;
grid-template-columns: 6fr 1fr;
padding-bottom: 12px;
gap: 4px 12px;
align-items: center;
grid-template-columns: 1fr 24px;
}
.vc-bbr-remove-button {
height: 100%;
color: var(--text-muted);
}
.vc-bbr-remove-button:hover {
color: var(--button-danger-background-hover);
}
.vc-bbr-add-button {
justify-content: start !important;
border: 0;
padding: 2px 12px;
color: var(--text-muted) !important;
font-size: 16px;
}
.vc-bbr-add-button div {
display: flex;
justify-content: start;
align-items: center;
gap: 12px;
margin: 0 !important;
}

View file

@ -36,7 +36,7 @@ export default definePlugin({
settings,
patches: [
{
find: "#{intl::BAN_CONFIRM_TITLE}",
find: "#{intl::BAN_REASON_OPTION_SPAM_ACCOUNT}",
replacement: {
match: /src:\i\("?\d+"?\)/g,
replace: "src:$self.source"