mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Make help message more informative
This commit is contained in:
+3
-3
@@ -72,9 +72,9 @@ module.exports = class CommandClient extends Client {
|
||||
|
||||
if (!this.dispatcher.isCommand(msg)) return;
|
||||
const parsed = await this.dispatcher.parseMessage(msg);
|
||||
if (typeof parsed === 'string') {
|
||||
const helpUsage = this.registry.commands.get('help').usage();
|
||||
await msg.reply(`${parsed}\n\nUse ${helpUsage} for more information.`);
|
||||
if (parsed.error) {
|
||||
const helpUsage = this.registry.commands.get('help').usage(parsed.command.name);
|
||||
await msg.reply(`${parsed.error}\n\nUse ${helpUsage} for more information.`);
|
||||
return;
|
||||
}
|
||||
const { command, args } = parsed;
|
||||
|
||||
+10
-10
@@ -54,10 +54,10 @@ module.exports = class CommandDispatcher {
|
||||
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
||||
break;
|
||||
} else {
|
||||
return stripIndents`
|
||||
return { command, error: stripIndents`
|
||||
The "${arg.label || arg.key}" argument is required.
|
||||
${arg.invalidText}
|
||||
`;
|
||||
` };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,12 +65,12 @@ module.exports = class CommandDispatcher {
|
||||
for (const parsedArg of infinite) {
|
||||
const valid = await arg.validate(parsedArg, msg, arg);
|
||||
if (typeof valid === 'string') {
|
||||
return valid;
|
||||
return { command, error: valid };
|
||||
} else if (!valid) {
|
||||
return stripIndents`
|
||||
return { command, error: stripIndents`
|
||||
An invalid value was provided for one of the "${arg.label || arg.key}" arguments.
|
||||
${arg.invalidText}
|
||||
`;
|
||||
` };
|
||||
}
|
||||
parsedArgs.push(await arg.parse(parsedArg, msg, arg));
|
||||
}
|
||||
@@ -80,10 +80,10 @@ module.exports = class CommandDispatcher {
|
||||
const parsedArg = i + 1 === command.args.length ? parsed._.slice(i).join(' ') : parsed._[i]?.toString();
|
||||
if (arg.isEmpty(parsedArg, msg, arg)) {
|
||||
if (arg.default === null) {
|
||||
return stripIndents`
|
||||
return { command, error: stripIndents`
|
||||
The "${arg.label || arg.key}" argument is required.
|
||||
${arg.invalidText}
|
||||
`;
|
||||
` };
|
||||
} else {
|
||||
finalResult[arg.key] = typeof arg.default === 'function' ? arg.default(msg) : arg.default;
|
||||
continue;
|
||||
@@ -91,12 +91,12 @@ module.exports = class CommandDispatcher {
|
||||
}
|
||||
const valid = await arg.validate(parsedArg, msg, arg);
|
||||
if (typeof valid === 'string') {
|
||||
return valid;
|
||||
return { command, error: valid };
|
||||
} else if (!valid) {
|
||||
return stripIndents`
|
||||
return { command, error: stripIndents`
|
||||
An invalid value was provided for the "${arg.label || arg.key}" argument.
|
||||
${arg.invalidText}
|
||||
`;
|
||||
` };
|
||||
}
|
||||
finalResult[arg.key] = await arg.parse(parsedArg, msg, arg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user