#I have a problem with my code (Discord.py)
31 messages · Page 1 of 1 (latest)
In this if
i got you
If self.bot.tr is not evaluating to True, the code will not enter the if block and will always go to the else part.
thats the problem
also check if its not overwritten
I don't understand, what can I do to solve it?
Where do you set self.tot
in the init
So maybe it would make sense to show us that code, no?
Ok, im sorryy
I changed the code but the problem is more or less still the same
@deep spruce ?
That N gets reset everytime a button is pressed
And how do I prevent this from happening?
Don't set N = 0 everytime?
and how do I declare N then?
set N=0 outside the function and set it as a global variable?
Won't work as soon as multiple people use the bot but yeah
Also not sure how that'd work with sharding
🗿
ooh
hmhmhm
i'm not familiar with making discord bots
i just said smth random that popped in my mind lol
No you're correct
My point was just that building distributed systems can be quite challenging (and that building Discord bots for more complex interactions is probably not the best idea)
How do I fix this problem then?
That's the easy fix
Doing it properly definitely involves some sort of synchronization between the shards, storing state in the interaction for each user in some database, etc.
self.tot will never be true because you never even declare it inside that class