Discord 如何只编辑json文件的一部分来设置前缀?

Discord 如何只编辑json文件的一部分来设置前缀?,discord,discord.js,Discord,Discord.js,我有这个代码,我想编辑一个json文件,但我不想替换所有的代码,只是,(messge.guild.id).prefix的一部分 index.js c.on(“消息”,消息=>{ if(message.content.startsWith(“前缀”)){ 函数jsonReader(文件路径,cb){ fs.readFile(文件路径,(错误,文件数据)=>{ 如果(错误){ 返回cb&&cb(错误); } 试一试{ const object=JSON.parse(fileData); 返回cb&&

我有这个代码,我想编辑一个json文件,但我不想替换所有的代码,只是,(messge.guild.id).prefix的一部分

index.js

c.on(“消息”,消息=>{
if(message.content.startsWith(“前缀”)){
函数jsonReader(文件路径,cb){
fs.readFile(文件路径,(错误,文件数据)=>{
如果(错误){
返回cb&&cb(错误);
}
试一试{
const object=JSON.parse(fileData);
返回cb&&cb(空,对象);
}捕捉(错误){
返回cb&&cb(错误);
}
});
}
jsonReader(“./pepe_config.json)”,(err,pepe_config)=>{
如果(错误){
控制台日志(err);
}
const guildid=message.guild.id;
让prefix=pepe_config[guildid]。前缀;
const arg=message.content
.切片(7)
.trim()
.拆分(“”)
if(arg.length<0)返回message.channel.send(“前缀no valido”);
const obj=pepe_config;
const String=JSON.stringify(obj.replace(前缀,arg.join(“”));
fs.writeFile('./pepe_config.json',字符串,err=>{
如果(错误){
console.log('Error write file',err)
}否则{
console.log('已成功写入文件')
}
});
});
}});
pepe_config.json

{ 
    "763103796514521139" : {
        "prefix"        :"p!",
        "color"         :"RANDOM"
    }
}
控制台错误

            let prefix = pepe_config[guildid].prefix; 
                                    ^

TypeError: Cannot read property '770362030174502922' of undefined
如果我可以在其他场合使用(let前缀),我不知道为什么会发生这种情况