3

I have been looking for a little while to find how to check what device a user is on in Discord with my bot.

for example, if a person initiates the command "device" if they're on a phone it will return with "phone".

I found a method to do this but don't know how to use it, its Docs are here.

If someone can explain this to me that would be great.

MIMJA156
  • 107
  • 1
  • 8

1 Answers1

4

You can access Presence#clientStatus through a User or GuildMember. This means that you can use Message#author#presence#clientStatus to get the information from the author of the command.

Beware that this property will be null if you have not enabled the GUILD_PRESENCES intent (more info). From there it returns an object with the potential properties web, mobile, and desktop (none of these are guaranteed). For example, if I'm on the discord mobile app and desktop app, it would show:

{
  desktop: 'online',
  mobile: 'online'
}

The value per property could either be online, idle, or dnd. More examples:

  • I'm offline
{}
  • I'm currently on the Discord website but I left the room so now I'm using Discord on my phone
{
  web: 'idle',
  mobile: 'online',
}
  • I'm trying to do homework so I don't want anyone to ping me but I keep procrastinating and looking at Discord
{
  web: 'dnd',
  desktop: 'dnd',
  mobile: 'dnd',
}
Lioness100
  • 8,260
  • 6
  • 18
  • 49