Answer the question
In order to leave comments, you need to log in
How to make a personal entry in a txt document and its subsequent output in a message?
I have a *profile command.
I want a server member to write their data
to it. The problem is to display personal data.
That is, when a person writes a command, it is necessary that it displays exactly his data that he indicated in the message, and not just all the data from txt
Here is the code:
# profile
@client.command(aliases = ['prof','profile','профиль'])
async def __profile(ctx, member: discord.Member):
author = ctx.message.author
now_date = datetime.datetime.now()
file = open('profile.txt', encoding = 'utf-8')
emb = discord.Embed(title = 'Профиль пользователя', color=0x20B2AA)
emb.add_field(name="Вошёл на сервер:",value=member.joined_at, inline=False)
emb.add_field(name='Псевдоним:',value=member.display_name, inline=False)
emb.add_field(name = 'Время пользователя' , value = '{}'.format(now_date), inline=False)
emb.add_field(name = 'День рождения' , value = f'{file.read()}', inline=False) # вывод данных
emb.set_thumbnail(url=member.avatar_url)
file.close()
await ctx.channel.purge(limit = 1)
await ctx.send(embed = emb)
# edit profile
@client.command(aliases = ['eprof','editprofile','свояинфа'])
async def __eprofile(ctx, message):
file = open('profile.txt', 'a', encoding = 'utf-8')
file.write(f"\n{message}") # запись данных
file.close()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question