#๐ Repeating message
18 messages ยท Page 1 of 1 (latest)
@median surge
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Could you please send your code, additionally I don't even see the code related to sending the level up msg
A) Please send the code in a text format, like in a pastebin or as a massage.
it's really difficult to read & search things up in an image.
B) you seem to calculate new_level_up_xp but never use it; and never reassign level_up_xp โ when the next comparison comes, the statement xp > level_up_xp would still remain True. Hence, the level up message.
just rechecked the image, it seems that you do call UPDATE on the database; but use level_up_xp for it and not new_level_up_xp instead.
it is kinda hard to confirm since the image cuts off.
@median surge (forgot to ping, lol)
https://paste.pythondiscord.com/P66A theres the code
https://paste.pythondiscord.com/P66A there's the code as well
@median surge yep, there's your problem.
from your code -
if xp >= level_up_xp:
cur_level += 1
new_level_up_xp = math.ceil(50 * cur_level ** 2 + 100 * cur_level + 50)
await message.channel.send(f"{message.author.mention} has leveled up to level {cur_level}!")
# USE 'new_level_up_xp' INSTEAD
cursor.execute("UPDATE Users SET level = ?, xp = ?, level_up_xp = ? WHERE guild_id = ? AND user_id = ? ", {cur_level, xp, level_up_xp, guild_id, user_id})
Fixed โ
if xp >= level_up_xp:
cur_level += 1
new_level_up_xp = math.ceil(50 * cur_level ** 2 + 100 * cur_level + 50)
await message.channel.send(f"{message.author.mention} has leveled up to level {cur_level}!")
cursor.execute("UPDATE Users SET level = ?, xp = ?, level_up_xp = ? WHERE guild_id = ? AND user_id = ? ", {cur_level, xp, new_level_up_xp, guild_id, user_id})
btw you don't need math.ceil() there, that equation would always result in a positive integer number.
thank you so much
forgot to mention, please ignore the indentation, I am writing this on the phone >.<
so no tabs . . .
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.