I am coding a discord.js bot, and I'm trying to get the activity of an user (games he is playing, spotify things, etc.).
When I take a look at the documentation, I see a Presence
class, and a .activities
property, that is supposed to return an array of the user's activities.
However, I get the "Cannot send empty message" when I run my code, with an activity running.
Here is my actual code:
let member = message.users.mention.first || message.author;
message.channel.send(member.presence.activities);
It is likely that the user has no activity and so the
member.presence.activities
returns null, therefore resulting in theempty message
error.To catch this, it is simple:
Also, if the
activities
param is an array, surely you would have to select from the array using the normal syntaxarr[0]
for example?