From f06e98e06fd91050a49d85966bbd671290ada4ee Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Mon, 27 Oct 2025 11:47:52 -0500 Subject: [PATCH] error if required option isn't included --- src/webpage/interactions/commands.ts | 13 ++++++++++--- translations/en.json | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/webpage/interactions/commands.ts b/src/webpage/interactions/commands.ts index ddfe5ec..6c3a15f 100644 --- a/src/webpage/interactions/commands.ts +++ b/src/webpage/interactions/commands.ts @@ -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, }, diff --git a/translations/en.json b/translations/en.json index f875f91..a62db6b 100644 --- a/translations/en.json +++ b/translations/en.json @@ -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",