Skip to content

Commit 59d2aa0

Browse files
committed
feat(Utils): checkIfSubOrGroup, avoid duplications
1 parent 73d0a4b commit 59d2aa0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/lib/util/Util.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class Util {
88

99
const check = options => {
1010
for (const option of options) {
11-
if ([1, 2].includes(option.type)) args.push(option.name);
11+
if (Util.checkIfSubOrGroup(option.type)) args.push(option.name);
1212
else args.push(option.value);
1313

1414
if (option.options) check(option.options);
@@ -29,7 +29,7 @@ export class Util {
2929

3030
const check = (options, object) => {
3131
for (const option of options) {
32-
if ([1, 2].includes(option.type)) object[option.name] = {};
32+
if (Util.checkIfSubOrGroup(option.type)) object[option.name] = {};
3333
else object[option.name] = option.value;
3434

3535
if (option.options) check(option.options, object[option.name]);
@@ -40,6 +40,15 @@ export class Util {
4040

4141
return args;
4242
}
43+
44+
/**
45+
* @deprecated We don't support arguments in object/array
46+
* @link https://discord.js.org/#/docs/main/stable/class/CommandInteractionOptionResolver
47+
*/
48+
private static checkIfSubOrGroup(type) {
49+
// Why? Because discord.js v14 (:
50+
return !!['SUB_COMMAND', 'SUB_COMMAND_GROUP', 'Subcommand', 'SubcommandGroup'].includes(type);
51+
}
4352

4453
static isClass(input: any): boolean {
4554
return (

0 commit comments

Comments
 (0)