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,
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({
@ -86,10 +90,14 @@ export default definePlugin({
patches: [
{
find: "default.Messages.BAN_MULTIPLE_CONFIRM_TITLE",
replacement: {
match: /=\[([^\\]*?)\]/,
replacement: [{
match: /=\[[^]*?\]/,
replace: "=$self.getReasons()"
}
},
{
match: /useState\(0\)/g,
replace: "useState($self.isOtherDefault())"
}]
}
],
getReasons() {
@ -97,5 +105,8 @@ export default definePlugin({
{ name: reason, value: reason }
));
},
isOtherDefault() {
return settings.store.otherOptionDefault ? 1 : 0;
},
settings,
});