Updated regex and added option to use other option by default

This commit is contained in:
Inbestigator 2024-06-09 16:12:21 -07:00
parent ddd883b988
commit 8208b528c0

View file

@ -77,6 +77,10 @@ const settings = definePluginSettings({
type: OptionType.COMPONENT, type: OptionType.COMPONENT,
component: ReasonsComponent, component: ReasonsComponent,
}, },
otherOptionDefault: {
type: OptionType.BOOLEAN,
description: 'Shows a text input instead of a select menu by default. (Equivalent to clicking the "Other" option)'
}
}); });
export default definePlugin({ export default definePlugin({
@ -86,10 +90,14 @@ export default definePlugin({
patches: [ patches: [
{ {
find: "default.Messages.BAN_MULTIPLE_CONFIRM_TITLE", find: "default.Messages.BAN_MULTIPLE_CONFIRM_TITLE",
replacement: { replacement: [{
match: /=\[([^\\]*?)\]/, match: /=\[[^]*?\]/,
replace: "=$self.getReasons()" replace: "=$self.getReasons()"
} },
{
match: /useState\(0\)/g,
replace: "useState($self.isOtherDefault())"
}]
} }
], ],
getReasons() { getReasons() {
@ -97,5 +105,8 @@ export default definePlugin({
{ name: reason, value: reason } { name: reason, value: reason }
)); ));
}, },
isOtherDefault() {
return settings.store.otherOptionDefault ? 1 : 0;
},
settings, settings,
}); });