mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-28 22:33:02 +05:00
Compare commits
6 commits
2dc7172179
...
3f90ff46cf
Author | SHA1 | Date | |
---|---|---|---|
|
3f90ff46cf | ||
d0b4a13a2e | |||
30a83aa273 | |||
|
62ab9250fc | ||
|
bce6242e1e | ||
|
b570759c09 |
361 changed files with 254 additions and 209 deletions
|
@ -22,5 +22,11 @@
|
|||
"owner": {
|
||||
"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 IDatabaseAdapter from "./IDatabaseAdapter.js";
|
||||
import logger from "../../helpers/logger.js";
|
||||
|
||||
export default class MongooseAdapter extends IDatabaseAdapter {
|
||||
/**
|
||||
|
@ -21,11 +22,11 @@ export default class MongooseAdapter extends IDatabaseAdapter {
|
|||
|
||||
async connect() {
|
||||
await mongoose.connect(this.uri, this.options);
|
||||
console.log("Database connected.");
|
||||
logger.log("Database connected.");
|
||||
}
|
||||
|
||||
async disconnect() {
|
||||
await mongoose.disconnect();
|
||||
console.log("Database disconnected.");
|
||||
console.warn("Database disconnected.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,72 +1,8 @@
|
|||
const { SlashCommandBuilder, InteractionContextType, ApplicationIntegrationType } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
export const data = {
|
||||
name: "8ball",
|
||||
description: "8ball",
|
||||
};
|
||||
|
||||
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;
|
||||
export const run = () => {
|
||||
console.log("8ball");
|
||||
};
|
||||
|
|
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 BaseEvent from "../base/BaseEvent";
|
||||
import logger from "../helpers/logger.js";
|
||||
|
||||
class Ready extends BaseEvent {
|
||||
constructor() {
|
||||
super({
|
||||
name: "ready",
|
||||
once: false,
|
||||
});
|
||||
}
|
||||
export const data = {
|
||||
name: "ready",
|
||||
once: true,
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @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
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../structures/client.js").ExtendedClient} client
|
||||
*/
|
||||
export async function run(client) {
|
||||
logger.ready(client.user.tag + " is online!");
|
||||
}
|
||||
|
||||
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 { client } from "../../index.js";
|
||||
import { getFilePaths } from "../../utils/index.js";
|
||||
|
@ -16,7 +17,8 @@ export const init = 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) {
|
||||
const { data, run } = await import(toFileURL(cmdFilePath));
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { resolve } from "node:path";
|
||||
import logger from "../../helpers/logger.js";
|
||||
import { client } from "../../index.js";
|
||||
import { getFilePaths } from "../../utils/index.js";
|
||||
|
@ -12,7 +13,8 @@ export const init = async () => {
|
|||
|
||||
const buildEvents = async () => {
|
||||
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) {
|
||||
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 { ExtendedClient } from "./structures/client.js";
|
||||
import logger from "./helpers/logger.js";
|
||||
|
||||
export const client = new ExtendedClient({
|
||||
intents: [
|
||||
|
@ -30,41 +25,10 @@ export const client = new ExtendedClient({
|
|||
|
||||
client.init();
|
||||
|
||||
// const client = new JaBaClient({
|
||||
// intents: [
|
||||
// GatewayIntentBits.Guilds,
|
||||
// GatewayIntentBits.GuildMembers,
|
||||
// GatewayIntentBits.GuildModeration,
|
||||
// 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"] },
|
||||
// });
|
||||
client
|
||||
.on("disconnect", () => logger.warn("Bot disconnected."))
|
||||
.on("reconnecting", () => logger.warn("Bot reconnecting..."))
|
||||
.on("warn", console.log)
|
||||
.on("error", console.log);
|
||||
|
||||
// (async () => {
|
||||
// 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));
|
||||
process.on("unhandledRejection", console.log).on("uncaughtException", console.log);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue