#I have a problem with my code (Discord.py)

31 messages · Page 1 of 1 (latest)

kindred saffron
kindred saffron
misty quail
#

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

kindred saffron
#

I don't understand, what can I do to solve it?

deep spruce
#

Where do you set self.tot

kindred saffron
#

in the init

deep spruce
#

So maybe it would make sense to show us that code, no?

kindred saffron
#

Ok, im sorryy

#

I changed the code but the problem is more or less still the same

#

@deep spruce ?

deep spruce
#

That N gets reset everytime a button is pressed

kindred saffron
#

And how do I prevent this from happening?

deep spruce
#

Don't set N = 0 everytime?

kindred saffron
#

and how do I declare N then?

oak sun
deep spruce
#

Also not sure how that'd work with sharding

#

🗿

oak sun
#

hmhmhm
i'm not familiar with making discord bots
i just said smth random that popped in my mind lol

deep spruce
#

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)

kindred saffron
#

How do I fix this problem then?

deep spruce
#

Doing it properly definitely involves some sort of synchronization between the shards, storing state in the interaction for each user in some database, etc.

rocky sky
# kindred saffron

self.tot will never be true because you never even declare it inside that class