nyx/events/level.js

29 lines
848 B
JavaScript
Raw Normal View History

2021-06-12 12:53:51 +02:00
const Levels = require("discord-xp");
2021-06-24 09:53:19 +02:00
const client = require("../bot");
2021-07-13 05:17:39 +02:00
require("dotenv").config();
Levels.setURL(process.env.MONGO);
2021-06-12 12:53:51 +02:00
client.on("message", async message => {
if (!message.guild) return;
if (message.author.bot) return;
2021-07-13 05:17:39 +02:00
const guild = await client.data.getGuild(message.guild.id);
if (guild.Level == false) return;
2021-06-12 12:53:51 +02:00
const user = await client.data.getUser(message.author.id);
var max = 30;
if (user) {
if (user.Tier) {
if (user.Tier == 1) max = 120;
if (user.Tier == 2) max = 90;
if (user.Tier == 3) max = 60;
}
}
const randomAmountOfXp = client.function.rndint(10, max);
const hasLeveledUp = await Levels.appendXp(
message.author.id,
message.guild.id,
randomAmountOfXp
);
if (hasLeveledUp) {
const user = await Levels.fetch(message.author.id, message.guild.id);
}
});