feat(bot): add commands, structs

This commit is contained in:
xHyroM 2023-04-05 14:44:17 +02:00
parent f22e1d6430
commit eebc948a58
No known key found for this signature in database
GPG key ID: BE0423F386C436AA
6 changed files with 57 additions and 1 deletions

View file

@ -0,0 +1,5 @@
import { Command } from "../structs/Command";
new Command({
name: "setup",
});

View file

@ -1,3 +1,8 @@
import "./commands/setup";
import { COMMANDS } from "./registers";
console.log(COMMANDS);
export default { export default {
fetch: (request: Request) => { fetch: (request: Request) => {
console.log(request); console.log(request);

View file

@ -0,0 +1,13 @@
import { Command } from "./structs/Command";
import { Listener } from "./structs/Listener";
export const COMMANDS: Command[] = [];
export const LISTENERS: Listener[] = [];
export const registerCommand = (command: Command) => {
COMMANDS.push(command);
};
export const registerListener = (listener: Listener) => {
LISTENERS.push(listener);
};

View file

@ -0,0 +1,15 @@
import { registerCommand } from "../registers";
interface CommandOptions {
name: string;
}
export class Command {
public name: string;
constructor(options: CommandOptions) {
this.name = options.name;
registerCommand(this);
}
}

View file

@ -0,0 +1,18 @@
import { registerListener } from "../registers";
interface ListenerOptions {
name: string;
once: boolean | undefined;
}
export class Listener {
public name: string;
public once: boolean;
constructor(options: ListenerOptions) {
this.name = options.name;
this.once = options.once ?? false;
registerListener(this);
}
}