每 10 分钟更改一次 setGame 文本

Bur*_*rcu 1 javascript discord discord.js

我正在尝试在 Discord Bot 上做一些事情我想每 10 分钟更改一次 setGame 文本

例如,10 分钟后,"#StayHome" => client.user.setGame( #StayHome); 或 10 分钟后再次 "!watch" = > client.user.setGame( !watch);

我希望它每 10 分钟更改一次我想要的 setGame 文本。我怎样才能做到这一点 ?

client.user.setStatus("online");
client.user.setGame(`!help`);
Run Code Online (Sandbox Code Playgroud)

MUH*_*YAS 5

const bot = () => {
  let status = ["!help", "!watch", "#StayHome"];
  let index = 0;
  let interval = setInterval(() => {
    client.user.setStatus("online");
    client.user.setGame(status[index]);
    index++;
    if (status.length === index) clearInterval(interval);
  }, 1000 * 60 * 10);
};
bot();
Run Code Online (Sandbox Code Playgroud)