你好,我正在尝试检查存储在 json 文件中的 id guild 问题是当机器人离开服务器时,它在调试中为我提供了 ID 服务器,但它没有删除 json 中服务器 id 中的项目,为什么. 这是我尝试过不止一次的尝试
client.on("guildDelete", function(guild){
var languagePath = "./locales/language.json"; // path that i create file json
var languageRead = fs.readFileSync(languagePath); // read data json file
var languageFile = JSON.parse(languageRead); //if it is ready for use
serverID = guild.id // get id server
console.log(serverID) // just for test if print to me id server in debug and check if the ID is also present in the json file because sometimes it changes
if (!serverID) return console.log("no setup yet") // check if exists id server.
delete languageFile[serverID]
//i am pretty sure that in the first item there is an id server but here it does not delete it.
});
这里证明 https://pasteboard.co/JTNjrvZ.png 我还检查了 ID 是否是相同的数字,我发现它是相同的数字,但仍然没有删除项目