feat: new structure, and fixes paths on handlers

This commit is contained in:
Slincnik 2024-12-09 13:09:57 +03:00
parent b7ee0fe291
commit db7f9693fe
No known key found for this signature in database
399 changed files with 85 additions and 29 deletions

View file

@ -1,19 +0,0 @@
import { Client } from "discord.js";
import { config } from "../config.js";
import { init as initCommands } from "../handlers/command-handler/index.js";
import { init as initEvents } from "../handlers/event-handler/index.js";
export class ExtendedClient extends Client {
/**
* @param {import("discord.js").ClientOptions} options
*/
constructor(options) {
super(options);
}
async init() {
return this.login(config.token)
.then(async () => await Promise.all([initCommands(), initEvents()]))
.catch(console.error);
}
}

View file

@ -2,10 +2,10 @@
"name": "jaba",
"version": "4.6.7",
"description": "My Discord Bot",
"main": "index.js",
"main": "src/index.js",
"type": "module",
"scripts": {
"start": "node ."
"start": "node src/index.js"
},
"author": "https://github.com/JonnyBro",
"dependencies": {

View file

@ -0,0 +1,9 @@
export default class IDatabaseAdapter {
async connect() {
throw new Error("Method `connect` not implemented.");
}
async disconnect() {
throw new Error("Method `disconnect` not implemented.");
}
}

View file

@ -0,0 +1,31 @@
import mongoose from "mongoose";
import IDatabaseAdapter from "./IDatabaseAdapter.js";
export default class MongooseAdapter extends IDatabaseAdapter {
/**
*
* @param {string} uri - database url connect
* @param {mongoose.ConnectOptions} options - database connect options
*/
constructor(uri, options = {}) {
super();
if (!uri) {
throw new Error("MongooseAdapter: URI is required.");
}
this.uri = uri;
this.options = options;
}
async connect() {
await mongoose.connect(this.uri, this.options);
console.log("Database connected.");
}
async disconnect() {
await mongoose.disconnect();
console.log("Database disconnected.");
}
}

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View file

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View file

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View file

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View file

@ -10,8 +10,8 @@ import { promises as fs } from "fs";
import { setTimeout } from "timers/promises";
import mongoose from "mongoose";
import config from "../config.js";
import * as emojis from "../emojis.json";
import config from "../../config.js";
import * as emojis from "../../emojis.json";
import langs from "../languages/language-meta.js";
import logger from "../helpers/logger.js";
import * as funcs from "../helpers/functions.js";
@ -327,7 +327,7 @@ class JaBaClient extends Client {
/**
* Returns a User data from the database.
* @param {string} userID - The ID of the user to find or create.
* @returns {Promise<import("./User")>} The user data object, either retrieved from the database or newly created.
* @returns {Promise<import("./User.js")>} The user data object, either retrieved from the database or newly created.
*/
async getUserData(userID) {
let userData = await this.usersData.findOne({ id: userID });
@ -346,7 +346,7 @@ class JaBaClient extends Client {
* Returns a Member data from the database.
* @param {string} memberId - The ID of the member to find or create.
* @param {string} guildId - The ID of the guild the member belongs to.
* @returns {Promise<import("./Member")>} The member data object, either retrieved from the database or newly created.
* @returns {Promise<import("./Member.js")>} The member data object, either retrieved from the database or newly created.
*/
async getMemberData(memberId, guildId) {
let memberData = await this.membersData.findOne({ guildID: guildId, id: memberId });
@ -370,7 +370,7 @@ class JaBaClient extends Client {
/**
* Returns a Guild data from the database.
* @param {string} guildId - The ID of the guild to find or create.
* @returns {Promise<import("./Guild")>} The guild data object, either retrieved from the database or newly created.
* @returns {Promise<import("./Guild.js")>} The guild data object, either retrieved from the database or newly created.
*/
async getGuildData(guildId) {
let guildData = await this.guildsData.findOne({ id: guildId }).populate("members");

Some files were not shown because too many files have changed in this diff Show more