Files
selmerBot/commands/Selmer Specific/msgLevels.js
T

39 lines
1.5 KiB
JavaScript

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) {
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) {
doc.insertOne({_id: "LEVELING", enabled: false, card: undefined, text: undefined});
const server = bot.guilds.cache.get(message.guild.id);
server.members.fetch(guild.ownerId).then(function(owner) {
// 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);
addxp(message, dbo, newXp, xp_list, true);
});
}
});
});
}
module.exports = {textToLevels};