I am trying to write a list of users from a discord server into a json using python, but I keep receiving this error.
Ideally I want to turn my dict {Snowflake(USERID#): Member(user=User(id=Snowflake(USERID#), username='USERNAME', discriminator='#', bot=None), nick=None),
Into a JSON file only containing the bot=none
users in a format like this:
{
"USERID#1": {
"Username": "USERNAME1"
},
"USERID#2": {
"Username": "USERNAME2"
},
...
}
Edit:
- Error text is
TypeError: keys must be str, int, float, bool or None, not Snowflake
- My code to initially pull the data into the dict and attempt to write it to the json is:
import interactions
from interactions import Button, ButtonStyle, SelectMenu, SelectOption, ActionRow, spread_to_rows
import json
memberslist = await guild.get_all_members()
print(memberslist)
membersdict = {Member.id: Member for Member in memberslist}
with open("playersbackup.json","w") as n:
json.dump(membersdict,n, indent=4)
from Fix keys must be str, int, float, bool or None, not Snowflake error
No comments:
Post a Comment