Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from Dex-404/dev
Browse files Browse the repository at this point in the history
@Dex-404| Update - index.js
  • Loading branch information
sandarutharuneth authored Feb 6, 2023
2 parents a700901 + f98277d commit c8cd1a4
Showing 1 changed file with 31 additions and 30 deletions.
61 changes: 31 additions & 30 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,17 @@ const fs = require("fs");

client.config = config;

(async () => {
await connect(config.MONGODB_URI).catch((err) =>
console.log(chalk.red(`[MONGO DB]: Error: ${err}`))
);
})();

handler.handleMongoEvents("./events/mongo", client);

// Initialise discord giveaways
const manager = new GiveawaysManager(client, {
storage: false,
updateCountdownEvery: 10000,
default: {
botsCanWin: false,
embedColor: "#2F3136",
reaction: "🎉",
lastChance: {
enabled: true,
content: ` ⚠️ **Last chance to enter**`,
threshold: 5000,
embedColor: "#2F3136",
},
},
});
const { Database } = require("quickmongo");
const db = new Database(config.MONGOLAB_URI);
db.once("ready", async () => {
console.log(chalk.green(`[MONGO DB]: Connected`));
if (await db.get("giveaways") === null) await db.set("giveaways", []);

});

client.giveawaysManager = manager;
GiveawaysManager(client);


//<:confetti:984296694357319730>
Expand Down Expand Up @@ -79,9 +65,30 @@ fs.readdir("./events/giveaways", (_err, files) => {
});
});

// if(config.privateMessageInformation === true) {
// fs.readdirSync('./events/giveaways').forEach(async (dir) => {
// const events = fs.readdirSync(`./events/giveaways/${dir}`).filter(file => file.endsWith('.js'));

// for(const file of events) {
// const event = require(`./events/giveaways/${dir}/${file}`);
// if(event.name) {
// // console.log(`[GIVEAWAYS EVENTS]` + ` Event ${file.split(".")[0]} loaded!`);

// client.giveawaysManager.on(event.name, (...args) => event.execute(...args, client))
// delete require.cache[require.resolve(`./events/giveaways/${dir}/${file}`)];
// } else {
// console.log(`[GIVEAWAYS EVENTS]` + ` Failed to load event: ${file.split('.')[0]}!`);
// continue;
// }
// }
// });
// } else {
// return console.log(`[WARNING]`.yellow + ` Private Message Information is disabled!`);
// }

/* Load all events (mongo based) */

handler.handleMongoEvents("./events/mongo", client);


// let interactions be a new collection ( slash commands )
client.interactions = new Discord.Collection();
Expand All @@ -103,10 +110,4 @@ fs.readdir("./slash/", (_err, files) => {

// Login through the client
client.login(config.token);
// (async () => {
// await connect(MONGOLAB_URI).catch((err) =>
// console.log(chalk.red(`[MONGO DB]: Error: ${err}`))
// );
// })();


0 comments on commit c8cd1a4

Please sign in to comment.