Fix oversight in forceEnum slash commands

This commit is contained in:
Wolfsblvt 2024-06-29 02:42:01 +02:00
parent cba2b54531
commit 75099d3a22

View File

@ -59,7 +59,7 @@ export class SlashCommandArgument {
* @param {string|SlashCommandEnumValue|(string|SlashCommandEnumValue)[]} enums * @param {string|SlashCommandEnumValue|(string|SlashCommandEnumValue)[]} enums
* @param {(executor:SlashCommandExecutor)=>SlashCommandEnumValue[]} enumProvider function that returns auto complete options * @param {(executor:SlashCommandExecutor)=>SlashCommandEnumValue[]} enumProvider function that returns auto complete options
*/ */
constructor(description, types, isRequired = false, acceptsMultiple = false, defaultValue = null, enums = [], enumProvider = null, forceEnum = true) { constructor(description, types, isRequired = false, acceptsMultiple = false, defaultValue = null, enums = [], enumProvider = null, forceEnum = false) {
this.description = description; this.description = description;
this.typeList = types ? Array.isArray(types) ? types : [types] : []; this.typeList = types ? Array.isArray(types) ? types : [types] : [];
this.isRequired = isRequired ?? false; this.isRequired = isRequired ?? false;
@ -90,7 +90,7 @@ export class SlashCommandNamedArgument extends SlashCommandArgument {
* @param {string|SlashCommandClosure} [props.defaultValue=null] default value if no value is provided * @param {string|SlashCommandClosure} [props.defaultValue=null] default value if no value is provided
* @param {string|SlashCommandEnumValue|(string|SlashCommandEnumValue)[]} [props.enumList=[]] list of accepted values * @param {string|SlashCommandEnumValue|(string|SlashCommandEnumValue)[]} [props.enumList=[]] list of accepted values
* @param {(executor:SlashCommandExecutor)=>SlashCommandEnumValue[]} [props.enumProvider=null] function that returns auto complete options * @param {(executor:SlashCommandExecutor)=>SlashCommandEnumValue[]} [props.enumProvider=null] function that returns auto complete options
* @param {boolean} [props.forceEnum=true] default: true - whether the input must match one of the enum values * @param {boolean} [props.forceEnum=false] default: false - whether the input must match one of the enum values
*/ */
static fromProps(props) { static fromProps(props) {
return new SlashCommandNamedArgument( return new SlashCommandNamedArgument(
@ -103,7 +103,7 @@ export class SlashCommandNamedArgument extends SlashCommandArgument {
props.enumList ?? [], props.enumList ?? [],
props.aliasList ?? [], props.aliasList ?? [],
props.enumProvider ?? null, props.enumProvider ?? null,
props.forceEnum ?? true, props.forceEnum ?? false,
); );
} }
@ -120,9 +120,9 @@ export class SlashCommandNamedArgument extends SlashCommandArgument {
* @param {string|SlashCommandEnumValue|(string|SlashCommandEnumValue)[]} [enums=[]] * @param {string|SlashCommandEnumValue|(string|SlashCommandEnumValue)[]} [enums=[]]
* @param {string[]} [aliases=[]] * @param {string[]} [aliases=[]]
* @param {(executor:SlashCommandExecutor)=>SlashCommandEnumValue[]} [enumProvider=null] function that returns auto complete options * @param {(executor:SlashCommandExecutor)=>SlashCommandEnumValue[]} [enumProvider=null] function that returns auto complete options
* @param {boolean} [forceEnum=true] * @param {boolean} [forceEnum=false]
*/ */
constructor(name, description, types, isRequired = false, acceptsMultiple = false, defaultValue = null, enums = [], aliases = [], enumProvider = null, forceEnum = true) { constructor(name, description, types, isRequired = false, acceptsMultiple = false, defaultValue = null, enums = [], aliases = [], enumProvider = null, forceEnum = false) {
super(description, types, isRequired, acceptsMultiple, defaultValue, enums, enumProvider, forceEnum); super(description, types, isRequired, acceptsMultiple, defaultValue, enums, enumProvider, forceEnum);
this.name = name; this.name = name;
this.aliasList = aliases ? Array.isArray(aliases) ? aliases : [aliases] : []; this.aliasList = aliases ? Array.isArray(aliases) ? aliases : [aliases] : [];