mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
feat(interactionCreate.ts) finish basic interaction handling for chat input commands
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"scripts": {
|
||||
"compile": "tsc",
|
||||
"watch": "tsc -w",
|
||||
"lint": "eslint src/**/*.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
|
||||
|
||||
@@ -21,6 +21,7 @@ export const onReady = ( wrapper : Wrapper ) => {
|
||||
)
|
||||
.subscribe({
|
||||
complete() {
|
||||
console.log(Files.Commands);
|
||||
// on ready event, complete!
|
||||
// log stuff?
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import type Context from "../context";
|
||||
export interface BaseModule {
|
||||
name? : string;
|
||||
description : string;
|
||||
execute<T>(ctx: Context, args: Args) : Awaitable<T>
|
||||
execute: (ctx: Context, args: Args) => Awaitable<void>;
|
||||
}
|
||||
export type Text = {
|
||||
type : CommandType.TEXT;
|
||||
|
||||
Reference in New Issue
Block a user