forked from Supositware/Haha-Yes
Show a message instead of error when an argument is required (for real this time)
This commit is contained in:
parent
26db60e95f
commit
c0507dc981
1 changed files with 17 additions and 3 deletions
|
@ -305,7 +305,7 @@ export default {
|
||||||
let isOptOut = await db.optout.findOne({ where: { userID: message.author.id } });
|
let isOptOut = await db.optout.findOne({ where: { userID: message.author.id } });
|
||||||
|
|
||||||
if (commandName === 'optout') {
|
if (commandName === 'optout') {
|
||||||
isOptOut = true
|
isOptOut = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const timestamp = new Date();
|
const timestamp = new Date();
|
||||||
|
@ -402,11 +402,17 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
const argsLength = command.data.options.length - argsToDelete;
|
const argsLength = command.data.options.length - argsToDelete;
|
||||||
|
const missingRequired = [];
|
||||||
|
|
||||||
for (let i = 0, j = 0; i < argsLength; i++, j++) {
|
for (let i = 0, j = 0; i < argsLength; i++, j++) {
|
||||||
if (!messageArgs[i]) continue;
|
|
||||||
const arg = command.data.options[j];
|
const arg = command.data.options[j];
|
||||||
|
|
||||||
|
if (arg.required && !messageArgs[i]) {
|
||||||
|
missingRequired.push({ name: arg.name, description: arg.description });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!messageArgs[i]) continue;
|
||||||
|
|
||||||
if (arg.type === ApplicationCommandOptionType.Attachment) continue;
|
if (arg.type === ApplicationCommandOptionType.Attachment) continue;
|
||||||
|
|
||||||
let payloadName = arg.name;
|
let payloadName = arg.name;
|
||||||
|
@ -437,6 +443,14 @@ export default {
|
||||||
console.log(`[${timestamp.toISOString()}] \x1b[33m⤷\x1b[0m with args ${JSON.stringify(args)}`);
|
console.log(`[${timestamp.toISOString()}] \x1b[33m⤷\x1b[0m with args ${JSON.stringify(args)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (missingRequired.length > 0) {
|
||||||
|
let missingMsg = '';
|
||||||
|
missingRequired.forEach(arg => {
|
||||||
|
missingMsg += `${arg.name} | ${arg.description}\n`;
|
||||||
|
});
|
||||||
|
return message.reply(`You are missing a required argument!\n\`${missingMsg}\``);
|
||||||
|
}
|
||||||
|
|
||||||
await command.execute(message, args, client)
|
await command.execute(message, args, client)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const hasPrallelLimit = await ratelimiter.checkParallel(message.author, commandName, command);
|
const hasPrallelLimit = await ratelimiter.checkParallel(message.author, commandName, command);
|
||||||
|
|
Loading…
Reference in a new issue