mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 22:27:44 +02:00
Fix
This commit is contained in:
+1
-1
@@ -57,7 +57,7 @@ module.exports = class CommandClient extends Client {
|
|||||||
const parsed = await this.dispatcher.parseMessage(msg);
|
const parsed = await this.dispatcher.parseMessage(msg);
|
||||||
if (typeof parsed === 'string') {
|
if (typeof parsed === 'string') {
|
||||||
const helpUsage = this.registry.commands.get('help').usage();
|
const helpUsage = this.registry.commands.get('help').usage();
|
||||||
await msg.reply(`${parsed} Use ${helpUsage} for more information.`);
|
await msg.reply(`${parsed}\nUse ${helpUsage} for more information.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { command, args } = parsed;
|
const { command, args } = parsed;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const minimist = require('minimist');
|
const minimist = require('minimist');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
|
const { list } = require('../util/Util');
|
||||||
const argRegex = /"([^"]*)"|(\S+)/g;
|
const argRegex = /"([^"]*)"|(\S+)/g;
|
||||||
|
|
||||||
module.exports = class CommandDispatcher {
|
module.exports = class CommandDispatcher {
|
||||||
@@ -47,7 +48,10 @@ module.exports = class CommandDispatcher {
|
|||||||
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
return `The "${arg.label || arg.key}" argument is required.`;
|
return stripIndents`
|
||||||
|
The "${arg.label || arg.key}" argument is required.
|
||||||
|
${arg.oneOf ? `It must be one of the following: ${list(arg.oneOf, 'or')}` : ''}
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -57,7 +61,7 @@ module.exports = class CommandDispatcher {
|
|||||||
if (!valid || typeof valid === 'string') {
|
if (!valid || typeof valid === 'string') {
|
||||||
return stripIndents`
|
return stripIndents`
|
||||||
An invalid value was provided for one of the "${arg.label || arg.key}" arguments.
|
An invalid value was provided for one of the "${arg.label || arg.key}" arguments.
|
||||||
${arg.oneOf ? `It must be one of the following: ${arg.oneOf.map(a => `\`${a}\``)}` : ''}
|
${arg.oneOf ? `It must be one of the following: ${list(arg.oneOf, 'or')}` : ''}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
parsedArgs.push(await arg.parse(parsedArg, msg, arg));
|
parsedArgs.push(await arg.parse(parsedArg, msg, arg));
|
||||||
@@ -70,7 +74,7 @@ module.exports = class CommandDispatcher {
|
|||||||
if (arg.default === null) {
|
if (arg.default === null) {
|
||||||
return stripIndents`
|
return stripIndents`
|
||||||
The "${arg.label || arg.key}" argument is required.
|
The "${arg.label || arg.key}" argument is required.
|
||||||
${arg.oneOf ? `It must be one of the following: ${arg.oneOf.map(a => `\`${a}\``)}` : ''}
|
${arg.oneOf ? `It must be one of the following: ${list(arg.oneOf, 'or')}` : ''}
|
||||||
`;
|
`;
|
||||||
} else {
|
} 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;
|
||||||
@@ -81,7 +85,7 @@ module.exports = class CommandDispatcher {
|
|||||||
if (!valid || typeof valid === 'string') {
|
if (!valid || typeof valid === 'string') {
|
||||||
return stripIndents`
|
return stripIndents`
|
||||||
An invalid value was provided for the "${arg.label || arg.key}" argument.
|
An invalid value was provided for the "${arg.label || arg.key}" argument.
|
||||||
${arg.oneOf ? `It must be one of the following: ${arg.oneOf.map(a => `\`${a}\``)}` : ''}
|
${arg.oneOf ? `It must be one of the following: ${list(arg.oneOf, 'or')}` : ''}
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
finalResult[arg.key] = await arg.parse(parsedArg, msg, arg);
|
finalResult[arg.key] = await arg.parse(parsedArg, msg, arg);
|
||||||
|
|||||||
Reference in New Issue
Block a user