mirror of
https://github.com/Hessenuk/DiscordTickets.git
synced 2024-12-23 08:13:09 +02:00
Added try/catch block to named args parsing
This commit is contained in:
parent
d9ece4beca
commit
c6dbc11424
@ -156,7 +156,17 @@ module.exports = class CommandManager {
|
|||||||
let args = raw_args;
|
let args = raw_args;
|
||||||
|
|
||||||
if (cmd.process_args) {
|
if (cmd.process_args) {
|
||||||
args = parseArgs(cmd.args, { argv: argv(raw_args) });
|
try {
|
||||||
|
args = parseArgs(cmd.args, { argv: argv(raw_args) });
|
||||||
|
} catch (error) {
|
||||||
|
let help_cmd = `${settings.command_prefix}${i18n('commands.help.name')} ${cmd_name}`;
|
||||||
|
return await message.channel.send(
|
||||||
|
new MessageEmbed()
|
||||||
|
.setColor(settings.error_colour)
|
||||||
|
.setTitle(i18n('cmd_usage.invalid_named_args.title'))
|
||||||
|
.setDescription(i18n('cmd_usage.invalid_named_args.description', error.message, help_cmd))
|
||||||
|
);
|
||||||
|
}
|
||||||
for (let arg of cmd.args) {
|
for (let arg of cmd.args) {
|
||||||
if (arg.required && args[arg.name] === undefined) {
|
if (arg.required && args[arg.name] === undefined) {
|
||||||
return await cmd.sendUsage(message.channel, cmd_name); // send usage if any required arg is missing
|
return await cmd.sendUsage(message.channel, cmd_name); // send usage if any required arg is missing
|
||||||
|
Loading…
Reference in New Issue
Block a user