discordjs/rpc

const DiscordRPC = require("./discord-rpc/src");

const scopes = ["rpc", "rpc.api"];

const clientId = "2313**177****3703**";

DiscordRPC.register(clientId);

const rpc = new DiscordRPC.Client({
transport: "websocket",
origin: "https://discord.com",
});
rpc.on("ready", () => {
console.log("Authed for user", rpc.user);
// rpc.selectVoiceChannel("s");
});

rpc.login({ clientId: clientId });
const DiscordRPC = require("./discord-rpc/src");

const scopes = ["rpc", "rpc.api"];

const clientId = "2313**177****3703**";

DiscordRPC.register(clientId);

const rpc = new DiscordRPC.Client({
transport: "websocket",
origin: "https://discord.com",
});
rpc.on("ready", () => {
console.log("Authed for user", rpc.user);
// rpc.selectVoiceChannel("s");
});

rpc.login({ clientId: clientId });
No description
28 Replies
d.js toolkit
d.js toolkit2d ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
monbrey
monbrey2d ago
A quick google search suggests the origin isn't even required. Try just dropping it
Fyzy
FyzyOP2d ago
it is.. I intitally did try without passing origin
monbrey
monbrey2d ago
Did you see this part of the page?
If you're connecting to the RPC server from within a non-browser application (like a game), you just need to make sure that the origin is sent with the upgrade request when connecting to the WebSocket. For local testing, we recommend testing with an origin like https://localhost
Fyzy
FyzyOP2d ago
let me try but what if i am using broswer...
monbrey
monbrey2d ago
If you're connecting to the RPC server from within a browser, RPC origins are usually in the form SCHEME://HOST[:PORT], where SCHEME is typically https or http, HOST is your domain or ip, and PORT is the port of the webserver from which the user will be connecting (omitted for ports 80 and 443). For example, https://discord.com would be used if the user were connecting from https://discord.com/some/page/url
Fyzy
FyzyOP2d ago
nope not working
No description
Fyzy
FyzyOP2d ago
yeah orgins are auto filled by browser, but i do need to set origin url in discord don't i ? and where is that field ? i can't find it anywhere thats the main probelm
monbrey
monbrey2d ago
I mean RPC is old and deprecated so The docs say they don't even approve new apps for it
Fyzy
FyzyOP2d ago
then how am i suppose to set rich presence ?
Fyzy
FyzyOP2d ago
lib is deprecated not rpc itself
No description
Fyzy
FyzyOP2d ago
No description
Fyzy
FyzyOP2d ago
what the actual heck...
No description
monbrey
monbrey2d ago
I did mean the lib, my bad for not being clearer But that does bring me back to "is origin even required"
Fyzy
FyzyOP2d ago
yeah and Game SDK has been archived both
SirH
SirH2d ago
websocket doesn't work and hasn't worked in like ever
Fyzy
FyzyOP2d ago
caz it requires rpc origin field to be set which i can't find anywhere in discord
SirH
SirH2d ago
no origin field is necessary. just switch to ipc
Fyzy
FyzyOP2d ago
but i want to embed it in broswer named pipes aren't supported in browser
SirH
SirH2d ago
impossible
Fyzy
FyzyOP2d ago
no its not
Fyzy
FyzyOP2d ago
No description
SirH
SirH2d ago
it's outdated the documentation on the websocket info is completely false
Fyzy
FyzyOP2d ago
really? *spechless* Is there any way for a broswer app to set rich presence ? whats that then premid should have used websocke to connect? how else it can connect but it runs in browser env no way i have read the rpc codes, it uses named pipe for ipc and named pipe isn't supported by browser well anyways let me try Browser environment yeah what that suppose to mean no, a extension cannot access named pipes thats what i found i looked through entire internet ... Browser environment means website btw ... ;-; whatever
Fyzy
FyzyOP2d ago
No description
Fyzy
FyzyOP2d ago
i take a look again, it is running in nodejs environment not browser environment it is an electron app not a extension code, so they are using electron app as a bridge between extension and discord to sets the activity so, they are like using extension to connect to the electron app and then that electron app sets the activity I never said they can't...browser environment meant by a context where javascript runs, which is isolated by browser and they don't have access to low level things like named pipe thats what i mean from beginning argument is waste, so lets forget it
Matthieu
Matthieu2d ago
An extension is still JavaScript executed in a browser environment
Fyzy
FyzyOP2d ago
yeah ... was an waste of time ig

Did you find this page helpful?