diff --git a/rewrite/index.ts b/rewrite/index.ts index e414501..27e6421 100644 --- a/rewrite/index.ts +++ b/rewrite/index.ts @@ -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; diff --git a/rewrite/types/common.ts b/rewrite/types/common.ts index 4c0a9ab..00e0767 100644 --- a/rewrite/types/common.ts +++ b/rewrite/types/common.ts @@ -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 & { __brand: K }; export type EventName = Brand; +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 = ( args: ArgumentTypeFromOptions, ) => any; +// TODO: Fill out signature export type UnicordEventHandler = (context: UnicordEventContext, payload: any) => any; export type UnicordHandler = diff --git a/testing/inferface.rewrite.test.ts b/testing/inferface.rewrite.test.ts index 831d524..4dd9ad0 100644 --- a/testing/inferface.rewrite.test.ts +++ b/testing/inferface.rewrite.test.ts @@ -1,15 +1,16 @@ // Here we are defining what we want the interface to look like so that there is a goal to work towards // Things here are not necessarily implemented in the actual code but show what we want it to look like to use the library -// import { unicord, t } from 'unicord'; import { Expectation, Unicord, UnicordArgumentType } from '../rewrite/index.ts'; +const DISCORD_APPLICATION_ID = process.env.APPLICATION_ID!; const DISCORD_CLIENT_TOKEN = process.env.BOT_TOKEN!; // Create a new client instance // Most usage will be via chaining methods off the client instance const client = new Unicord({ - token: process.env.BOT_TOKEN!, + application_id: DISCORD_APPLICATION_ID, + token: DISCORD_CLIENT_TOKEN, }) .registerChatCommand( 'ping', @@ -73,8 +74,6 @@ const client = new Unicord({ console.log(`Logged in as ${payload.user.username}`); }); -// client.login(DISCORD_CLIENT_TOKEN); - // Allow use of "child" instances inside parent instance const etc = new Unicord().registerChatCommand( 'zing', @@ -101,4 +100,4 @@ const etc = new Unicord().registerChatCommand( client.use(etc); -client.login(); \ No newline at end of file +client.login();