const { Collection, Partials, GatewayIntentBits, Options } = require('discord.js'); const path = require('path'); const { ShardingClient } = require('status-sharding'); const AudioManager = require('./AudioManager'); // Creates Lunio class class Lunio extends ShardingClient { constructor() { super({ makeCache: Options.cacheWithLimits({ MessageManager: { maxSize: 50, keepOverLimit: (message) => message.author.id === this.user.id, }, GuildMemberManager: { maxSize: 200, keepOverLimit: (member) => member.id === this.user.id, }, UserManager: { maxSize: 100, }, }), messageCacheLifetime: 1210000, sweepers: { ...Options.DefaultSweeperSettings, messages: { interval: 3_600 * 3, // Every 3 hours. lifetime: 5_400, // Remove messages older than 1.5 hours. }, users: { interval: 3_600 * 3, // Every 3 hours. filter: () => (user) => user.id !== this.user.id, }, }, partials: [Partials.GuildMember, Partials.User, Partials.Channel, Partials.Reaction, Partials.Message], intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.MessageContent], failIfNotExists: false, rest: { globalRequestsPerSecond: 50, }, }); // for musicembed function this.rateLimitEmbedMap = new Map(); // for console logging this.logger = require('../utils/Logger'); // for command handler this.aliases = new Collection(); this.commands = new Collection(); this.interactions = new Collection(); this.cooldowns = new Collection(); // connect to database this.mongoose = require('../database/mongoose'); // config file this.config = require('../../config.js'); this.blockedWords = require('../utils/maps/blockedWords.js'); // for Activity this.Activity = []; this.PresenceType = 'LISTENING'; // Basic statistics for the bot this.messagesSent = 0; this.commandsUsed = 0; //AudioFunctions this.addAutoresume = require('../utils/functions/AudioFunctions/addAutoresume.js').bind(this); // player this.autoresume = require('../utils/functions/AudioFunctions/autoresume.js').bind(this); // bot, nodeID, nodeDisconnect this.checkDJ = require('../utils/functions/AudioFunctions/checkDJ'); // member, settings { MusicDJ, MusicDJRole } this.checkVC = require('../utils/functions/AudioFunctions/checkVC'); // member, settings { VCToggle, VCs } this.controlembed = require('../utils/functions/AudioFunctions/controlembed.js').bind(this); // guild, player, settings this.controlembedoff = require('../utils/functions/AudioFunctions/controlembedoff.js').bind(this); // guild, player this.getduration = require('../utils/functions/AudioFunctions/getduration'); // duration this.musicembed = require('../utils/functions/AudioFunctions/musicembed').bind(this); // player, settings { mChannelID, mChannelEmbedID, Requester, Language } this.musicoff = require('../utils/functions/AudioFunctions/musicoff'); // settings { mChannelID, mChannelEmbedID, Language } this.progressBar = require('../utils/functions/AudioFunctions/progressBar.js'); // maxtime, currenttime this.removeAutoresume = require('../utils/functions/AudioFunctions/removeAutoresume.js').bind(this); // guildID this.replaceCredentials = require('../utils/functions/AudioFunctions/replaceCredentials').bind(this); // res this.search = require('../utils/functions/AudioFunctions/search'); // bot, msg, search, settings { mChannelID, mChannelEmbedID, DefaultVol, SongUserLimit, SongTimeLimitMS, Playlists, Language } //GuildDataFunctions this.getGuildData = require('../utils/functions/GuildDataFunctions/getGuildData').bind(this); // guildId this.updateGuildSettings = require('../utils/functions/GuildDataFunctions/updateGuildSettings').bind(this); // guildId, settings this.updateTopggStats = require('../utils/functions/GuildDataFunctions/updateTopggStats').bind(this); // serverCount //PlaylistFunctions this.createPlaylist = require('../utils/functions/PlaylistFunctions/createPlaylist').bind(this); // settings this.deletePlaylist = require('../utils/functions/PlaylistFunctions/deletePlaylist').bind(this); // settings this.updatePlaylistExpireAt = require('../utils/functions/PlaylistFunctions/updatePlaylistExpireAt').bind(this); // userId, userSettings //UserDataFunctions this.getUserData = require('../utils/functions/UserDataFunctions/getUserData').bind(this); // userId this.updateUserSettings = require('../utils/functions/UserDataFunctions/updateUserSettings').bind(this); // userId, settings this.updateUserExpireAt = require('../utils/functions/UserDataFunctions/updateUserExpireAt.js').bind(this); // bot, userId, userSettings //UtilFunctions this.checkBlacklisted = require('../utils/functions/UtilFunctios/checkBlacklisted.js'); // guildId, userId this.checkDefaultPerms = require('../utils/functions/UtilFunctios/checkDefaultPerms.js').bind(this); // channel, guild, settings, interaction = null this.checkPremium = require('../utils/functions/UtilFunctios/checkPremium.js').bind(this); // settings, userSettings this.codeBlock = require('../utils/functions/UtilFunctios/codeBlock'); // textToCodeBlock this.delay = require('../utils/functions/UtilFunctios/delay').bind(this); // TimeInMS this.getColor = require('../utils/functions/UtilFunctios/getColor').bind(this); // guildId this.getGuild = require('../utils/functions/UtilFunctios/getGuild.js').bind(this); // guildID // for audio this.manager = new AudioManager(this); // for permissions this.permissionsMap = require('../utils/maps/permissionsMap'); } // Function for getting translations translate(locale, key, args) { if (!locale) locale = require('../../config.js').defaultSettings.Language; const language = this.translations.get(locale); if (!language) return 'Invalid language set in data.'; return language(key, args); } // Load a command loadCommand(commandPath, commandName) { const cmd = new (require(`.${commandPath}${path.sep}${commandName}`))(this); this.logger.log(`[SYSTEM] Loading Command: ${cmd.help.name}`); cmd.conf.location = commandPath; this.commands.set(cmd.help.name, cmd); cmd.help.aliases.forEach((alias) => { this.aliases.set(alias, cmd.help.name); }); } async reloadBlockedWords() { try { // Reload blocked words from the file system this.blockedWords = require('../utils/maps/blockedWords.js'); this.logger.log('[SYSTEM] Blocked words reloaded successfully'); } catch (error) { this.logger.error(`[SYSTEM] Error reloading blocked words: ${error}`); } } } module.exports = Lunio;