-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LevelUp event #1
Comments
Hello! As shown in my client.on('levelUp', async (message, data, role) => { your_code_here }) this is basically just a callback function, whenever the user levels up, as long as you have that code somewhere, it will trigger the event, allowing you to proceed however you wish! If I was able to help, you may close the issue, otherwise please let me know how I should explain :) |
Thanks for this info so something like const xp = require("simply-xp");
const client = require("..");
client.on("levelUp", async (message, data) => {
message.channel.send({
content: `🥳 <@${data.userID}>, **Level Up! 🎉** Now you are **level ${data.level}** in **${message.guild.name}**.`
});
// if the user levels up gets a role, right?
xp.lvlRole(message, data.userID, data.guildID);
return;
})
will be fine? |
Yep! That should work |
Ok cool, if the user gets the role how can i add an extra message? Like the normale message will be 🥳 <@${data.userID}>, **Level Up! 🎉** Now you are **level ${data.level}** in **${message.guild.name}**.`
});
and if the user get a role after it reaches a certain level the bot should add a text like: You got this role etc |
It's possible! So you can just do something like this: client.on("levelUp", async (message, data, role) => {
// level up message goes here
if (role != undefined) {
<Channel>.send(`Hey! You have also received the following roles: ${<@&role.role>}`)
<xp>.lvlRole(message, data.userID, data.guildID)
}) Which allows you to check if there are roles for the new level TIP: |
That's amazing, ty for your help. I'll open this issue when I'll have other questions :) |
yo I got another question lol, if i use all the functions of simply-xp what intent should I put? Only guild and guild messages? |
For my test bot, I've only used the It really depends on how you're using them. If it works, then you should be alright |
Ok cool but is there a way we can customize this if (!user) throw new Error('[XP] NO_DATA | User has no XP data.') Because as you know if a user has no xp it will throw that error, so how can we avoid that |
There isn't a way to change it @ core, HOWEVER! You can actually avoid this by using If the user is NOT found, then you can use |
Nice, when I'll be free I'll send ex example and you can tell me if its correct |
If I want to get more xp on Saturday and normal xp on the other days, something like this willl be fine, right? const date = new Date();
if (date.getDay() === 6)
xp.addXP(message, message.author.id, message.guild.id, {
min: 20,
max: 35,
});
else
xp.addXP(message, message.author.id, message.guild.id, {
min: 1,
max: 15,
});
// I'm using this in my messageCreate event so I need the guild messages intent also how can I get in the console the amount of xp that an user gets |
Good day! Thank you for your patience; the code you gave should function as intended. Regarding the XP logging, you can see that it does so at Our Guide!, so you'll just need to return it, something like: xp.addXP(message, userid, guildid, { .. }).then(res => { console.log(res) })
// or you can also do this
var res = await xp.addXP(message, userid, guildid, { ... })
console.log(res) Both of them should return something like |
Oh thanks a lot |
Since there is a rank card will you ever make a leaderboard card where are displayed the top 10 people |
Although we do not currently have a leaderboard card, that is an interesting thought! I'll add it to my to-do list; I might introduce it in v2! In the meantime, you can still set a limit of 10 people by following the steps on Our Documentation if you haven't already known :D |
yea I know how to make it but it will be cool if you add that :) |
Hello again! About that, if I set more roles at the same level, the bot adds them but sends a message saying that it has only added one role, how can I fix that :) |
Hey there! Can you provide some logs, and the message it's saying? I'll look further into this matter. |
I got both roles tho |
Assuming you're fetching the role(s) from the levelUp event, I might be able to crack down the issue, please hold! I'll reply as soon as possible. |
Sure, take your time |
Hey There! I've identified the bug and fixed it: |
Good job, so that was a bug, right? |
Yeah! A minor mistake was made in earlier versions of the package. |
Oh ok, feel free to close this issue |
Hello once more! Simply-XP has just been updated to |
With the new version @Abadima |
Can you give a better example about the level up event since there is the same example on the documentation and Im not sure what to do
The text was updated successfully, but these errors were encountered: