FridayNightFunkinBoyfriendBot/src/index.js

37 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-07-07 15:44:16 -04:00
const createBot = require('./bot.js');
const readline = require('readline');
const loadModules = require('./util/loadModules');
const js_yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');
const { Client, GatewayIntentBits } = require('discord.js');
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits;
const discordClient = new Client({ intents: [Guilds, GuildMessages, MessageContent] });
console.log('Starting FNFBoyfriendBot');
2024-07-20 20:27:17 -04:00
if (!fs.existsSync(path.join(__dirname, "../config.yml"))) {
console.log("Config not found creating config from the default config");
fs.copyFileSync(
path.join(__dirname, "./data/default_config.yml"),
path.join(__dirname, "../config.yml")
)
}
2024-07-07 15:44:16 -04:00
try {
config = js_yaml.load(fs.readFileSync(path.join(__dirname, '../', 'config.yml')))
} catch (e) {
console.log(e.stack);
}
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
2024-07-25 22:57:29 -04:00
// prompt: `Boot success! type ${config.console.prefix}help for a list of commands`
2024-07-07 15:44:16 -04:00
})
2024-07-20 20:27:17 -04:00
if (config.discord.enabled) discordClient.login(config.discord.token);
2024-07-07 15:44:16 -04:00
const bots = [];
2024-08-09 23:26:27 -04:00
for (options of config.bots) {
bot = createBot(options);
2024-07-07 15:44:16 -04:00
bots.push(bot);
bot.bots = bots;
loadModules(bot, options, config, discordClient);
bot.console.useReadlineInterface(rl);
}