mirror of
https://github.com/jaronpate/unicord.git
synced 2026-10-18 21:47:40 +00:00
cleaning up client merging
This commit is contained in:
@@ -71,26 +71,8 @@ export class Unicord {
|
||||
}
|
||||
|
||||
use(client: Unicord): this {
|
||||
// const handlers = client.commandManager.all();
|
||||
|
||||
// for (const type in handlers) {
|
||||
// const typeKey = type as UnicordEventType.ChatCommands | UnicordEventType.ApplicationCommands;
|
||||
// for (const [event, definition] of handlers[typeKey]) {
|
||||
// this.commandManager.register(
|
||||
// typeKey,
|
||||
// event,
|
||||
// definition.handler.bind(this.commandManager),
|
||||
// definition.options,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// this.commandManager.registerDefaultHelpCommand();
|
||||
|
||||
this.commandManager.merge(client.commandManager);
|
||||
|
||||
// TODO: inherit event listeners too
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -117,7 +99,6 @@ export class Unicord {
|
||||
return this;
|
||||
}
|
||||
|
||||
// TODO: should have a different signature for events that are not commands
|
||||
onEvent(event: string, handler: UnicordEventHandler): this {
|
||||
this.__onEvent(UnicordEventType.SystemEvent, event, handler);
|
||||
return this;
|
||||
|
||||
+31
-3
@@ -1,14 +1,17 @@
|
||||
import { UnicordCommandContext } from "../context";
|
||||
import { UnicordCommandContext } from '../context';
|
||||
|
||||
export type Primitive = string | number | boolean | null;
|
||||
|
||||
export interface UnicordConfig {
|
||||
application_id?: string;
|
||||
token?: string;
|
||||
prefix?: string;
|
||||
intents?: Intent[];
|
||||
}
|
||||
|
||||
export interface UnicordConfigWithDefaults extends UnicordConfig {
|
||||
application_id: string;
|
||||
token: string;
|
||||
intents: Intent[];
|
||||
}
|
||||
|
||||
@@ -16,6 +19,13 @@ export type Brand<T, K> = T & { __brand: K };
|
||||
|
||||
export type EventName = Brand<string, 'event-name'>;
|
||||
|
||||
export enum UnicordApplicationCommandType {
|
||||
Chat = 1,
|
||||
User = 2,
|
||||
Message = 3,
|
||||
PrimaryEntryPoint = 4,
|
||||
}
|
||||
|
||||
export enum UnicordArgumentType {
|
||||
SubCommand = 1,
|
||||
SubCommandGroup = 2,
|
||||
@@ -30,6 +40,23 @@ export enum UnicordArgumentType {
|
||||
Attachment = 11,
|
||||
}
|
||||
|
||||
export enum UnicordChannelType {
|
||||
GuildText = 0,
|
||||
DM = 1,
|
||||
GuildVoice = 2,
|
||||
GroupDm = 3,
|
||||
GuildCategory = 4,
|
||||
GuildNews = 5,
|
||||
GuildStore = 6,
|
||||
GuildNewsThread = 10,
|
||||
GuildPublicThread = 11,
|
||||
GuildPrivateThread = 12,
|
||||
GuildStageVoice = 13,
|
||||
GuildDirectory = 14,
|
||||
GuildForum = 15,
|
||||
GuildMedia = 16,
|
||||
}
|
||||
|
||||
// Old type
|
||||
// export type ApplicationCommandOption = {
|
||||
// type: ApplicationCommandOptionType;
|
||||
@@ -96,8 +123,8 @@ export type ArgumentTypeFromOptions<T extends readonly UnicordArgumentDefinition
|
||||
? U
|
||||
: U | undefined
|
||||
: Definition['required'] extends true // If required, keep as is; otherwise, make optional
|
||||
? DefinitionTypeMap[Definition['type']]
|
||||
: DefinitionTypeMap[Definition['type']] | undefined
|
||||
? DefinitionTypeMap[Definition['type']]
|
||||
: DefinitionTypeMap[Definition['type']] | undefined
|
||||
: unknown;
|
||||
};
|
||||
|
||||
@@ -106,6 +133,7 @@ export type UnicordCommandHandler<Options extends UnicordCommandOptions> = (
|
||||
args: ArgumentTypeFromOptions<Options['args']>,
|
||||
) => any;
|
||||
|
||||
// TODO: Fill out signature
|
||||
export type UnicordEventHandler = (context: UnicordEventContext, payload: any) => any;
|
||||
|
||||
export type UnicordHandler<Options extends UnicordCommandOptions> =
|
||||
|
||||
Reference in New Issue
Block a user