i wanted to set a member counter status for my bot the code is:
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);
});
And the error is:
client.user.setPresence(...).then is not a function
在setPresence
v13 中, setPresence
返回一个ClientPresence
,而不是v12 中的 Promise ,因此没有.then()
方法。
If you are using djs v13 you need to use:
client.user.setPresence({
activities: [{ name: `${targetGuild.members.cache.size} Members` }],
status: 'online',
type: 'WATCHING'
});
And also there is no .then()
method because in discord.js v13 setPresence
doesn't return a Promise
but ClientPresence
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.