diff --git a/commands/general/qr/create.js b/commands/general/qr/create.js index c7c6eb9d..99e9d0a9 100644 --- a/commands/general/qr/create.js +++ b/commands/general/qr/create.js @@ -1,6 +1,13 @@ import MediaCommand from "#cmd-classes/mediaCommand.js"; +const textEncoder = new TextEncoder(); + class QrCreateCommand extends MediaCommand { + async criteria(text) { + if (textEncoder.encode(text).length > 2952) return false; + return true; + } + paramsFunc() { const inputText = this.getOptionString("text") ?? this.args.join(" "); return { @@ -10,7 +17,7 @@ class QrCreateCommand extends MediaCommand { static init() { super.init(); - this.addTextParam(); + this.addTextParam(2952); return this; } diff --git a/src/classes/mediaCommand.ts b/src/classes/mediaCommand.ts index 22c3b589..2a1d5572 100644 --- a/src/classes/mediaCommand.ts +++ b/src/classes/mediaCommand.ts @@ -226,14 +226,14 @@ class MediaCommand extends Command { }); } - static addTextParam() { + static addTextParam(maxLen?: number) { this.flags.unshift({ name: "text", nameLocalizations: getAllLocalizations("image.flagNames.text"), type: Constants.ApplicationCommandOptionTypes.STRING, description: "The text to put on the image", descriptionLocalizations: getAllLocalizations("image.flags.text"), - maxLength: 4096, + maxLength: maxLen ?? 4096, required: !this.textOptional, classic: true, });