Issue
I am trying to get the online status of any given user within a guild that the bot is in?
Currently I can get the online status of message author. However, I want to be able to get any users online status such as the following:
const member = client.getMemeber(ID OR USERNAME);
const online_status = member.presence.status;
And that it returns null, online, dnd, idle
.
Solution
To get a member,you want a guild first:
const guild = client.guilds.cache.get(guildId);
, then you can get the member: const member = guild.members.cache.get(userId);
. Alternatively, you can get a user directly from the client: const user = client.users.cache.get(userId);
, but a user doesn't have a presense property.
const member = client.guilds.cache.get(guildId)?.members.cache.get(userId);
console.log(member.presense.status);
Answered By - DeMineArchiver
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.