Fix send Subcommand + new WebEmbed

This commit is contained in:
March 7th 2022-04-01 23:15:16 +07:00
parent 42bea13249
commit 76902bf8b2
2 changed files with 17 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "discord.js-selfbot-v13", "name": "discord.js-selfbot-v13",
"version": "1.2.4", "version": "1.2.5",
"description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]", "description": "A unofficial discord.js fork for creating selfbots [Based on discord.js v13]",
"main": "./src/index.js", "main": "./src/index.js",
"types": "./typings/index.d.ts", "types": "./typings/index.d.ts",

View File

@ -470,6 +470,7 @@ class ApplicationCommand extends Base {
let subCommand; let subCommand;
if (subCommandCheck) { if (subCommandCheck) {
subCommand = this.options.find((option) => option.name == options[0]); subCommand = this.options.find((option) => option.name == options[0]);
options.shift();
option_[0] = { option_[0] = {
type: ApplicationCommandOptionTypes[subCommand.type], type: ApplicationCommandOptionTypes[subCommand.type],
name: subCommand.name, name: subCommand.name,
@ -482,7 +483,7 @@ class ApplicationCommand extends Base {
const value = options[i]; const value = options[i];
if (typeof value !== 'string') { if (typeof value !== 'string') {
throw new TypeError( throw new TypeError(
`Expected option to be a String, got ${typeof value}`, `Expected option to be a String, got ${typeof value}. If you type Number, please convert to String.`,
); );
} }
if (!subCommandCheck && !this?.options[i]) continue; if (!subCommandCheck && !this?.options[i]) continue;
@ -511,7 +512,8 @@ class ApplicationCommand extends Base {
}; };
optionFormat.push(data); optionFormat.push(data);
} else { } else {
if (!options[i + 1]) continue; // First element is sub command and removed
if (!value) continue;
// Check value is invalid // Check value is invalid
let choice; let choice;
if ( if (
@ -524,7 +526,7 @@ class ApplicationCommand extends Base {
subCommand.options[i].choices.find((c) => c.value == value); subCommand.options[i].choices.find((c) => c.value == value);
if (!choice) { if (!choice) {
throw new Error( throw new Error(
`Invalid option: ${value} is not a valid choice for this option\nList of choices: ${subCommand.options[ `Invalid option: ${value} is not a valid choice for this option\nList of choices: \n${subCommand.options[
i i
].choices.map( ].choices.map(
(c, i) => `#${i + 1} Name: ${c.name} Value: ${c.value}\n`, (c, i) => `#${i + 1} Name: ${c.name} Value: ${c.value}\n`,
@ -535,12 +537,13 @@ class ApplicationCommand extends Base {
const data = { const data = {
type: ApplicationCommandOptionTypes[subCommand.options[i].type], type: ApplicationCommandOptionTypes[subCommand.options[i].type],
name: subCommand.options[i].name, name: subCommand.options[i].name,
value: choice?.value || value:
choice?.value ||
(subCommand.options[i].type == 'INTEGER' (subCommand.options[i].type == 'INTEGER'
? Number(options[i + 1]) ? Number(value)
: subCommand.options[i].type == 'BOOLEAN' : subCommand.options[i].type == 'BOOLEAN'
? Boolean(options[i + 1]) ? Boolean(value)
: options[i + 1]), : value),
}; };
optionFormat.push(data); optionFormat.push(data);
} }
@ -550,7 +553,7 @@ class ApplicationCommand extends Base {
if ( if (
subCommandCheck && subCommandCheck &&
subCommand?.options && subCommand?.options &&
subCommand?.options[i - 1]?.required subCommand?.options[i]?.required
) )
throw new Error('Value required missing'); throw new Error('Value required missing');
await this.client.api.interactions.post({ await this.client.api.interactions.post({