From 1ff96e780a164086a2f806fbda12b04a01def162 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 08:42:23 +0530 Subject: [PATCH] chore: Update JavaScript plugins (#95) chore: update JavaScript plugins Co-authored-by: EvolutionX-10 --- JavaScript/publish.js | 22 ++++++++++++++++++---- TypeScript/publish.ts | 25 +++++++++++++------------ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/JavaScript/publish.js b/JavaScript/publish.js index d9ad606..86f23b9 100644 --- a/JavaScript/publish.js +++ b/JavaScript/publish.js @@ -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; + } + }); } diff --git a/TypeScript/publish.ts b/TypeScript/publish.ts index c807818..a108e25 100644 --- a/TypeScript/publish.ts +++ b/TypeScript/publish.ts @@ -160,18 +160,19 @@ export function publish< } export function optionsTransformer(ops: Array) { - 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, ...T[]];