diff --git a/package.json b/package.json index e89f700..ba3c002 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "description": "", "main": "dist/index.js", - "scripts": { + "scripts": { "compile": "tsc", "watch": "tsc -w", "lint": "eslint src/**/*.ts", diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 70a778f..6443e2d 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -16,8 +16,8 @@ export const onInteractionCreate = ( wrapper : Wrapper ) => { concatMap ( interaction => { if (interaction.isChatInputCommand()) { return of(interaction.commandName).pipe( - map ( Files.Commands.get ), - filter ( mod => mod !== undefined && (mod.type & CommandType.SLASH) != 0), + map ( name => Files.Commands.get(name) ), + filter( mod => mod !== undefined && (mod.type & CommandType.SLASH) != 0), tap ( mod => { const ctx = new Context(None, Some(interaction)); mod!.execute(ctx, ['slash', interaction.options]); @@ -31,9 +31,8 @@ export const onInteractionCreate = ( wrapper : Wrapper ) => { else { return of() } }) ).subscribe({ - error() { - //log things - console.log('Failed to finished message subscription!'); + error(e) { + throw e; }, next(command) { //log on each command emitted diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 2369444..20ac940 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -21,6 +21,7 @@ export const onReady = ( wrapper : Wrapper ) => { ) .subscribe({ complete() { + console.log(Files.Commands); // on ready event, complete! // log stuff? } diff --git a/src/handler/sern.ts b/src/handler/sern.ts index 916d342..6b183d2 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -6,20 +6,19 @@ import type { Client, } from 'discord.js'; -import Logger from './logger'; import type Wrapper from './structures/wrapper'; import { fromEvent } from 'rxjs'; import { SernError } from './structures/errors'; import { onReady } from './events/readyEvent'; import { onMessageCreate } from './events/messageEvent'; +import { onInteractionCreate } from './events/interactionCreate'; export function init( wrapper : Wrapper) { - const logger = new Logger(); const { events, client } = wrapper; if (events !== undefined) eventObserver(client, events); onReady( wrapper ); onMessageCreate( wrapper ); - + onInteractionCreate ( wrapper ); } diff --git a/src/handler/structures/commands/module.ts b/src/handler/structures/commands/module.ts index 00ea2e8..bc1c4e7 100644 --- a/src/handler/structures/commands/module.ts +++ b/src/handler/structures/commands/module.ts @@ -8,7 +8,7 @@ import type Context from "../context"; export interface BaseModule { name? : string; description : string; - execute(ctx: Context, args: Args) : Awaitable + execute: (ctx: Context, args: Args) => Awaitable; } export type Text = { type : CommandType.TEXT;