UNPKG

@lilybird/jsx

Version:
73 lines (72 loc) 2.31 kB
export function ApplicationCommand({ name, description, defaultMemberPermissions, dmPermission, name_localizations, description_localizations, nsfw, children }) { if (children != null && !Array.isArray(children)) children = [children]; return { type: 1, name, description, dm_permission: dmPermission, name_localizations, description_localizations, nsfw, default_member_permissions: defaultMemberPermissions?.reduce((prev, curr) => prev | curr, 0n).toString(), options: children }; } function commandComponent(type, data) { return { type, ...data }; } export function CommandOptions(props) { return props; } export function SubCommandOption(props) { let { children: options, ...obj } = props; if (options != null && !Array.isArray(options)) options = [options]; return commandComponent(1, { ...obj, options }); } export function SubCommandGroupOption(props) { let { children: options, ...obj } = props; if (!Array.isArray(options)) options = [options]; return commandComponent(2, { ...obj, options }); } export function StringOption(props) { let { children: choices, ...obj } = props; if (choices != null && !Array.isArray(choices)) choices = [choices]; return commandComponent(3, { ...obj, choices }); } export function IntegerOption(props) { let { children: choices, ...obj } = props; if (choices != null && !Array.isArray(choices)) choices = [choices]; return commandComponent(4, { ...obj, choices }); } export function BooleanOption(props) { return commandComponent(5, props); } export function UserOption(props) { return commandComponent(6, props); } export function ChannelOption(props) { return commandComponent(7, props); } export function RoleOption(props) { return commandComponent(8, props); } export function MentionableOption(props) { return commandComponent(9, props); } export function NumberOption(props) { let { children: choices, ...obj } = props; if (choices != null && !Array.isArray(choices)) choices = [choices]; return commandComponent(10, { ...obj, choices }); } export function AttachmentOption(props) { return commandComponent(11, props); }