Just a short change. I realized I can return the user in the GetUser() method Since the members is of type DUser, I can just return the user variable as is instead of making a new DUser So it you just return the user in the foreach loop it is a type DUser and it makes the process truly dynamic so it you add anything new to DUser, you don't have to change any code in the level engine class I also realized that at the start of the AddXP() method I forgot to set levelledUp = false Because every time a user levels up its going to set it as true and it will remain as true until the method is executed again, and at that point u want it to be false again because at that point, someone is not going to level up unless the XP threshold has been reached So please set levelledUp to false at the very start of this method
thank you for video bro, it's very helpful! but i have one question. how i can edit info in json file using command? for example: command to mange member level
if you wanna change someones level within a command its literally the same thing as the AddXP method, but this time, you arent storing anything, but you are changing something So what you need to do is foreach through the JSON file and search for the user you want to change level, and all you have to do is change their Level property and write the changes to the file Its a lot similar to the AddXP method in a sense because in that method im altering the XP they have and their level
Hello, I am making a bot based on your video as it is the latest discord bot programming lesson. for the video, I found a few notes that I changed for correct work: 1) you use the name and not the id to check the existence and storage of user data, and this is bad, since a person can rename himself as someone else's and he will give out someone else's user data. 2) you use "var addedXP = LevelEngine.AddXp", it is desirable to put a filter so that the commands "!" did not activate this function since it occupies a file and commands that require data from this file will not be able to read (well, or even then set a delay) 3) you said that you can’t notify a person (@user), I somehow managed to do it, but I can’t find this code anymore. i sent data received with "e.Author.Mention.Replace("@!", "@")" or "ctx.User.Mention.Replace("@!", "@")" 4) In the AddXp method, it is better to use "while (user.XP >= MaxXP * user.Level)" instead of "if (user.XP >= MaxXP * user.Level)" because the user can type more than "MaxXP * user. Level" several times.
Thanks for the feedback. Yeah a lot of it has room for improvement and I'm glad uve picked up on it. Its all part of the learning experience so I'm sure uve taken this existing core and really transformed it. Props to u for pointing all this out 👍👍👍
Just a short change. I realized I can return the user in the GetUser() method
Since the members is of type DUser, I can just return the user variable as is instead of making a new DUser
So it you just return the user in the foreach loop it is a type DUser and it makes the process truly dynamic so it you add anything new to DUser, you don't have to change any code in the level engine class
I also realized that at the start of the AddXP() method I forgot to set levelledUp = false
Because every time a user levels up its going to set it as true and it will remain as true until the method is executed again, and at that point u want it to be false again because at that point, someone is not going to level up unless the XP threshold has been reached
So please set levelledUp to false at the very start of this method
More like this please. Very useful vid, thank you
Hello how do I do this through a slash command?
thank you for video bro, it's very helpful! but i have one question. how i can edit info in json file using command? for example: command to mange member level
if you wanna change someones level within a command its literally the same thing as the AddXP method, but this time, you arent storing anything, but you are changing something
So what you need to do is foreach through the JSON file and search for the user you want to change level, and all you have to do is change their Level property and write the changes to the file
Its a lot similar to the AddXP method in a sense because in that method im altering the XP they have and their level
@@samjesus8 thank you, bro
Hello, I am making a bot based on your video as it is the latest discord bot programming lesson. for the video, I found a few notes that I changed for correct work:
1) you use the name and not the id to check the existence and storage of user data, and this is bad, since a person can rename himself as someone else's and he will give out someone else's user data.
2) you use "var addedXP = LevelEngine.AddXp", it is desirable to put a filter so that the commands "!" did not activate this function since it occupies a file and commands that require data from this file will not be able to read (well, or even then set a delay)
3) you said that you can’t notify a person (@user), I somehow managed to do it, but I can’t find this code anymore. i sent data received with "e.Author.Mention.Replace("@!", "@")" or "ctx.User.Mention.Replace("@!", "@")"
4) In the AddXp method, it is better to use "while (user.XP >= MaxXP * user.Level)" instead of "if (user.XP >= MaxXP * user.Level)" because the user can type more than "MaxXP * user. Level" several times.
Thanks for the feedback. Yeah a lot of it has room for improvement and I'm glad uve picked up on it. Its all part of the learning experience so I'm sure uve taken this existing core and really transformed it. Props to u for pointing all this out 👍👍👍