You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.4 KiB
JavaScript

const InstaBot = require(`./Structure/Client`),
client = new InstaBot();
const util = require(`util`),
fs = require(`fs`),
readdir = util.promisify(fs.readdir),
mongoose = require(`mongoose`);
require(`dotenv`).config();
const initialize = async () => {
let directories = await readdir(`./Commands/`);
directories.forEach(async (dir) => {
let commands = await readdir(`./Commands/` + dir + `/`);
commands.filter((cmd) => cmd.split(`.`).pop() === `js`).forEach((cmd) => {
const response = client.loadCommand(`./Commands/` + dir, cmd);
if (response) {
client.logger.log(response, `error`);
}
});
});
const evtFiles = await readdir(`./Events/`);
evtFiles.forEach((file) => {
const eventName = file.split(`.`)[0];
const event = new (require(`./Events/${file}`))(client);
client.on(eventName, (...args) => event.emit(...args));
delete require.cache[require.resolve(`./Events/${file}`)];
});
client.login(process.env.BOTUSERNAME, process.env.PASSWORD);
client.on('rawFbns', (data) => console.log(data));
mongoose.connect(process.env.DATABASEURL, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => {
client.logger.log(`Connected to the Mongodb database.`, `ready`);
}).catch((err) => {
client.logger.log(`Unable to connect to the Mongodb database. Error:`+err, `error`);
});
};
initialize();