chore: Update JavaScript plugins (#95)

chore: update JavaScript plugins

Co-authored-by: EvolutionX-10 <EvolutionX-10@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2023-06-26 08:42:23 +05:30
committed by GitHub
parent e3d40e40cd
commit 1ff96e780a
2 changed files with 31 additions and 16 deletions

View File

@@ -19,7 +19,10 @@
* ```
*/
import { CommandInitPlugin, CommandType, controller } from "@sern/handler";
import { ApplicationCommandType } from "discord.js";
import {
ApplicationCommandType,
ApplicationCommandOptionType,
} from "discord.js";
import { useContainer } from "../index.js";
export const CommandTypeRaw = {
[CommandType.Both]: ApplicationCommandType.ChatInput,
@@ -146,7 +149,18 @@ export function publish(options) {
});
}
export function optionsTransformer(ops) {
return ops.map((el) =>
el.autocomplete ? (({ command, ...el }) => el)(el) : el
);
return ops.map((el) => {
switch (el.type) {
case ApplicationCommandOptionType.String:
case ApplicationCommandOptionType.Number:
case ApplicationCommandOptionType.Integer: {
return el.autocomplete && "command" in el
? (({ command, ...el }) => el)(el)
: el;
}
default:
return el;
}
});
}

View File

@@ -160,18 +160,19 @@ export function publish<
}
export function optionsTransformer(ops: Array<SernOptionsData>) {
return ops.map((el) => {
switch(el.type) {
case ApplicationCommandOptionType.String:
case ApplicationCommandOptionType.Number:
case ApplicationCommandOptionType.Integer: {
return el.autocomplete && 'command' in el
? (({command, ...el}) => el)(el)
: el;
}
default: return el;
}
});
return ops.map((el) => {
switch (el.type) {
case ApplicationCommandOptionType.String:
case ApplicationCommandOptionType.Number:
case ApplicationCommandOptionType.Integer: {
return el.autocomplete && "command" in el
? (({ command, ...el }) => el)(el)
: el;
}
default:
return el;
}
});
}
export type NonEmptyArray<T extends `${number}` = `${number}`> = [T, ...T[]];