error if required option isn't included

This commit is contained in:
MathMan05
2025-10-27 11:47:52 -05:00
parent 35f90d71d9
commit f06e98e06f
2 changed files with 12 additions and 4 deletions
+10 -3
View File
@@ -259,6 +259,15 @@ export class Command extends SnowFlake {
return true;
}
const opts = states.filter((_) => typeof _ !== "string");
const options = opts.map(({option, state}) => {
return option.toJson(state);
});
const madeit = new Set(opts.map((_) => _.option));
for (const thing of this.options) {
if (thing.required && !madeit.has(thing)) {
throw new OptionError(I18n.commands.required(thing.localizedName));
}
}
await fetch(this.info.api + "/interactions", {
method: "POST",
@@ -275,9 +284,7 @@ export class Command extends SnowFlake {
attachments: [],
id: this.id,
name: this.name,
options: opts.map(({option, state}) => {
return option.toJson(state);
}),
options,
type: 1,
version: this.version,
},
+2 -1
View File
@@ -683,7 +683,8 @@
"nick:": "Nickname:"
},
"commands":{
"errorNotValid":"$1 is not a valid choice for $2"
"errorNotValid":"$1 is not a valid choice for $2",
"required":"$1 is a required part of this command"
},
"badge": {
"staff": "Instance staff",