Question:
For some reason I’m running into a weird issue where my code is looping in on itself and I have no idea where I’d begin with a fix.
Repl link:
https://replit.com/@BlazeT1/DiscordRPG-1?s=app
I wrote the code in python first and the game was working there but after adding discord functionality and the database stuff it broke completely. I assume I need to rewrite the code completely which will be fun.
Here’s the code in question:
In player class:
def save_to_db(self):
player_dict = deepcopy(vars(self))
db["players"][self.user_id] = player_dict
And in the create command:
if user_id not in db["players"] or not db["players"][user_id]:
player = create_player(name, race, user_id)
This was the error:
Value error: circular reference detected
Can you send the complete traceback of the error?
There is just the starting of error in the image which is useless
1 Like
Part 1 because I can only send 1 pic at a time as a new user:
There are wayy more errors than just that…
Stuff like NameErrors
because you didnt define the variable in scope or other reasons. Spent some time fixing those but still many are left. Please fix those simpler ones before trying to fix the one you are asking. Due to other errors, i cant recreate the main error
I tried to run your code and it said
AttributeError: 'NoneType' object has no attribute 'strip'
This suggests that your DISCORD_TOKEN
is None
.
Are you sure you got the Token correctly?
1 Like
Probably, remember that Secrets cannot be accessed from the cover page, which is likely what caused the NoneType
error.
1 Like
- please make sure you are using asyncdb, not normal replit db as discord.py is async, and having synchronized requests can severely slow down or stop your code (doc for async db)
from replit import AsyncDatabase
from os import getenv
db = AsyncDatabase(getenv("REPLIT_DB_URL"))
- Can we please have the full error in text so that we can be sure we are not missing any parts.
1 Like