UNPKG

@wilcosp/rex

Version:

Rex is an automated command manager for discord js

84 lines (83 loc) 3.37 kB
/*! * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import { APIApplicationCommandBasicOption, ApplicationCommandType, Locale, Snowflake } from "discord-api-types/v10"; import { StringSelectMenuInteraction, RoleSelectMenuInteraction, UserSelectMenuInteraction, MentionableSelectMenuInteraction } from "discord.js"; import { RexReplyModalInteractionBase } from "../interactions/replyModalBase"; import { RexUpdateReplyInteractionBase } from "../interactions/replyUpdateBase"; import { RexAutoCompleteInteraction } from "../interactions/slashCommands/autocomplete"; export type rexExecuteFun<I extends RexReplyModalInteractionBase, T extends RexCommandInfo> = (this: T, value: I) => void | unknown | Promise<void | unknown>; export type rexExecuteFunComponentModal<I extends RexUpdateReplyInteractionBase> = (value: I) => void | unknown | Promise<void | unknown>; export type RexAutoCompleteExecuteFun = (value: RexAutoCompleteInteraction) => void; export type SelectMenuInteraction = RoleSelectMenuInteraction | StringSelectMenuInteraction | UserSelectMenuInteraction | MentionableSelectMenuInteraction; export declare enum RexCommandMapping { ChatInput = "slash", User = "user", Message = "msg" } export declare enum RexComponentMapping { string = "stringSelect", role = "roleSelect", user = "userSelect", mention = "mentionSelect", button = "button" } export declare const RexCommandMappingByNumber: { readonly 1: RexCommandMapping.ChatInput; readonly 3: RexCommandMapping.Message; readonly 2: RexCommandMapping.User; }; export type ExtraCommandReplyInteractionOptions = { autoDefer?: boolean; deferEphemeral?: boolean; debounceDelay?: number; auditDelay?: number; useFailOver?: boolean; }; /** * @param id id of command, * @param name name of command */ export type RexCommandInfoBase = { id: Snowflake; name: string; nsfw?: boolean; description: string; nameLocalizations?: Map<Locale, string | undefined>; descriptionLocalizations?: Map<Locale, string | undefined>; }; /** * @param type type of command */ export type RexContextCommandInfo = RexCommandInfoBase & { type: ApplicationCommandType.Message | ApplicationCommandType.User; }; /** * @param type type of command * @param options options of command in raw format * @param mention the mention string for this command */ export type RexChatInputCommandInfo = RexCommandInfoBase & { options: APIApplicationCommandBasicOption[]; mention: string; type: ApplicationCommandType.ChatInput; }; export type RexGroupCommandInfo = RexCommandInfoBase & { type: RexCommandInfoTypes.GroupCommand; commands: Map<string, RexSubCommandInfo | RexChatInputCommandInfo>; }; export type RexSubCommandInfo = RexCommandInfoBase & { type: RexCommandInfoTypes.SubCommand; commands: Map<string, RexChatInputCommandInfo>; }; export declare const enum RexCommandInfoTypes { GroupCommand = -2, SubCommand = -1, ChatInput = 1, User = 2, Message = 3 } export type RexCommandInfo = RexContextCommandInfo | RexChatInputCommandInfo | RexSubCommandInfo | RexGroupCommandInfo; export type RexArray<T> = (T | ReadonlyArray<T>)[] | T[][];