Answer the question
In order to leave comments, you need to log in
How to add a user to the User#1234 list?
I'm making a Discord bot that adds user data to a list like User#1234 if the user is not in the list. But I can’t add this data to the list or they are not saved
here is the code
@bot.command()
async def start(ctx):
if ctx.author == bot.user:
return
if ctx.author not in u_l:
if ctx.channel.recipient.bot == True:
return
else:
u_l.append(ctx.author)
print(ctx.author)
print(u_l)
return
else:
return
User#1234
print(ctx.author)
[<User id=1234567890123456789 name='User' discriminator='1234' bot=False>]
And this is the same value, but stored in a list user_base_info = (ctx.author.name + '#' +ctx.author.discriminator)
u_l.append(user_base_info)
Answer the question
In order to leave comments, you need to log in
If you want to store users, it's best to store them by their ID, the name and discriminator can easily be changed, and are not reliable storage methods.
All variables in python (as in most other languages) are stored in RAM, and are "forgotten" as soon as the process ends. If you want to store data between "sessions", you need to save it to disk and load it from there. The simplest version of this, in my opinion, is json .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question