use isTrueBoolean on all bools

This commit is contained in:
LenAnderson
2024-01-16 22:40:40 +00:00
parent 9f4ae351db
commit 1a50c9f976

View File

@ -91,14 +91,14 @@ export class SlashCommandHandler {
toggleGlobalSet(name, args = {}) { toggleGlobalSet(name, args = {}) {
try { try {
this.api.toggleGlobalSet(name, JSON.parse(args.visible ?? 'true') === true); this.api.toggleGlobalSet(name, isTrueBoolean(args.visible ?? 'true'));
} catch (ex) { } catch (ex) {
toastr.error(ex.message); toastr.error(ex.message);
} }
} }
addGlobalSet(name, args = {}) { addGlobalSet(name, args = {}) {
try { try {
this.api.addGlobalSet(name, JSON.parse(args.visible ?? 'true') === true); this.api.addGlobalSet(name, isTrueBoolean(args.visible ?? 'true'));
} catch (ex) { } catch (ex) {
toastr.error(ex.message); toastr.error(ex.message);
} }
@ -114,14 +114,14 @@ export class SlashCommandHandler {
toggleChatSet(name, args = {}) { toggleChatSet(name, args = {}) {
try { try {
this.api.toggleChatSet(name, JSON.parse(args.visible ?? 'true') === true); this.api.toggleChatSet(name, isTrueBoolean(args.visible ?? 'true'));
} catch (ex) { } catch (ex) {
toastr.error(ex.message); toastr.error(ex.message);
} }
} }
addChatSet(name, args = {}) { addChatSet(name, args = {}) {
try { try {
this.api.addChatSet(name, JSON.parse(args.visible ?? 'true') === true); this.api.addChatSet(name, isTrueBoolean(args.visible ?? 'true'));
} catch (ex) { } catch (ex) {
toastr.error(ex.message); toastr.error(ex.message);
} }
@ -143,11 +143,11 @@ export class SlashCommandHandler {
{ {
message: message ?? '', message: message ?? '',
title: args.title, title: args.title,
isHidden: JSON.parse(args.hidden ?? 'false') === true, isHidden: isTrueBoolean(args.hidden),
executeOnStartup: JSON.parse(args.startup ?? 'false') === true, executeOnStartup: isTrueBoolean(args.startup),
executeOnUser: JSON.parse(args.user ?? 'false') === true, executeOnUser: isTrueBoolean(args.user),
executeOnAi: JSON.parse(args.bot ?? 'false') === true, executeOnAi: isTrueBoolean(args.bot),
executeOnChatChange: JSON.parse(args.load ?? 'false') === true, executeOnChatChange: isTrueBoolean(args.load),
}, },
); );
} catch (ex) { } catch (ex) {
@ -189,7 +189,7 @@ export class SlashCommandHandler {
args.set, args.set,
args.label, args.label,
name, name,
JSON.parse(args.chain ?? 'false') === true, isTrueBoolean(args.chain),
); );
} catch (ex) { } catch (ex) {
toastr.error(ex.message); toastr.error(ex.message);
@ -216,9 +216,9 @@ export class SlashCommandHandler {
this.api.createSet( this.api.createSet(
args.name ?? name ?? '', args.name ?? name ?? '',
{ {
disableSend: JSON.parse(args.nosend ?? 'false') === true, disableSend: isTrueBoolean(args.nosend),
placeBeforeInput: JSON.parse(args.before ?? 'false') === true, placeBeforeInput: isTrueBoolean(args.before),
injectInput: JSON.parse(args.inject ?? 'false') === true, injectInput: isTrueBoolean(args.inject),
}, },
); );
} catch (ex) { } catch (ex) {
@ -230,9 +230,9 @@ export class SlashCommandHandler {
this.api.updateSet( this.api.updateSet(
args.name ?? name ?? '', args.name ?? name ?? '',
{ {
disableSend: args.nosend !== undefined ? JSON.parse(args.nosend ?? 'false') === true : undefined, disableSend: args.nosend !== undefined ? isTrueBoolean(args.nosend) : undefined,
placeBeforeInput: args.before !== undefined ? JSON.parse(args.before ?? 'false') === true : undefined, placeBeforeInput: args.before !== undefined ? isTrueBoolean(args.before) : undefined,
injectInput: args.inject !== undefined ? JSON.parse(args.inject ?? 'false') === true : undefined, injectInput: args.inject !== undefined ? isTrueBoolean(args.inject) : undefined,
}, },
); );
} catch (ex) { } catch (ex) {