我制作了一个简单的不和谐验证机器人,但我想让机器人状态观看 # 人 验证(# 是我的服务器中有多少人).我看到一些机器人有它,但我不知道如何制作它.这是我当前的机器人状态代码:
if (Object.keys(this.config.presence).length !== 0) {this.user.setPresence({游戏: {名称:this.config.presence.name,类型:this.config.presence.type},状态:在线"}).catch(console.error);} 解决方案首先你需要设置间隔命令来更新成员.
您不需要使用 this.user 进行此操作.以前的答案方法将仅显示 cached用户,所以这是错误的方式,因为在机器人启动时,您将在此集合中没有用户.
如果您需要在自己的服务器上显示成员,您可以这样做:
bot 启动后,5 分钟后更新.
为了测试,您可以将 }, 1000 * 60 * 5) 更改为 }, 1000);
I made a simple discord verify bot, but I want to make the bot status to watching # people verifying (the # is how many people in my server). I see some bots have it, but I don't know how to make it. Here is my current code for the bot status:
if (Object.keys(this.config.presence).length !== 0) { this.user.setPresence({ game: { name: this.config.presence.name, type: this.config.presence.type }, status: "online" }).catch(console.error); }解决方案
At the first you need set interval command to update member.
You dont need use this.user for this operation. The previus answer method will display only cached users, so its wrong way, because on bot start, you will has no users in this collection.
If you need display members on your own server you can do like this:
client.on('ready', () => { setInterval(() => { targetGuild = client.guilds.get('GUILD ID HERE') if(targetGuild) { client.user.setPresence({ game: { name: targetGuild.memberCount + ' people verifying!', type: 'WATCHING' }, status: 'online' }) .then(console.log) .catch(console.error); } }, 1000 * 60 * 5); });
After bot start, this will update after 5 minutes.
For test you can change }, 1000 * 60 * 5) to }, 1000);
更多推荐
如何创建一个有 memberCount 的机器人状态?
发布评论