M
M
Mark Eshkilev2020-08-02 15:20:54
JSON
Mark Eshkilev, 2020-08-02 15:20:54

Added - } in profile.json file when executing code??

Such a problem...When executing this code

if(profile[rUser.id].warns ==20){
        message.channel.send('Пользователь забанен на сервере по причине того что у него 20/20 Предупреждений');
        message.guild.member(rUser).ban({ reason: '20/20 Предупреждений' });
        profile[rUser.id].warns -= 20;
        fs.writeFile('./profile.json',JSON.stringify(profile),(err)=>{
            if(err) console.log(err);
        });
    };

the - } sign is added to the profile.json file, although in fact it should not be added
here profile.json itself
{"590373859874570251":{"coins":1302,"warns":0,"xp":54,"lvl":11},"610091146768678933":{"coins":39,"warns":0,"xp":13,"lvl":1},"725607950655291473":{"coins":99,"warns":0,"xp":13,"lvl":2}}

that is ... the problem is that when the code is executed, the sign - } is added to the very end
and because of this there is a problem due to the fact that the sign - } is added, how to remove this problem ??...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Pokrovsky, 2020-08-02
@mark_edinoroglove

{
    "590373859874570251": 
    {
        "coins": 1302,
        "warns": 0,
        "xp": 54,
        "lvl": 11
    },
    "610091146768678933":
    {
        "coins": 39,
        "warns": 0,
        "xp": 13,
        "lvl": 1
    },
    "725607950655291473": 
    {
        "coins": 99,
        "warns": 0,
        "xp": 13,
        "lvl": 2
    }
}

It's all right, isn't it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question