mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-11 15:57:50 +02:00
Fix
This commit is contained in:
@@ -5,17 +5,17 @@ module.exports = class Argument {
|
|||||||
Object.defineProperty(this, 'client', { value: client });
|
Object.defineProperty(this, 'client', { value: client });
|
||||||
|
|
||||||
this.key = options.key.toLowerCase();
|
this.key = options.key.toLowerCase();
|
||||||
this.label = options.label || null;
|
this.label = typeof options.label === 'undefined' ? null : options.label;
|
||||||
this.typeID = options.type.toLowerCase();
|
this.typeID = options.type.toLowerCase();
|
||||||
this.min = options.min || null;
|
this.min = typeof options.min === 'undefined' ? null : options.min;
|
||||||
this.max = options.max || null;
|
this.max = typeof options.max === 'undefined' ? null : options.max;
|
||||||
this.oneOf = options.oneOf || null;
|
this.oneOf = typeof options.oneOf === 'undefined' ? null : options.oneOf;
|
||||||
this.default = options.default || null;
|
this.default = typeof options.default === 'undefined' ? null : options.default;
|
||||||
this.infinite = options.infinite || false;
|
this.infinite = options.infinite || false;
|
||||||
this.avatarSize = options.avatarSize || 2048;
|
this.avatarSize = options.avatarSize || 2048;
|
||||||
this.validator = options.validate || null;
|
this.validator = typeof options.validate === 'undefined' ? null : options.validate;
|
||||||
this.parser = options.parse || null;
|
this.parser = typeof options.parse === 'undefined' ? null : options.parse;
|
||||||
this.emptyChecker = options.isEmpty || null;
|
this.emptyChecker = typeof options.isEmpty === 'undefined' ? null : options.isEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
get type() {
|
get type() {
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ module.exports = class CommandDispatcher {
|
|||||||
}
|
}
|
||||||
const parsedArg = parsed._[i]?.toString();
|
const parsedArg = parsed._[i]?.toString();
|
||||||
if (arg.isEmpty(parsedArg, msg, arg)) {
|
if (arg.isEmpty(parsedArg, msg, arg)) {
|
||||||
if (arg.default !== null) {
|
if (arg.default === null) {
|
||||||
|
return `The "${arg.label || arg.key}" argument is required.`;
|
||||||
|
} else {
|
||||||
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
|
||||||
return `The "${arg.label || arg.key}" argument is required.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const valid = await arg.validate(parsedArg, msg, arg);
|
const valid = await arg.validate(parsedArg, msg, arg);
|
||||||
|
|||||||
Reference in New Issue
Block a user