discordjs / discord.js

A powerful JavaScript library for interacting with the Discord API
https://discord.js.org
Apache License 2.0
25.36k stars 3.97k forks source link

Can't change activity of a non-bot client #2541

Closed TotomInc closed 6 years ago

TotomInc commented 6 years ago

Please describe the problem you are having in as much detail as possible:

I am trying to make a small userscript that display the current track playing from SoundCloud on Google Chrome, linked to my Discord user account. It works well with a bot-client but the user activity don't change when I'm logged in with a user account.

When testing the script, I am logged from both the Windows Discord client and the SoundCloud tab. Maybe it's because of 2 simultaneous connections on a same (user?) account.

As a side note, I can change the status (from idle to online, DND to idle, ...).

Include a reproducible code sample here, if possible:

// retrieve the track title from the soundcloud tab
let track = 'track title from soundcloud tab';

// once track title retrieved, set the new user activity with the track name
client.user.setActivity(track)
    .then((activity) => console.log('[DiscordJS EXTENSION] activity set:', activity));

Further details:

devsnek commented 6 years ago

you should use RPC for this: https://github.com/discordjs/RPC

TotomInc commented 6 years ago

Alright, thanks!

TotomInc commented 6 years ago

Discord RPC is currently in private beta according to Discord dev-docs, I get Invalid Origin error.

devsnek commented 6 years ago

@Totomlnc you should use IPC not websockets

TotomInc commented 6 years ago

Looks like discordjs/rpc is broken with ipc transport type.