mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 15:35:11 +00:00
Use classNameFactory and modernised patches
This commit is contained in:
parent
7fb014ac84
commit
ecf3231b88
1 changed files with 19 additions and 15 deletions
|
@ -7,9 +7,14 @@
|
||||||
import "./styles.css";
|
import "./styles.css";
|
||||||
|
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
|
import { getIntlMessage } from "@utils/discord";
|
||||||
|
import { runtimeHashMessageKey } from "@utils/intlHash";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { Button, Forms, i18n, TextInput } from "@webpack/common";
|
import { Button, Forms, TextInput } from "@webpack/common";
|
||||||
|
|
||||||
|
const cl = classNameFactory("vc-bbr-");
|
||||||
|
|
||||||
function ReasonsComponent() {
|
function ReasonsComponent() {
|
||||||
const { reasons } = settings.use(["reasons"]);
|
const { reasons } = settings.use(["reasons"]);
|
||||||
|
@ -18,11 +23,11 @@ function ReasonsComponent() {
|
||||||
<Forms.FormSection title="Reasons">
|
<Forms.FormSection title="Reasons">
|
||||||
{reasons.map((reason: string, index: number) => (
|
{reasons.map((reason: string, index: number) => (
|
||||||
<div
|
<div
|
||||||
className="vc-bbr-reason-wrapper"
|
key={index}
|
||||||
|
className={cl("reason-wrapper")}
|
||||||
>
|
>
|
||||||
<TextInput
|
<TextInput
|
||||||
type="text"
|
type="text"
|
||||||
key={index}
|
|
||||||
value={reason}
|
value={reason}
|
||||||
onChange={v => {
|
onChange={v => {
|
||||||
reasons[index] = v;
|
reasons[index] = v;
|
||||||
|
@ -32,7 +37,7 @@ function ReasonsComponent() {
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
color={Button.Colors.RED}
|
color={Button.Colors.RED}
|
||||||
className="vc-bbr-remove-button"
|
className={cl("remove-button")}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
reasons.splice(index, 1);
|
reasons.splice(index, 1);
|
||||||
settings.store.reasons = [...reasons];
|
settings.store.reasons = [...reasons];
|
||||||
|
@ -60,7 +65,7 @@ const settings = definePluginSettings({
|
||||||
default: [],
|
default: [],
|
||||||
component: ReasonsComponent,
|
component: ReasonsComponent,
|
||||||
},
|
},
|
||||||
textInputDefault: {
|
isTextInputDefault: {
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: 'Shows a text input instead of a select menu by default. (Equivalent to clicking the "Other" option)'
|
description: 'Shows a text input instead of a select menu by default. (Equivalent to clicking the "Other" option)'
|
||||||
}
|
}
|
||||||
|
@ -72,9 +77,9 @@ export default definePlugin({
|
||||||
authors: [Devs.Inbestigator],
|
authors: [Devs.Inbestigator],
|
||||||
patches: [
|
patches: [
|
||||||
{
|
{
|
||||||
find: "Messages.BAN_MULTIPLE_CONFIRM_TITLE",
|
find: "." + runtimeHashMessageKey("BAN_MULTIPLE_CONFIRM_TITLE"),
|
||||||
replacement: [{
|
replacement: [{
|
||||||
match: /\[\{name:\i\.\i\.Messages\.BAN_REASON_OPTION_SPAM_ACCOUNT.+?\}\]/,
|
match: /\[(\{((?:name|value):\i\.intl\.string\(\i\.\i\.[A-Za-z0-9]+\),?){2}\},?){3}\]/,
|
||||||
replace: "$self.getReasons()"
|
replace: "$self.getReasons()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -84,17 +89,16 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
getReasons() {
|
getReasons() {
|
||||||
const reasons = settings.store.reasons.length
|
const storedReasons = settings.store.reasons.filter((r: string) => r.trim());
|
||||||
? settings.store.reasons
|
const reasons: string[] = storedReasons.length
|
||||||
|
? storedReasons
|
||||||
: [
|
: [
|
||||||
i18n.Messages.BAN_REASON_OPTION_SPAM_ACCOUNT,
|
getIntlMessage("BAN_REASON_OPTION_SPAM_ACCOUNT"),
|
||||||
i18n.Messages.BAN_REASON_OPTION_HACKED_ACCOUNT,
|
getIntlMessage("BAN_REASON_OPTION_HACKED_ACCOUNT"),
|
||||||
i18n.Messages.BAN_REASON_OPTION_BREAKING_RULES
|
getIntlMessage("BAN_REASON_OPTION_BREAKING_RULES"),
|
||||||
];
|
];
|
||||||
return reasons.map(s => ({ name: s, value: s }));
|
return reasons.map(s => ({ name: s, value: s }));
|
||||||
},
|
},
|
||||||
getDefaultState() {
|
getDefaultState: () => settings.store.isTextInputDefault ? 1 : 0,
|
||||||
return settings.store.textInputDefault ? 1 : 0;
|
|
||||||
},
|
|
||||||
settings,
|
settings,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue