So, I have a JSON file, let's call it my_file.json
, that contains some information:
[
{
"user": 0,
"infos": []
},
{
"user": 1,
"infos": []
}
]
On my BOT, I want to create a function to access the "infos"
of a user id:
import json
@bot.command()
async def getinfo(ctx, *, user_id):
user_id = int(user_id)
with open("my_file.json") as f:
for _ in json.load(f):
if _["user"] == user_id:
# HERE I WANT TO SEND THE CONTENTS OF "infos" OF THE
# CORRESPONDING USER ID IN A FILE, EACH LIST ITEM SEPERATED BY
# A NEWLINE
So I want the BOT to send the file containing all the items of the "infos"
list of the corresponding user id, each of them separated by a newline, but I don't want the file to be saved on my computer. Is this possible?