mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-22 14:41:05 +01:00
refactor: commands, listeners
This commit is contained in:
parent
23a8fd94c4
commit
01fc5af809
9 changed files with 32 additions and 16 deletions
1
src/commands/index.ts
Normal file
1
src/commands/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
import "./version.ts"
|
|
@ -1 +1,6 @@
|
||||||
export default {};
|
import { defineCommand } from "../loaders/commands";
|
||||||
|
|
||||||
|
export default defineCommand({
|
||||||
|
name: "version",
|
||||||
|
run: (context) => {}
|
||||||
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import "./loaders";
|
import "./commands"
|
||||||
|
import "./listeners";
|
||||||
|
|
||||||
import { Bubu } from "./structs/Client.ts";
|
import { Bubu } from "./structs/Client.ts";
|
||||||
|
|
||||||
|
|
1
src/listeners/index.ts
Normal file
1
src/listeners/index.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
import "./ready.ts";
|
|
@ -1,9 +1,10 @@
|
||||||
import { defineListener } from "../loaders/listeners.ts";
|
import { defineListener } from "../loaders/listeners.ts";
|
||||||
import { Events } from "discord.js";
|
import { Client, Events } from "discord.js";
|
||||||
|
|
||||||
defineListener({
|
defineListener({
|
||||||
event: Events.ClientReady,
|
event: Events.ClientReady,
|
||||||
run: (client) => {
|
once: true,
|
||||||
|
run: (client: Client) => {
|
||||||
console.log("heeh");
|
console.log("heeh");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,2 +1,12 @@
|
||||||
import "../commands/version.ts";
|
interface Command {
|
||||||
|
name: string;
|
||||||
|
run: (
|
||||||
|
context
|
||||||
|
) => any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const COMMANDS: Map<string, Command> = new Map();
|
||||||
|
|
||||||
|
export function defineCommand<T extends Command>(command: T) {
|
||||||
|
COMMANDS.set(command.name, command);
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
import "./commands.ts";
|
|
||||||
import "./listeners.ts";
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { ClientEvents, Events } from "discord.js";
|
import type { ClientEvents } from "discord.js";
|
||||||
import "../listeners/ready.ts";
|
|
||||||
|
|
||||||
interface Listener<E extends keyof ClientEvents> {
|
interface Listener<E extends keyof ClientEvents> {
|
||||||
event: E;
|
event: E;
|
||||||
|
once?: boolean;
|
||||||
run: (
|
run: (
|
||||||
...args: ClientEvents[E]
|
...args: ClientEvents[E]
|
||||||
) => any;
|
) => any;
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
import { Client, GatewayIntentBits, } from "discord.js";
|
import { Client, GatewayIntentBits } from "discord.js";
|
||||||
|
|
||||||
export const Bubu = new Client({
|
export const Bubu = new Client({
|
||||||
intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent
|
intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent | GatewayIntentBits.GuildMembers,
|
||||||
//intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent | GatewayIntentBits.GuildMembers,
|
allowedMentions: {
|
||||||
//allowedMentions: {
|
parse: [],
|
||||||
// parse: [],
|
repliedUser: false,
|
||||||
// repliedUser: false,
|
}
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Bubu.on("error", console.log);
|
Bubu.on("error", console.log);
|
||||||
|
|
Loading…
Reference in a new issue