const statuses = [
{ name: "ABC", type: ActivityType.Streaming },
{ name: "DEF", type: ActivityType.Watching },
{ name: "GHI", type: ActivityType.Listening },
{ name: "JKL", type: ActivityType.Playing },
];
client.on('ready', (c) => {
console.log(`✅ ${c.user.tag} is online!`);
setInterval(() => {
var newStatus = statuses[Math.floor(Math.random() * statuses.length)];
client.user.setActivity(newStatus);
}, 10000);
});
statuses.json
(目前为止什么都没有)
我尝试添加一个 JSON 文件(下面显示的随机示例):
[{
name: "ABC", type: ActivityType.Streaming
name: "DEF", type: ActivityType.Watching
name: "GHI", type: ActivityType.Listening
name: "JKL", type: ActivityType.Playing
}]
但是,我仍然不确定如何将其调用到我的主 index.js 文件中。
使用以下信息创建一个 json 文件:[{name: "Orange", type: "fruit"}],然后在主 JS 文件中使用 'FS' 导入,如下所示:
const fruits = JSON.parse(fs.readFileSync('fruits.json'));