Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const client = new Discord.Client({intents: Object.values(Discord.IntentsBitField.Flags)})
- const { Collection, Client, MessageEmbed } = require("discord.js");
- module.exports = {
- client: client
- };
- module.imports = {
- getLogSymbols: './nodes_modules/log-symbols/index.js',
- logSymbols: getLogSymbols
- };
- const { Manager } = require("lavacord");
- const { readdirSync } = require("fs");
- const { BOT_TOKEN, EMBED_COLOR, MUTE_ROLE, YT_API_KEY, COMMAND_PREFIX, STATS } = require("./settings/configuration").BOT_SETTINGS;
- const db = require('quick.db')
- const path = require("path");
- const Enmap = require('enmap');
- const Tickets = new Enmap({ name: 'tickets' });
- const i18n = require('i18n');
- if (!COMMAND_PREFIX) throw new Error('Please provide a prefix in the configuration')
- if (!BOT_TOKEN) throw new Error('Please provide a valid bot token to start the bot\nObtain one from here https://discord.com/developers/applications')
- if (!YT_API_KEY) throw new Error('Please provide a Youtube API key in the configuration.\nGet one here https://developers.google.com/youtube/v3/getting-started')
- if (!EMBED_COLOR) throw new Error('Please provide an embed hex color in the configuration. E.g. RED or #fl92jd')
- console.log(logSymbols.success, 'Finished successfully!');
- client.StickyMessages = new db.table(`sticky`)
- const StickyMessages = new db.table(`sticky`)
- client.db = require('quick.db')
- client.embed = class Embed extends MessageEmbed { color = EMBED_COLOR }
- client.on('ready', () => {
- console.log(`Logged in as ${client.user.tag}!`);
- client.user.setActivity(`everyone and -thing`, {
- type: "Monitoring"
- })
- });
- client.on('error', (e) => {
- console.log(e)
- })
- client.on('warn', (e) => {
- console.log(e)
- })
- client.on('debug', (e) => {
- console.log(e)
- })
- process.on('unhandledRejection', (error) => {
- console.log('Unhandled promise rejection:', error)
- })
- i18n.configure({
- locales: ["en", "ko", "fr", "pt_br", "zh_cn", "zh_tw"],
- directory: path.join(__dirname, "locales"),
- defaultLocale: "en",
- objectNotation: true,
- register: global,
- logErrorFn: function (msg) {
- console.log("error", msg);
- },
- missingKeyFn: function (locale, value) {
- return value;
- },
- mustacheConfig: {
- tags: ["{{", "}}"],
- disable: false
- }
- });
- client.tickets = Tickets;
- client.snipes = new Collection()
- client.commands = new Collection();
- client.color = EMBED_COLOR;
- client.muteRole = MUTE_ROLE;
- client.afk = new Collection()
- client.spam = new Collection()
- client.handle = require("./functions/handle");
- client.play = require("./functions/play");
- client.queue = new Collection()
- client.categories = new Collection()
- client.db = {
- ...require('quick.db'),
- ensure: (key, def) => {
- if (db.get(key)) return db.get(key)
- db.set(key, def)
- return db.get(key, def)
- }
- }
- client.manager = new Manager(client, [{ id: 'main', host: 'localhost', port: 2333, password: 'brandon2511' }])
- client.manager.on('ready', node => console.log(`Node ${node.id} is ready!`))
- .on('disconnect', (ws, node) => console.log(`Node ${node.id} disconnected.`))
- .on('reconnecting', node => console.log(`Node ${node.id} tries to reconnect.`))
- .on('error', (error, node) => console.log(`Node ${node.id} got an error: ${error.message}`))
- const eventFiles = readdirSync("./events").filter(f => f.endsWith(".js"));
- for (const file of eventFiles) {
- const event = require(`./events/${file}`);
- if (event.name) {
- client.on(event.name, (...args) => event.execute(client, ...args));
- console.log(`[√] Event ${file} has been successfully loaded!`);
- }
- }
- const categories = ['fun', 'info', 'moderation', 'system', 'tickets', 'basic', 'music'];
- categories.forEach(async category => {
- const commandFiles = readdirSync(`./commands/${category}`).filter(f => f.endsWith(".js"));
- if (category !== 'owner') client.categories.set(category, commandFiles.map(s => s.split('.')[0]))
- for (const file of commandFiles) {
- try {
- const command = require(`./commands/${category}/${file}`);
- if (command.config) {
- client.commands.set(file.split('.')[0], { name: file.split('.')[0], ...command });
- console.log(`[√] Command ${file.split('.')[0]} has been successfully loaded!`);
- } else throw new Error('Command missing config')
- } catch (e) {
- console.log(`[❌] Command ${file} failed to load: ${e.message}`)
- }
- }
- })
- client.login(BOT_TOKEN).catch(() => {
- console.log(
- `[❌] Error while trying bot to log in.
- [⚠️ POSSIBLE FIX] You provided an invalid token of the bot`
- )
- })
Advertisement
Add Comment
Please, Sign In to add comment