mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-22 06:31:06 +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";
|
||||
|
||||
|
|
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 { Events } from "discord.js";
|
||||
import { Client, Events } from "discord.js";
|
||||
|
||||
defineListener({
|
||||
event: Events.ClientReady,
|
||||
run: (client) => {
|
||||
once: true,
|
||||
run: (client: Client) => {
|
||||
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 "../listeners/ready.ts";
|
||||
import type { ClientEvents } from "discord.js";
|
||||
|
||||
interface Listener<E extends keyof ClientEvents> {
|
||||
event: E;
|
||||
once?: boolean;
|
||||
run: (
|
||||
...args: ClientEvents[E]
|
||||
) => any;
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import { Client, GatewayIntentBits, } from "discord.js";
|
||||
import { Client, GatewayIntentBits } from "discord.js";
|
||||
|
||||
export const Bubu = new Client({
|
||||
intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent
|
||||
//intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent | GatewayIntentBits.GuildMembers,
|
||||
//allowedMentions: {
|
||||
// parse: [],
|
||||
// repliedUser: false,
|
||||
//}
|
||||
intents: GatewayIntentBits.Guilds | GatewayIntentBits.GuildMessages | GatewayIntentBits.MessageContent | GatewayIntentBits.GuildMembers,
|
||||
allowedMentions: {
|
||||
parse: [],
|
||||
repliedUser: false,
|
||||
}
|
||||
});
|
||||
|
||||
Bubu.on("error", console.log);
|
||||
|
|
Loading…
Reference in a new issue