2022-07-31 18:52:16 +05:00
|
|
|
const { EmbedBuilder, Client, Collection, SlashCommandBuilder, ContextMenuCommandBuilder } = require("discord.js"),
|
2022-01-04 02:18:28 +05:00
|
|
|
{ GiveawaysManager } = require("discord-giveaways"),
|
|
|
|
{ SoundCloudPlugin } = require("@distube/soundcloud"),
|
2022-02-04 16:43:08 +05:00
|
|
|
{ SpotifyPlugin } = require("@distube/spotify"),
|
2022-07-23 17:14:42 +05:00
|
|
|
{ YtDlpPlugin } = require("@distube/yt-dlp"),
|
|
|
|
{ REST } = require("@discordjs/rest"),
|
2022-07-31 17:08:00 +05:00
|
|
|
{ Routes } = require("discord-api-types/v10");
|
2022-01-04 02:18:28 +05:00
|
|
|
|
2022-07-31 17:08:00 +05:00
|
|
|
const BaseEvent = require("./BaseEvent.js"),
|
2022-07-23 17:14:42 +05:00
|
|
|
BaseCommand = require("./BaseCommand.js"),
|
2022-07-31 20:43:08 +05:00
|
|
|
{ DiscordTogether } = require("../helpers/discordTogether"),
|
2022-01-04 02:18:28 +05:00
|
|
|
AmeClient = require("amethyste-api"),
|
|
|
|
path = require("path"),
|
2022-07-23 17:14:42 +05:00
|
|
|
fs = require("fs").promises,
|
|
|
|
mongoose = require("mongoose"),
|
2022-01-04 02:18:28 +05:00
|
|
|
DisTube = require("distube"),
|
|
|
|
moment = require("moment");
|
|
|
|
|
|
|
|
moment.relativeTimeThreshold("s", 60);
|
|
|
|
moment.relativeTimeThreshold("ss", 5);
|
|
|
|
moment.relativeTimeThreshold("m", 60);
|
|
|
|
moment.relativeTimeThreshold("h", 60);
|
|
|
|
moment.relativeTimeThreshold("d", 24);
|
|
|
|
moment.relativeTimeThreshold("M", 12);
|
|
|
|
|
|
|
|
// Creates JaBa class
|
|
|
|
class JaBa extends Client {
|
|
|
|
constructor(options) {
|
|
|
|
super(options);
|
|
|
|
this.config = require("../config"); // Load the config file
|
|
|
|
this.customEmojis = require("../emojis"); // load the bot's emojis
|
|
|
|
this.languages = require("../languages/language-meta"); // Load the bot's languages
|
|
|
|
this.commands = new Collection(); // Creates new commands collection
|
|
|
|
this.logger = require("../helpers/logger"); // Load the logger file
|
2022-07-31 17:08:00 +05:00
|
|
|
this.wait = require("node:timers/promises").setTimeout; // client.wait(1000) - Wait 1 second
|
2022-01-04 02:18:28 +05:00
|
|
|
this.functions = require("../helpers/functions"); // Load the functions file
|
|
|
|
this.guildsData = require("../base/Guild"); // Guild mongoose model
|
|
|
|
this.usersData = require("../base/User"); // User mongoose model
|
|
|
|
this.membersData = require("../base/Member"); // Member mongoose model
|
|
|
|
this.dashboard = require("../dashboard/app"); // Dashboard app
|
|
|
|
this.states = {}; // Used for the dashboard
|
|
|
|
this.knownGuilds = [];
|
|
|
|
|
|
|
|
this.databaseCache = {};
|
|
|
|
this.databaseCache.users = new Collection();
|
|
|
|
this.databaseCache.guilds = new Collection();
|
|
|
|
this.databaseCache.members = new Collection();
|
|
|
|
this.databaseCache.usersReminds = new Collection(); // members with active reminds
|
|
|
|
this.databaseCache.mutedUsers = new Collection(); // members who are currently muted
|
|
|
|
|
|
|
|
if (this.config.apiKeys.amethyste) this.AmeAPI = new AmeClient(this.config.apiKeys.amethyste);
|
2022-06-10 15:32:43 +05:00
|
|
|
|
2022-07-31 20:43:08 +05:00
|
|
|
this.discordTogether = new DiscordTogether(this);
|
|
|
|
|
2022-01-04 02:18:28 +05:00
|
|
|
this.player = new DisTube.default(this, {
|
2022-01-17 13:20:49 +05:00
|
|
|
plugins: [
|
|
|
|
new SpotifyPlugin({
|
|
|
|
emitEventsAfterFetching: true
|
|
|
|
}),
|
2022-02-04 16:43:08 +05:00
|
|
|
new SoundCloudPlugin(),
|
|
|
|
new YtDlpPlugin()
|
2022-01-17 13:20:49 +05:00
|
|
|
],
|
2022-07-31 17:08:00 +05:00
|
|
|
directLink: true,
|
2022-01-17 13:20:49 +05:00
|
|
|
emitNewSongOnly: true,
|
|
|
|
leaveOnEmpty: true,
|
|
|
|
leaveOnFinish: true,
|
2022-02-04 01:34:25 +05:00
|
|
|
leaveOnStop: true,
|
2022-01-04 02:18:28 +05:00
|
|
|
searchSongs: 10,
|
|
|
|
searchCooldown: 30,
|
2022-02-22 16:47:16 +05:00
|
|
|
emptyCooldown: 10,
|
2022-01-17 13:20:49 +05:00
|
|
|
emitAddListWhenCreatingQueue: false,
|
|
|
|
emitAddSongWhenCreatingQueue: false
|
2022-01-04 02:18:28 +05:00
|
|
|
});
|
|
|
|
|
|
|
|
this.player
|
|
|
|
.on("playSong", async (queue, song) => {
|
2022-03-21 13:47:37 +05:00
|
|
|
const m = await queue.textChannel.send({ content: this.translate("music/play:NOW_PLAYING", { songName: song.name }, queue.textChannel.guild.data.language) });
|
2022-01-31 20:46:23 +05:00
|
|
|
if (song.duration > 1) {
|
2022-01-04 02:18:28 +05:00
|
|
|
setTimeout(() => {
|
2022-01-05 00:24:57 +05:00
|
|
|
if (m.deletable) m.delete();
|
2022-01-04 02:18:28 +05:00
|
|
|
}, song.duration * 1000);
|
|
|
|
} else {
|
|
|
|
setTimeout(() => {
|
2022-01-05 00:24:57 +05:00
|
|
|
if (m.deletable) m.delete();
|
2022-01-31 20:46:23 +05:00
|
|
|
}, 10 * 60 * 1000); // m * s * ms
|
2022-01-04 02:18:28 +05:00
|
|
|
}
|
|
|
|
})
|
2022-03-21 13:47:37 +05:00
|
|
|
.on("addSong", (queue, song) => queue.textChannel.send({ content: this.translate("music/play:ADDED_QUEUE", { songName: song.name }, queue.textChannel.guild.data.language) }))
|
2022-06-10 15:32:43 +05:00
|
|
|
.on("addList", (queue, playlist) => queue.textChannel.send({ content: this.translate("music/play:ADDED_QUEUE_COUNT", { songCount: `**${playlist.songs.length}** ${this.getNoun(playlist.songs.length, this.translate("misc:NOUNS:TRACKS:1"), this.translate("misc:NOUNS:TRACKS:1"), this.translate("misc:NOUNS:TRACKS:2"), this.translate("misc:NOUNS:TRACKS:5"))}` }, queue.textChannel.guild.data.language) }))
|
2022-01-04 02:18:28 +05:00
|
|
|
.on("searchResult", (message, result) => {
|
2022-01-13 00:26:23 +05:00
|
|
|
let i = 0;
|
2022-07-31 17:08:00 +05:00
|
|
|
const embed = new EmbedBuilder()
|
2022-01-28 00:38:47 +05:00
|
|
|
.setDescription(result.map(song => `**${++i} -** ${song.name}`).join("\n"))
|
2022-03-21 13:47:37 +05:00
|
|
|
.setFooter({ text: this.translate("music/play:RESULTS_FOOTER", null, message.guild.data.language) })
|
2022-01-04 02:18:28 +05:00
|
|
|
.setColor(this.config.embed.color);
|
2022-02-13 17:26:12 +05:00
|
|
|
message.reply({ embeds: [embed] });
|
2022-01-04 02:18:28 +05:00
|
|
|
})
|
|
|
|
.on("searchDone", () => {})
|
|
|
|
.on("searchCancel", message => message.error("misc:TIMES_UP"))
|
|
|
|
.on("searchInvalidAnswer", message => message.error("misc:INVALID_NUMBER_RANGE", { min: 1, max: 10 }))
|
|
|
|
.on("searchNoResult", message => message.error("music/play:NO_RESULT"))
|
|
|
|
.on("error", (textChannel, e) => {
|
|
|
|
console.error(e);
|
2022-03-21 13:47:37 +05:00
|
|
|
textChannel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e }, textChannel.guild.data.language) });
|
2022-01-04 02:18:28 +05:00
|
|
|
})
|
2022-03-21 13:47:37 +05:00
|
|
|
.on("finish", queue => queue.textChannel.send(this.translate("music/play:QUEUE_ENDED", null, queue.textChannel.guild.data.language)))
|
|
|
|
// .on("disconnect", queue => queue.textChannel.send(this.translate("music/play:STOP_DISCONNECTED", null, queue.textChannel.guild.data.language)))
|
|
|
|
.on("empty", queue => queue.textChannel.send(this.translate("music/play:STOP_EMPTY", null, queue.textChannel.guild.data.language)));
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
this.giveawaysManager = new GiveawaysManager(this, {
|
|
|
|
storage: "./giveaways.json",
|
|
|
|
default: {
|
|
|
|
botsCanWin: false,
|
|
|
|
embedColor: this.config.embed.color,
|
2022-01-05 02:11:13 +05:00
|
|
|
embedColorEnd: "#FF0000",
|
2022-01-04 02:18:28 +05:00
|
|
|
reaction: "🎉"
|
|
|
|
}
|
|
|
|
});
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
2022-08-01 20:06:09 +05:00
|
|
|
async init() {
|
|
|
|
this.login(this.config.token);
|
|
|
|
|
|
|
|
mongoose.connect(this.config.mongoDB, {
|
|
|
|
useNewUrlParser: true,
|
|
|
|
useUnifiedTopology: true
|
|
|
|
}).then(() => {
|
|
|
|
this.logger.log("Connected to the Mongodb database.", "log");
|
|
|
|
}).catch((err) => {
|
|
|
|
this.logger.log(`Unable to connect to the Mongodb database. Error: ${err}`, "error");
|
|
|
|
});
|
|
|
|
|
|
|
|
const autoUpdateDocs = require("../helpers/autoUpdateDocs");
|
|
|
|
autoUpdateDocs.update(this);
|
|
|
|
}
|
|
|
|
|
2022-07-23 17:14:42 +05:00
|
|
|
/**
|
2022-07-25 22:09:02 +05:00
|
|
|
*
|
|
|
|
* @param {String} dir
|
|
|
|
* @returns
|
|
|
|
*/
|
2022-07-26 19:46:32 +05:00
|
|
|
async loadCommands(dir) {
|
2022-07-23 17:14:42 +05:00
|
|
|
const filePath = path.join(__dirname, dir);
|
2022-07-29 23:31:08 +05:00
|
|
|
var folders = await fs.readdir(filePath); folders = folders.map(file => path.join(filePath, file)).filter(async (path) => { path = await fs.lstat(path); path.isDirectory(); });
|
2022-07-31 17:08:00 +05:00
|
|
|
const rest = new REST().setToken(this.config.token);
|
2022-07-23 17:14:42 +05:00
|
|
|
const commands = [];
|
2022-07-29 23:31:08 +05:00
|
|
|
for (let index = 0; index < folders.length; index++) {
|
|
|
|
const folder = folders[index];
|
|
|
|
const files = await fs.readdir(folder);
|
|
|
|
|
|
|
|
for (let index = 0; index < files.length; index++) {
|
|
|
|
const file = files[index];
|
|
|
|
|
|
|
|
if (file.endsWith(".js")) {
|
|
|
|
const Command = require(path.join(folder, file));
|
|
|
|
if (Command.prototype instanceof BaseCommand) {
|
|
|
|
const command = new Command(this);
|
|
|
|
this.commands.set(command.command.name, command);
|
|
|
|
const aliases = [];
|
|
|
|
if (command.aliases && Array.isArray(command.aliases) && command.aliases.length > 0) {
|
|
|
|
command.aliases.forEach((alias) => {
|
2022-07-31 18:52:16 +05:00
|
|
|
const command_alias = (command.command instanceof SlashCommandBuilder || command.command instanceof ContextMenuCommandBuilder) ? { ...command.command.toJSON() } : { ...command.command };
|
2022-07-29 23:31:08 +05:00
|
|
|
command_alias.name = alias;
|
|
|
|
aliases.push(command_alias);
|
|
|
|
this.commands.set(alias, command);
|
|
|
|
});
|
|
|
|
}
|
2022-07-23 17:14:42 +05:00
|
|
|
|
2022-07-31 18:52:16 +05:00
|
|
|
commands.push((command.command instanceof SlashCommandBuilder || command.command instanceof ContextMenuCommandBuilder) ? command.command.toJSON() : command.command, ...aliases);
|
2022-07-23 17:14:42 +05:00
|
|
|
|
2022-07-29 23:31:08 +05:00
|
|
|
if (command.onLoad || typeof command.onLoad === "function") await command.onLoad(this);
|
|
|
|
this.logger.log(`Successfully loaded "${file}" command file. (Command: ${command.command.name})`);
|
|
|
|
}
|
2022-07-23 17:14:42 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-04 02:18:28 +05:00
|
|
|
try {
|
2022-07-26 19:46:32 +05:00
|
|
|
if (!this.config.production) {
|
2022-07-23 17:14:42 +05:00
|
|
|
await rest.put(
|
2022-07-26 19:46:32 +05:00
|
|
|
Routes.applicationGuildCommands(this.config.user, this.config.support.id), {
|
2022-07-29 23:31:08 +05:00
|
|
|
body: commands
|
2022-07-26 19:46:32 +05:00
|
|
|
}
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
await rest.put(
|
|
|
|
Routes.applicationCommands(this.config.user), {
|
|
|
|
body: commands
|
|
|
|
}
|
2022-07-23 17:14:42 +05:00
|
|
|
);
|
|
|
|
}
|
2022-07-26 19:46:32 +05:00
|
|
|
|
2022-07-23 17:14:42 +05:00
|
|
|
this.logger.log("Successfully registered application commands.");
|
|
|
|
} catch (err) {
|
|
|
|
this.logger.log("Cannot load commands: " + err.message, "error");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-26 19:46:32 +05:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {String} dir
|
|
|
|
* @param {String} file
|
|
|
|
*/
|
|
|
|
async loadCommand(dir, file) {
|
|
|
|
const Command = require(path.join(dir, `${file}.js`));
|
|
|
|
if (Command.prototype instanceof BaseCommand) {
|
|
|
|
const command = new Command(this);
|
|
|
|
this.commands.set(command.command.name, command);
|
|
|
|
const aliases = [];
|
|
|
|
if (command.aliases && Array.isArray(command.aliases) && command.aliases.length > 0) {
|
|
|
|
command.aliases.forEach((alias) => {
|
|
|
|
const command_alias = command.command instanceof SlashCommandBuilder ? { ...command.command.toJSON() } : { ...command.command };
|
|
|
|
command_alias.name = alias;
|
|
|
|
aliases.push(command_alias);
|
|
|
|
this.commands.set(alias, command);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (command.onLoad || typeof command.onLoad === "function") await command.onLoad(this);
|
|
|
|
this.logger.log(`Successfully loaded "${file}" command file. (Command: ${command.command.name})`);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {String} dir
|
|
|
|
* @param {String} name
|
|
|
|
*/
|
|
|
|
async unloadCommand(dir, name) {
|
|
|
|
delete require.cache[require.resolve(`${dir}${path.sep}${name}.js`)];
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-23 17:14:42 +05:00
|
|
|
/**
|
2022-07-25 22:09:02 +05:00
|
|
|
*
|
|
|
|
* @param {String} dir
|
|
|
|
* @returns
|
|
|
|
*/
|
2022-07-23 17:14:42 +05:00
|
|
|
async loadEvents(dir) {
|
|
|
|
const filePath = path.join(__dirname, dir);
|
|
|
|
const files = await fs.readdir(filePath);
|
|
|
|
for (let index = 0; index < files.length; index++) {
|
|
|
|
const file = files[index];
|
|
|
|
const stat = await fs.lstat(path.join(filePath, file));
|
2022-07-25 22:09:02 +05:00
|
|
|
if (stat.isDirectory()) this.loadEvents(path.join(dir, file));
|
2022-07-23 17:14:42 +05:00
|
|
|
if (file.endsWith(".js")) {
|
|
|
|
const Event = require(path.join(filePath, file));
|
|
|
|
if (Event.prototype instanceof BaseEvent) {
|
|
|
|
const event = new Event();
|
|
|
|
if (!event.name || !event.name.length) return console.error(`Cannot load "${file}" event file: Event name is not set!`);
|
|
|
|
if (event.once) this.once(event.name, event.execute.bind(event, this));
|
|
|
|
else this.on(event.name, event.execute.bind(event, this));
|
|
|
|
this.logger.log(`Successfully loaded "${file}" event file. (Event: ${event.name})`);
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
2022-07-25 22:09:02 +05:00
|
|
|
get defaultLanguage() {
|
|
|
|
return this.languages.find(language => language.default).name;
|
|
|
|
}
|
2022-07-23 17:14:42 +05:00
|
|
|
|
2022-07-25 22:09:02 +05:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {String} key
|
|
|
|
* @param {Array} args
|
|
|
|
* @param {String} locale
|
|
|
|
*/
|
|
|
|
translate(key, args, locale) {
|
|
|
|
if (!locale) locale = this.defaultLanguage;
|
|
|
|
const language = this.translations.get(locale);
|
|
|
|
if (!language) throw "Invalid language set in data.";
|
2022-07-23 17:14:42 +05:00
|
|
|
|
2022-07-25 22:09:02 +05:00
|
|
|
return language(key, args);
|
|
|
|
}
|
2022-07-23 17:14:42 +05:00
|
|
|
|
2022-07-25 22:09:02 +05:00
|
|
|
printDate(date, format, locale) {
|
|
|
|
if (!locale) locale = this.defaultLanguage;
|
|
|
|
const languageData = this.languages.find((language) => language.name === locale || language.aliases.includes(locale));
|
|
|
|
if (!format) format = languageData.defaultMomentFormat;
|
2022-07-23 17:14:42 +05:00
|
|
|
|
2022-07-25 22:09:02 +05:00
|
|
|
return moment(new Date(date))
|
|
|
|
.locale(languageData.moment)
|
|
|
|
.format(format);
|
|
|
|
}
|
|
|
|
|
|
|
|
convertTime(time, type, noPrefix, locale) {
|
2022-07-26 17:20:10 +05:00
|
|
|
if (!type) type = false;
|
2022-07-25 22:09:02 +05:00
|
|
|
if (!locale) locale = this.defaultLanguage;
|
|
|
|
const languageData = this.languages.find((language) => language.name === locale || language.aliases.includes(locale));
|
|
|
|
const m = moment(time).locale(languageData.moment);
|
2022-07-23 17:14:42 +05:00
|
|
|
|
2022-07-26 17:20:10 +05:00
|
|
|
return (type ? m.toNow(noPrefix) : m.fromNow(noPrefix));
|
2022-07-25 22:09:02 +05:00
|
|
|
}
|
2022-07-23 17:14:42 +05:00
|
|
|
|
2022-07-25 22:09:02 +05:00
|
|
|
getNoun(number, one, two, five) {
|
|
|
|
let n = Math.abs(number);
|
|
|
|
n %= 100;
|
|
|
|
if (n >= 5 && n <= 20) return five;
|
|
|
|
n %= 10;
|
|
|
|
if (n === 1) return one;
|
|
|
|
if (n >= 2 && n <= 4) return two;
|
|
|
|
|
|
|
|
return five;
|
|
|
|
}
|
2022-07-23 17:14:42 +05:00
|
|
|
|
2022-01-04 02:18:28 +05:00
|
|
|
async findOrCreateUser({ id: userID }, isLean) {
|
|
|
|
if (this.databaseCache.users.get(userID)) return isLean ? this.databaseCache.users.get(userID).toJSON() : this.databaseCache.users.get(userID);
|
|
|
|
else {
|
|
|
|
let userData = (isLean ? await this.usersData.findOne({
|
|
|
|
id: userID
|
|
|
|
}).lean() : await this.usersData.findOne({
|
|
|
|
id: userID
|
|
|
|
}));
|
|
|
|
if (userData) {
|
|
|
|
if (!isLean) this.databaseCache.users.set(userID, userData);
|
|
|
|
|
|
|
|
return userData;
|
|
|
|
} else {
|
|
|
|
userData = new this.usersData({
|
|
|
|
id: userID
|
|
|
|
});
|
|
|
|
await userData.save();
|
|
|
|
this.databaseCache.users.set(userID, userData);
|
|
|
|
|
|
|
|
return isLean ? userData.toJSON() : userData;
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
async findOrCreateMember({ id: memberID, guildID }, isLean) {
|
|
|
|
if (this.databaseCache.members.get(`${memberID}${guildID}`)) return isLean ? this.databaseCache.members.get(`${memberID}${guildID}`).toJSON() : this.databaseCache.members.get(`${memberID}${guildID}`);
|
|
|
|
else {
|
|
|
|
let memberData = (isLean ? await this.membersData.findOne({
|
|
|
|
guildID,
|
|
|
|
id: memberID
|
|
|
|
}).lean() : await this.membersData.findOne({
|
|
|
|
guildID,
|
|
|
|
id: memberID
|
|
|
|
}));
|
|
|
|
if (memberData) {
|
|
|
|
if (!isLean) this.databaseCache.members.set(`${memberID}${guildID}`, memberData);
|
|
|
|
|
|
|
|
return memberData;
|
|
|
|
} else {
|
|
|
|
memberData = new this.membersData({
|
|
|
|
id: memberID,
|
|
|
|
guildID: guildID
|
|
|
|
});
|
|
|
|
await memberData.save();
|
|
|
|
const guild = await this.findOrCreateGuild({
|
|
|
|
id: guildID
|
|
|
|
});
|
|
|
|
if (guild) {
|
|
|
|
guild.members.push(memberData._id);
|
|
|
|
await guild.save();
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
this.databaseCache.members.set(`${memberID}${guildID}`, memberData);
|
|
|
|
|
|
|
|
return isLean ? memberData.toJSON() : memberData;
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
async findOrCreateGuild({ id: guildID }, isLean) {
|
|
|
|
if (this.databaseCache.guilds.get(guildID)) return isLean ? this.databaseCache.guilds.get(guildID).toJSON() : this.databaseCache.guilds.get(guildID);
|
|
|
|
else {
|
|
|
|
let guildData = (isLean ? await this.guildsData.findOne({
|
|
|
|
id: guildID
|
|
|
|
}).populate("members").lean() : await this.guildsData.findOne({
|
|
|
|
id: guildID
|
|
|
|
}).populate("members"));
|
|
|
|
if (guildData) {
|
|
|
|
if (!isLean) this.databaseCache.guilds.set(guildID, guildData);
|
|
|
|
|
|
|
|
return guildData;
|
|
|
|
} else {
|
|
|
|
guildData = new this.guildsData({
|
|
|
|
id: guildID
|
|
|
|
});
|
|
|
|
await guildData.save();
|
|
|
|
this.databaseCache.guilds.set(guildID, guildData);
|
|
|
|
|
|
|
|
return isLean ? guildData.toJSON() : guildData;
|
2022-01-13 00:26:23 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-04 02:18:28 +05:00
|
|
|
|
|
|
|
module.exports = JaBa;
|