2022-11-18 11:01:15 -05:00
|
|
|
const { addxp, BASE } = require('../db/econ.js');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function setCard(bot, interaction) {
|
|
|
|
|
bot.mongoconnection.then(async (client) => {
|
|
|
|
|
const dbo = client.db(interaction.guildId).collection('SETUP');
|
|
|
|
|
dbo.findOne({_id: "LEVELING"}).then((doc) => {
|
|
|
|
|
const bkBuffer = Buffer.from(doc.card, 'base64');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function textToLevels(bot, message, xp_list) {
|
2022-12-26 14:40:50 -08:00
|
|
|
if (!bot.inDebugMode && message.guild.id == bot.home_server) { return; }
|
|
|
|
|
|
2022-11-18 11:01:15 -05:00
|
|
|
const author = message.author;
|
|
|
|
|
// doc.xp + (BASE.XP * doc.rank)
|
|
|
|
|
bot.mongoconnection.then((client) => {
|
|
|
|
|
const serverOpts = client.db(message.guild.id).collection('SETUP');
|
|
|
|
|
serverOpts.findOne({_id: "LEVELING"}).then((doc) => {
|
|
|
|
|
if (!doc) {
|
2022-12-26 14:40:50 -08:00
|
|
|
serverOpts.insertOne({_id: "LEVELING", enabled: false, card: undefined, text: undefined, col: "#FFFFFF"});
|
2022-11-18 11:01:15 -05:00
|
|
|
const server = bot.guilds.cache.get(message.guild.id);
|
2022-12-19 20:48:01 -05:00
|
|
|
server.members.fetch(message.guild.ownerId).then(function(owner) {
|
2022-11-18 11:01:15 -05:00
|
|
|
// Implement `setup leveling enable`
|
|
|
|
|
owner.send("Interactive Leveling has been added to your server!\nTo enable it, use `/setup leveling enable`");
|
|
|
|
|
});
|
|
|
|
|
} else if (doc.enabled) {
|
|
|
|
|
const dbo = client.db(message.guild.id).collection(author.id);
|
|
|
|
|
dbo.findOne({"balance": {$exists: true}}).then((doc) => {
|
|
|
|
|
const newXp = doc.xp + Math.ceil((BASE.XP * doc.rank) / 4);
|
2022-12-26 14:40:50 -08:00
|
|
|
addxp(bot, message, dbo, newXp, xp_list, true);
|
2022-11-18 11:01:15 -05:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {textToLevels};
|