presence update

Wondering how to differentiate when a person starts a new activtity, such as listening to spotify and that the activity should not be exisiting in old presence. For exaple, user is playing a game + spotify, if spotify updates , the game remains same, it should not show game.

  if (!oldPresence) return;
    if (newPresence.activities.length === 0) return;

    const { guild, userId, activities } = newPresence;

    console.log(newPresence);

    let str = "";

    for (const activity of activities) {
      const { type, state, details, name } = activity;

      if (type === ActivityType.Custom) continue;
      if (type === 6) continue; // vc channel activity

      const isSameActivity = oldPresence.activities.some((oldActivity) =>
        activity.equals(oldActivity)
      );

      if (isSameActivity) continue;
    }
    if (!str) return;


here's what i got so far, seems to work. The .equals how does it work? it seems like if i am running vs code since few hours (timestamp property of activity showing start as few hours ago) but edit a new file (createdTimestamp updates), it says true. Is there anyway for me to modify it so it only show when the presence actually starts (running vs code)
Was this page helpful?