/* eslint-disable no-case-declarations */ /* eslint-disable indent */ // dotenv for handling environment variables const dotenv = require('dotenv'); dotenv.config(); const token = process.env.TOKEN; const statusChannelId = process.env.STATUS_CHANNEL_ID; // Discord.JS const { Client } = require('discord.js-selfbot-v13'); const client = new Client({ partials: [ 'CHANNEL', 'MESSAGE', ], }); const { MessageActionRow, MessageButton } = require('discord.js'); // Various imports const fn = require('./functions.js'); const config = require('./config.json'); const strings = require('./strings.json'); const { GifData, CommandData } = require('./CustomModules/NodBot.js'); const isDev = process.env.IS_DEV; client.once('ready', async () => { fn.collections.dotCommands(client); fn.collections.setvalidCommands(client); fn.collections.roaches(client); await fn.download.gifs(client); await fn.download.pastas(client); await fn.download.joints(client); await fn.download.requests(client); await fn.download.strains(client); await fn.download.medicalAdvice(client); console.log('Ready!'); await fn.avWx.metar.getAllICAOs(); await fn.avWx.datis.getAllICAOs(); // console.log(JSON.stringify(icaoArray)); client.channels.fetch(statusChannelId).then(channel => { channel.send(`${new Date().toISOString()} -- <@${process.env.OWNER_ID}>\nStartup Sequence Complete`); }); }); // dot-commands client.on('messageCreate', message => { // Some basic checking to prevent running unnecessary code if (message.author.bot) return; if (message.author.id == client.user.id) return; // Automatic Responses, will respond if any message contains the keyword(s), excluding self-messages const lowerContent = message.content.toLowerCase(); const autoresponses = fn.autoresponses.checkForAll(lowerContent); autoresponses.forEach(e => { fn.autoresponses.send(message, e); }); // Break the message down into its components and analyze it const commandData = new CommandData(message).validate(message.client.dotCommands); console.log(commandData); if (commandData.isValid && commandData.isCommand) { try { client.dotCommands.get(commandData.command).execute(message, commandData); } catch (error) { console.error(error); message.reply('There was an error trying to execute that command.'); } } return; }); client.login(token);