首页 > 解决方案 > 如何使用会员计数器制作机器人状态?

问题描述

我想为我的机器人设置会员计数器状态,代码是:

client.on('ready', () => {
    setInterval(() => {
      targetGuild = client.guilds.cache.get('I Pasted my Guild ID Here')
      if(targetGuild) {
          client.user.setPresence({ game: { name: targetGuild.memberCount + 'Members', type: 'WATCHING' }, status: 'online'  })
                .then(console.log)
                .catch(console.error);
      }
    }, 1000 * 60 * 5);

});

错误是:

client.user.setPresence(...).then is not a function

标签: javascriptdiscorddiscord.js

解决方案


在 discord.js v13 中,setPresence返回 a ClientPresence,而不是像v12中的 Promise ,因此没有.then()方法。


推荐阅读