2019-11-05 15:52:46 +00:00
|
|
|
const db = require("../utils/database.js");
|
2019-09-13 20:02:41 +00:00
|
|
|
const logger = require("../utils/logger.js");
|
|
|
|
const misc = require("../utils/misc.js");
|
|
|
|
const client = require("../utils/client.js");
|
|
|
|
|
|
|
|
// run when the bot is added to a guild
|
|
|
|
module.exports = async (guild) => {
|
2019-09-15 04:22:29 +00:00
|
|
|
logger.log("info", `[GUILD JOIN] ${guild.name} (${guild.id}) added the bot. Owner: ${client.users.get(guild.ownerID).username}#${client.users.get(guild.ownerID).discriminator} (${guild.ownerID})`);
|
2019-11-05 15:52:46 +00:00
|
|
|
const guildDB = new db.guilds({
|
2019-10-28 20:21:06 +00:00
|
|
|
id: guild.id,
|
|
|
|
tags: misc.tagDefaults,
|
|
|
|
prefix: "&"
|
|
|
|
});
|
2019-11-05 15:52:46 +00:00
|
|
|
const memberInfo = {};
|
|
|
|
for (const member of guild.members) {
|
|
|
|
memberInfo[member.id] = {
|
|
|
|
xpAmount: 0,
|
|
|
|
level: 0
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const xpDB = new db.xp({
|
|
|
|
id: guild.id,
|
|
|
|
members: memberInfo,
|
|
|
|
enabled: false
|
|
|
|
});
|
2019-10-28 20:21:06 +00:00
|
|
|
await guildDB.save();
|
2019-11-05 15:52:46 +00:00
|
|
|
await xpDB.save();
|
2019-09-13 20:02:41 +00:00
|
|
|
};
|