This commit is contained in:
Dragon Fire
2024-03-20 00:36:40 -04:00
parent 51826788b1
commit 0362bdf613
2 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ module.exports = class CommandClient extends Client {
const parsed = await this.dispatcher.parseMessage(msg);
if (typeof parsed === 'string') {
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;
}
const { command, args } = parsed;
+8 -4
View File
@@ -1,5 +1,6 @@
const minimist = require('minimist');
const { stripIndents } = require('common-tags');
const { list } = require('../util/Util');
const argRegex = /"([^"]*)"|(\S+)/g;
module.exports = class CommandDispatcher {
@@ -47,7 +48,10 @@ module.exports = class CommandDispatcher {
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
break;
} 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') {
return stripIndents`
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));
@@ -70,7 +74,7 @@ module.exports = class CommandDispatcher {
if (arg.default === null) {
return stripIndents`
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 {
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') {
return stripIndents`
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);