小编Poo*_*yan的帖子

ENOENT:没有这样的文件或目录,打开“文件名”

我需要来自 .json 文件的一些数据,但收到此错误:

Error: ENOENT: no such file or directory, open '../Jsons/eshop.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Object.execute (C:\Users\Pooyan\Desktop\PDM Bot Main\commands\shop.js:9:24)
    at module.exports (C:\Users\Pooyan\Desktop\PDM Bot Main\events\guild\message.js:114:15)
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: '../Jsons/eshop.json'
}
Run Code Online (Sandbox Code Playgroud)

我的代码:

Error: ENOENT: no such file or directory, open '../Jsons/eshop.json'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at Object.execute (C:\Users\Pooyan\Desktop\PDM Bot Main\commands\shop.js:9:24)
    at module.exports (C:\Users\Pooyan\Desktop\PDM Bot Main\events\guild\message.js:114:15)
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: '../Jsons/eshop.json'
}
Run Code Online (Sandbox Code Playgroud)

我认为这就是您所需要的,但如果需要任何其他代码,请对其进行评论。我正在使用discord.js v13和node.js 16

javascript node.js discord discord.js

6
推荐指数
1
解决办法
2万
查看次数

我想让我的机器人状态 24/7 显示

我想让我的机器人状态 24/7 显示

这是我的代码:

client.once('ready', () => {
    console.log('pdm bot is online'); 
        setInterval(() => {
          targetGuild = client.guilds.cache.get('My guild id')
          client.user.setPresence({ 
            activities: [{ name: `${targetGuild.memberCount} Users`, type: 'WATCHING' }], 
            status: 'online'
            });
        }, 1000 * 60 * 5);
    
    });
Run Code Online (Sandbox Code Playgroud)

我的问题是,当我关闭命令提示符时,代码不再运行,但我的活动将为空。

javascript node.js discord discord.js

0
推荐指数
1
解决办法
740
查看次数

标签 统计

discord ×2

discord.js ×2

javascript ×2

node.js ×2