mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-31 16:00:07 +00:00
* (transformers) return as Optionalize<typeof> * fix check error Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
23 lines
935 B
TypeScript
23 lines
935 B
TypeScript
import { Bot } from "../bot.ts";
|
|
import { DiscordApplicationCommand } from "../types/discord.ts";
|
|
import { Optionalize } from "../types/shared.ts";
|
|
|
|
export function transformApplicationCommand(bot: Bot, payload: DiscordApplicationCommand) {
|
|
const applicationCommand = {
|
|
id: bot.transformers.snowflake(payload.id),
|
|
applicationId: bot.transformers.snowflake(payload.application_id),
|
|
guildId: payload.guild_id ? bot.transformers.snowflake(payload.guild_id) : undefined,
|
|
name: payload.name,
|
|
description: payload.description,
|
|
defaultPermission: payload.default_permission ?? false,
|
|
type: payload.type,
|
|
version: payload.version,
|
|
|
|
options: payload.options?.map((option) => bot.transformers.applicationCommandOption(bot, option)),
|
|
};
|
|
|
|
return applicationCommand as Optionalize<typeof applicationCommand>;
|
|
}
|
|
|
|
export interface ApplicationCommand extends ReturnType<typeof transformApplicationCommand> {}
|