javascript - 如何使用会员计数器制作机器人状态?
问题描述
我想为我的机器人设置会员计数器状态,代码是:
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
解决方案
在 discord.js v13 中,setPresence
返回 a ClientPresence
,而不是像v12中的 Promise ,因此没有.then()
方法。
推荐阅读
- python - 有没有办法限制句子中的单词数量?
- laravel - 如何使用 Vue 和 Laravel 访问另一个 docker 卷文件?
- python - 特定单词的 Python 正则表达式
- android - 在 CameraX analyze() 中执行异步代码的最佳方法是什么?
- r - 如何找到数据帧每一行的最小值索引?
- r - 在 Databricks 中调用 R 工作簿
- jquery - 当 JQuery 的其余部分工作时,为什么所有 Ajax 方法都失败了
- python - 说我还没有宣布,即使我清楚地有
- sql-server - 如何让kafka复制目标表中的源表结构
- r - 将列值作为 R 中的列名