mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-29 23:03:02 +05:00
Compare commits
5 commits
7109a2a0ef
...
5deee996dc
Author | SHA1 | Date | |
---|---|---|---|
5deee996dc | |||
d0b4a13a2e | |||
30a83aa273 | |||
|
62ab9250fc | ||
|
bce6242e1e |
361 changed files with 254 additions and 209 deletions
|
@ -22,5 +22,11 @@
|
||||||
"owner": {
|
"owner": {
|
||||||
"id": "123456789098765432"
|
"id": "123456789098765432"
|
||||||
},
|
},
|
||||||
"apiKeys": {}
|
"apiKeys": {},
|
||||||
|
"paths": {
|
||||||
|
"commands": "./src/commands",
|
||||||
|
"events": "./src/events",
|
||||||
|
"locales": "./src/services/languages/locales"
|
||||||
|
},
|
||||||
|
"defaultLang": "en-US"
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
import IDatabaseAdapter from "./IDatabaseAdapter.js";
|
import IDatabaseAdapter from "./IDatabaseAdapter.js";
|
||||||
|
import logger from "../../helpers/logger.js";
|
||||||
|
|
||||||
export default class MongooseAdapter extends IDatabaseAdapter {
|
export default class MongooseAdapter extends IDatabaseAdapter {
|
||||||
/**
|
/**
|
||||||
|
@ -21,11 +22,11 @@ export default class MongooseAdapter extends IDatabaseAdapter {
|
||||||
|
|
||||||
async connect() {
|
async connect() {
|
||||||
await mongoose.connect(this.uri, this.options);
|
await mongoose.connect(this.uri, this.options);
|
||||||
console.log("Database connected.");
|
logger.log("Database connected.");
|
||||||
}
|
}
|
||||||
|
|
||||||
async disconnect() {
|
async disconnect() {
|
||||||
await mongoose.disconnect();
|
await mongoose.disconnect();
|
||||||
console.log("Database disconnected.");
|
logger.warn("Database disconnected.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,72 +1,8 @@
|
||||||
const { SlashCommandBuilder, InteractionContextType, ApplicationIntegrationType } = require("discord.js");
|
export const data = {
|
||||||
const BaseCommand = require("../../base/BaseCommand");
|
name: "8ball",
|
||||||
|
description: "8ball",
|
||||||
|
};
|
||||||
|
|
||||||
class Eightball extends BaseCommand {
|
export const run = () => {
|
||||||
/**
|
console.log("8ball");
|
||||||
*
|
};
|
||||||
* @param {import("../base/Client")} client
|
|
||||||
*/
|
|
||||||
constructor(client) {
|
|
||||||
super({
|
|
||||||
command: new SlashCommandBuilder()
|
|
||||||
.setName("8ball")
|
|
||||||
.setDescription(client.translate("fun/8ball:DESCRIPTION"))
|
|
||||||
.setDescriptionLocalizations({
|
|
||||||
uk: client.translate("fun/8ball:DESCRIPTION", null, "uk-UA"),
|
|
||||||
ru: client.translate("fun/8ball:DESCRIPTION", null, "ru-RU"),
|
|
||||||
})
|
|
||||||
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall])
|
|
||||||
.setContexts([InteractionContextType.BotDM, InteractionContextType.PrivateChannel, InteractionContextType.Guild])
|
|
||||||
.addStringOption(option =>
|
|
||||||
option
|
|
||||||
.setName("question")
|
|
||||||
.setDescription(client.translate("fun/8ball:QUESTION"))
|
|
||||||
.setDescriptionLocalizations({
|
|
||||||
uk: client.translate("fun/8ball:QUESTION", null, "uk-UA"),
|
|
||||||
ru: client.translate("fun/8ball:QUESTION", null, "ru-RU"),
|
|
||||||
})
|
|
||||||
.setRequired(true),
|
|
||||||
)
|
|
||||||
.addBooleanOption(option =>
|
|
||||||
option
|
|
||||||
.setName("ephemeral")
|
|
||||||
.setDescription(client.translate("misc:EPHEMERAL_RESPONSE"))
|
|
||||||
.setDescriptionLocalizations({
|
|
||||||
uk: client.translate("misc:EPHEMERAL_RESPONSE", null, "uk-UA"),
|
|
||||||
ru: client.translate("misc:EPHEMERAL_RESPONSE", null, "ru-RU"),
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
dirname: __dirname,
|
|
||||||
ownerOnly: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {import("../../base/Client")} client
|
|
||||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
||||||
*/
|
|
||||||
async execute(client, interaction) {
|
|
||||||
await interaction.deferReply({ ephemeral: interaction.options.getBoolean("ephemeral") || false });
|
|
||||||
|
|
||||||
const question = interaction.options.getString("question");
|
|
||||||
const embed = client.embed({
|
|
||||||
fields: [
|
|
||||||
{
|
|
||||||
name: interaction.translate("fun/8ball:QUESTION"),
|
|
||||||
value: question,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: interaction.translate("fun/8ball:ANSWER"),
|
|
||||||
value: interaction.translate(`fun/8ball:RESPONSE_${client.functions.randomNum(1, 20)}`),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
await client.wait(5000);
|
|
||||||
|
|
||||||
interaction.editReply({ embeds: [embed] });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = Eightball;
|
|
||||||
|
|
72
src/commands_OLD/Fun/8ball.js
Normal file
72
src/commands_OLD/Fun/8ball.js
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
const { SlashCommandBuilder, InteractionContextType, ApplicationIntegrationType } = require("discord.js");
|
||||||
|
const BaseCommand = require("../../base/BaseCommand");
|
||||||
|
|
||||||
|
class Eightball extends BaseCommand {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {import("../base/Client")} client
|
||||||
|
*/
|
||||||
|
constructor(client) {
|
||||||
|
super({
|
||||||
|
command: new SlashCommandBuilder()
|
||||||
|
.setName("8ball")
|
||||||
|
.setDescription(client.translate("fun/8ball:DESCRIPTION"))
|
||||||
|
.setDescriptionLocalizations({
|
||||||
|
uk: client.translate("fun/8ball:DESCRIPTION", null, "uk-UA"),
|
||||||
|
ru: client.translate("fun/8ball:DESCRIPTION", null, "ru-RU"),
|
||||||
|
})
|
||||||
|
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall, ApplicationIntegrationType.UserInstall])
|
||||||
|
.setContexts([InteractionContextType.BotDM, InteractionContextType.PrivateChannel, InteractionContextType.Guild])
|
||||||
|
.addStringOption(option =>
|
||||||
|
option
|
||||||
|
.setName("question")
|
||||||
|
.setDescription(client.translate("fun/8ball:QUESTION"))
|
||||||
|
.setDescriptionLocalizations({
|
||||||
|
uk: client.translate("fun/8ball:QUESTION", null, "uk-UA"),
|
||||||
|
ru: client.translate("fun/8ball:QUESTION", null, "ru-RU"),
|
||||||
|
})
|
||||||
|
.setRequired(true),
|
||||||
|
)
|
||||||
|
.addBooleanOption(option =>
|
||||||
|
option
|
||||||
|
.setName("ephemeral")
|
||||||
|
.setDescription(client.translate("misc:EPHEMERAL_RESPONSE"))
|
||||||
|
.setDescriptionLocalizations({
|
||||||
|
uk: client.translate("misc:EPHEMERAL_RESPONSE", null, "uk-UA"),
|
||||||
|
ru: client.translate("misc:EPHEMERAL_RESPONSE", null, "ru-RU"),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
dirname: __dirname,
|
||||||
|
ownerOnly: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {import("../../base/Client")} client
|
||||||
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||||
|
*/
|
||||||
|
async execute(client, interaction) {
|
||||||
|
await interaction.deferReply({ ephemeral: interaction.options.getBoolean("ephemeral") || false });
|
||||||
|
|
||||||
|
const question = interaction.options.getString("question");
|
||||||
|
const embed = client.embed({
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
name: interaction.translate("fun/8ball:QUESTION"),
|
||||||
|
value: question,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: interaction.translate("fun/8ball:ANSWER"),
|
||||||
|
value: interaction.translate(`fun/8ball:RESPONSE_${client.functions.randomNum(1, 20)}`),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
await client.wait(5000);
|
||||||
|
|
||||||
|
interaction.editReply({ embeds: [embed] });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Eightball;
|
|
@ -1,64 +1,14 @@
|
||||||
import { ActivityType } from "discord.js";
|
import logger from "../helpers/logger.js";
|
||||||
import BaseEvent from "../base/BaseEvent";
|
|
||||||
|
|
||||||
class Ready extends BaseEvent {
|
export const data = {
|
||||||
constructor() {
|
|
||||||
super({
|
|
||||||
name: "ready",
|
name: "ready",
|
||||||
once: false,
|
once: true,
|
||||||
});
|
};
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {import("../base/Client")} client
|
* @param {import("../structures/client.js").ExtendedClient} client
|
||||||
*/
|
*/
|
||||||
async execute(client) {
|
export async function run(client) {
|
||||||
const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()];
|
logger.ready(client.user.tag + " is online!");
|
||||||
let servers = client.guilds.cache.size;
|
|
||||||
let users = 0;
|
|
||||||
|
|
||||||
client.guilds.cache.forEach(g => {
|
|
||||||
users += g.memberCount;
|
|
||||||
});
|
|
||||||
|
|
||||||
const birthdays = require("../helpers/birthdays");
|
|
||||||
birthdays.init(client);
|
|
||||||
|
|
||||||
const checkReminds = require("../helpers/checkReminds");
|
|
||||||
checkReminds.init(client);
|
|
||||||
|
|
||||||
client.logger.ready(`Loaded a total of ${commands.length} command(s).`);
|
|
||||||
client.logger.ready(`${client.user.getUsername()}, ready to serve ${users} members in ${servers} servers.`);
|
|
||||||
console.timeEnd("botReady");
|
|
||||||
|
|
||||||
const version = require("../package.json").version;
|
|
||||||
const status = [
|
|
||||||
`${commands.length} ${client.functions.getNoun(commands.length, client.translate("misc:NOUNS:COMMANDS:1"), client.translate("misc:NOUNS:COMMANDS:2"), client.translate("misc:NOUNS:COMMANDS:5"))} available!`,
|
|
||||||
`I'm in ${servers} ${client.functions.getNoun(servers, client.translate("misc:NOUNS:SERVER:1"), client.translate("misc:NOUNS:SERVER:2"), client.translate("misc:NOUNS:SERVER:5"))}!`,
|
|
||||||
`Cached ${users} ${client.functions.getNoun(users, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))}.`,
|
|
||||||
"Use /help for commands list!",
|
|
||||||
"Did you know that I have a brother called JaBa IT? Yeah! Ask Jonny about him.",
|
|
||||||
];
|
|
||||||
|
|
||||||
let i = 0;
|
|
||||||
setInterval(async () => {
|
|
||||||
servers = (await client.guilds.fetch()).size;
|
|
||||||
users = 0;
|
|
||||||
|
|
||||||
client.guilds.cache.forEach(g => {
|
|
||||||
users += g.memberCount;
|
|
||||||
});
|
|
||||||
|
|
||||||
client.user.setActivity({
|
|
||||||
type: ActivityType.Custom,
|
|
||||||
name: "custom",
|
|
||||||
state: `${status[i]} | v${version}`,
|
|
||||||
});
|
|
||||||
|
|
||||||
i = (i + 1) % status.length; // Wrap around to the start when reaching the end
|
|
||||||
}, 30 * 1000); // Every 30 seconds
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export default Ready;
|
|
||||||
|
|
64
src/events_OLD/Ready.js
Normal file
64
src/events_OLD/Ready.js
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
import { ActivityType } from "discord.js";
|
||||||
|
import BaseEvent from "../base/BaseEvent";
|
||||||
|
|
||||||
|
class Ready extends BaseEvent {
|
||||||
|
constructor() {
|
||||||
|
super({
|
||||||
|
name: "ready",
|
||||||
|
once: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {import("../base/Client")} client
|
||||||
|
*/
|
||||||
|
async execute(client) {
|
||||||
|
const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()];
|
||||||
|
let servers = client.guilds.cache.size;
|
||||||
|
let users = 0;
|
||||||
|
|
||||||
|
client.guilds.cache.forEach(g => {
|
||||||
|
users += g.memberCount;
|
||||||
|
});
|
||||||
|
|
||||||
|
const birthdays = require("../helpers/birthdays");
|
||||||
|
birthdays.init(client);
|
||||||
|
|
||||||
|
const checkReminds = require("../helpers/checkReminds");
|
||||||
|
checkReminds.init(client);
|
||||||
|
|
||||||
|
client.logger.ready(`Loaded a total of ${commands.length} command(s).`);
|
||||||
|
client.logger.ready(`${client.user.getUsername()}, ready to serve ${users} members in ${servers} servers.`);
|
||||||
|
console.timeEnd("botReady");
|
||||||
|
|
||||||
|
const version = require("../package.json").version;
|
||||||
|
const status = [
|
||||||
|
`${commands.length} ${client.functions.getNoun(commands.length, client.translate("misc:NOUNS:COMMANDS:1"), client.translate("misc:NOUNS:COMMANDS:2"), client.translate("misc:NOUNS:COMMANDS:5"))} available!`,
|
||||||
|
`I'm in ${servers} ${client.functions.getNoun(servers, client.translate("misc:NOUNS:SERVER:1"), client.translate("misc:NOUNS:SERVER:2"), client.translate("misc:NOUNS:SERVER:5"))}!`,
|
||||||
|
`Cached ${users} ${client.functions.getNoun(users, client.translate("misc:NOUNS:USERS:1"), client.translate("misc:NOUNS:USERS:2"), client.translate("misc:NOUNS:USERS:5"))}.`,
|
||||||
|
"Use /help for commands list!",
|
||||||
|
"Did you know that I have a brother called JaBa IT? Yeah! Ask Jonny about him.",
|
||||||
|
];
|
||||||
|
|
||||||
|
let i = 0;
|
||||||
|
setInterval(async () => {
|
||||||
|
servers = (await client.guilds.fetch()).size;
|
||||||
|
users = 0;
|
||||||
|
|
||||||
|
client.guilds.cache.forEach(g => {
|
||||||
|
users += g.memberCount;
|
||||||
|
});
|
||||||
|
|
||||||
|
client.user.setActivity({
|
||||||
|
type: ActivityType.Custom,
|
||||||
|
name: "custom",
|
||||||
|
state: `${status[i]} | v${version}`,
|
||||||
|
});
|
||||||
|
|
||||||
|
i = (i + 1) % status.length; // Wrap around to the start when reaching the end
|
||||||
|
}, 30 * 1000); // Every 30 seconds
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Ready;
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { resolve } from "node:path";
|
||||||
import logger from "../../helpers/logger.js";
|
import logger from "../../helpers/logger.js";
|
||||||
import { client } from "../../index.js";
|
import { client } from "../../index.js";
|
||||||
import { getFilePaths } from "../../utils/index.js";
|
import { getFilePaths } from "../../utils/index.js";
|
||||||
|
@ -16,7 +17,8 @@ export const init = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildCommands = async () => {
|
const buildCommands = async () => {
|
||||||
const commandFilePaths = (await getFilePaths("./newCommands", true)).filter(path => path.endsWith(".js"));
|
const cmdPath = resolve(client.configService.get("paths.commands"));
|
||||||
|
const commandFilePaths = (await getFilePaths(cmdPath, true)).filter(path => path.endsWith(".js"));
|
||||||
|
|
||||||
for (const cmdFilePath of commandFilePaths) {
|
for (const cmdFilePath of commandFilePaths) {
|
||||||
const { data, run } = await import(toFileURL(cmdFilePath));
|
const { data, run } = await import(toFileURL(cmdFilePath));
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { resolve } from "node:path";
|
||||||
import logger from "../../helpers/logger.js";
|
import logger from "../../helpers/logger.js";
|
||||||
import { client } from "../../index.js";
|
import { client } from "../../index.js";
|
||||||
import { getFilePaths } from "../../utils/index.js";
|
import { getFilePaths } from "../../utils/index.js";
|
||||||
|
@ -12,7 +13,8 @@ export const init = async () => {
|
||||||
|
|
||||||
const buildEvents = async () => {
|
const buildEvents = async () => {
|
||||||
try {
|
try {
|
||||||
const eventFilePaths = (await getFilePaths("./newEvents", true)).filter(path => path.endsWith(".js"));
|
const eventPath = resolve(client.configService.get("paths.events"));
|
||||||
|
const eventFilePaths = (await getFilePaths(eventPath, true)).filter(path => path.endsWith(".js"));
|
||||||
|
|
||||||
for (const eventFilePath of eventFilePaths) {
|
for (const eventFilePath of eventFilePaths) {
|
||||||
const { data, run } = await import(toFileURL(eventFilePath));
|
const { data, run } = await import(toFileURL(eventFilePath));
|
||||||
|
|
50
src/index.js
50
src/index.js
|
@ -1,11 +1,6 @@
|
||||||
// import "./helpers/extenders.js";
|
|
||||||
|
|
||||||
// import { GatewayIntentBits } from "discord.js";
|
|
||||||
// import JaBaClient from "./base/Client.js";
|
|
||||||
// import languages from "./helpers/languages.js";
|
|
||||||
|
|
||||||
import { GatewayIntentBits } from "discord.js";
|
import { GatewayIntentBits } from "discord.js";
|
||||||
import { ExtendedClient } from "./structures/client.js";
|
import { ExtendedClient } from "./structures/client.js";
|
||||||
|
import logger from "./helpers/logger.js";
|
||||||
|
|
||||||
export const client = new ExtendedClient({
|
export const client = new ExtendedClient({
|
||||||
intents: [
|
intents: [
|
||||||
|
@ -30,41 +25,10 @@ export const client = new ExtendedClient({
|
||||||
|
|
||||||
client.init();
|
client.init();
|
||||||
|
|
||||||
// const client = new JaBaClient({
|
client
|
||||||
// intents: [
|
.on("disconnect", () => logger.warn("Bot disconnected."))
|
||||||
// GatewayIntentBits.Guilds,
|
.on("reconnecting", () => logger.warn("Bot reconnecting..."))
|
||||||
// GatewayIntentBits.GuildMembers,
|
.on("warn", console.log)
|
||||||
// GatewayIntentBits.GuildModeration,
|
.on("error", console.log);
|
||||||
// GatewayIntentBits.GuildEmojisAndStickers,
|
|
||||||
// GatewayIntentBits.GuildIntegrations,
|
|
||||||
// GatewayIntentBits.GuildInvites,
|
|
||||||
// GatewayIntentBits.GuildVoiceStates,
|
|
||||||
// GatewayIntentBits.GuildPresences,
|
|
||||||
// GatewayIntentBits.GuildMessages,
|
|
||||||
// GatewayIntentBits.GuildMessageReactions,
|
|
||||||
// GatewayIntentBits.GuildMessageTyping,
|
|
||||||
// GatewayIntentBits.MessageContent,
|
|
||||||
// GatewayIntentBits.DirectMessageTyping,
|
|
||||||
// GatewayIntentBits.DirectMessages,
|
|
||||||
// GatewayIntentBits.DirectMessageReactions,
|
|
||||||
// ],
|
|
||||||
// allowedMentions: { parse: ["everyone", "roles", "users"] },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// (async () => {
|
process.on("unhandledRejection", console.log).on("uncaughtException", console.log);
|
||||||
// console.time("botReady");
|
|
||||||
|
|
||||||
// client.translations = await languages();
|
|
||||||
|
|
||||||
// await client.loadEvents("../events");
|
|
||||||
// await client.loadCommands("../commands");
|
|
||||||
// await client.init();
|
|
||||||
// })();
|
|
||||||
|
|
||||||
// client
|
|
||||||
// .on("disconnect", () => client.logger.warn("Bot disconnected."))
|
|
||||||
// .on("reconnecting", () => client.logger.warn("Bot reconnecting..."))
|
|
||||||
// .on("warn", console.log)
|
|
||||||
// .on("error", console.log);
|
|
||||||
|
|
||||||
// process.on("unhandledRejection", e => console.log(e)).on("uncaughtException", e => console.log(e));
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue