#archive-rpc-help
21942 messages · Page 22 of 22 (latest)
Yes I don't get why you require auth if you redirect to youtube
lmao
Setting a rich presence doesn't require authorization
Why it happens then
const RPC = require("discord-rpc")
const clientId = "843505868275449866";
const scopes = ["rpc", "messages.read"];
const client = new RPC.Client({ transport: "ipc" });
RPC.register(clientId)
client.on("ready", () => {
console.log("Logged in as", client.application.name);
console.log("Authed for user", client.user.username);
client.selectVoiceChannel("950022618369650768");
});
// Log in to RPC with client id
client.login({ clientId, scopes });
Cause you clicked on it?
First off why do you have messages.read scope
Ah, selecting a voice channel
I know nothing of that side of the RPC.
I only know how to set the rich presence.
However I do recommend using game SDK if you plan to do advanced stuff.
That scope caused auth thing
I cant use this basic stuff too lol
Yeah, what are you trying to do here?
Set RPC or set a voicechannel
Just trying to use rpc to set button in my bio
Then I can tell you this copypasted code won't work xd
Removed voice channel line
Yeah
const RPC = require("discord-rpc");
const clientId = "843505868275449866";
const client = new RPC.Client({ transport: "ipc" });
client.on("ready", () => {
console.log("Authed for user", client.user.username);
});
// Log in to RPC with client id
client.login({ clientId });
you should use
<RPCClient>.setActivity(optionsObject);
in the ready event to set your presence.
It worked
Thanks
i get this error when pressing save changes after adding an asset, does anyone know why??
Is there a way to do in-app authorization with scopes without deploying the client_secret to production?
Sounds a bit like an XY problem, what are you trying to do?
For RPC you are already fairly limited in functionality and locked to people in the test group- if you are referring to general OAuth2, you'd be looking for the Implicit Grant flow
whats a discord-rpc
I built an application that gets all the people the user's voice channel, even after they switch channels.
I use the ['rpc', 'rpc.voice.read'] scopes.
What Im doing right now is the app opens a link in the default browser where the user authenticates and the token is sent back to the app. But it would be better to have it just authenticates in discord itself as users need to login to the browser.
wait how did you do this?? I’m looking to do something similar rn
Does anyone know how I can open OAuth2s links on the client instead of the browser?
i thought the rpc does that automatically
for me at least
using the code in the readme on github it opens directly in the client
Can you give some example or url reference, please? 🙏
`const clientId = '287406016902594560';
const scopes = ['rpc', 'rpc.api', 'messages.read'];
const client = new RPC.Client({ transport: 'websocket' });
client.on('ready', () => {
console.log('Logged in as', client.application.name);
console.log('Authed for user', client.user.username);
client.selectVoiceChannel('81384788862181376');
});
// Log in to RPC with client id
client.login({ clientId, scopes });`
this literally opens in the client
Oh, let me check because I'm using transport: 'websocket'
and this is in https://github.com/discordjs/RPC
well i think i used websocket as well
nvr mind i used ipc, but i cant figure out what the redirect_url should be cause I always get "not a well formed url"
An URL listed in your application oauth page
LOL, I was like 'why i'm getting Error: connection closed?' XD
like thats the thing im changing
what do i do then
yea so u need a redirect url in the application oauth page
Uhm, you like... Run it? Lol
as if thats not what im doing rn
this is what i always get
nothing else
The redirect Uri btw is only needed if you use RPC scopes and I've heard someone using an empty string instead and get it working properly (didn't try personally though)
Can you show your code?
you are still missing a redirect uri
where
in the login method
i have it in the application portal
wait
Yea that works, but it only opens on the web, I want to open it in the client.
I found that Discord have its own protocol, so it opens links in client instead of the browser, example:
Client: discord:///users/273911143284867076
Browser: https://discord.com/users/273911143284867076
And I was looking for something similar
so we need one in both???
You should set the redirect_uri in the login options
And it should be a registered redirect URL in the Dev portal
hmm
interesting
ok
so like this?
and then the url inside
uri not url, but I dont think thats a thing looking at the sauce code
ok
wait it is
god I hate the docs of rpc
bruh
its still not working
but its redirectUri according to sauce
ohh

now it says invalid client
show full error
Then your id is wrong ig
the id is copy pasted from the application portal
What about the client secret?
wait we need that as well?
Yeah iirc you need it in order to use RPC scopes
yes
BRUH
ok
someone really needs to redo the whole documentation for this
ikr
Yeah 😂
At least types are ok
:0
no errors
types ARE the problem
Mmh?
you dont see shit in the docs
https://imageing.eu/shared/OfmiIxY.png lemme ask god what its supposed to contain
I meant Typescript type definitions
Lol
and now i dont see any pop-ups
awesome
yeah, why in hell is that not documented on docs
fr
¯\_(ツ)_/¯
bro i think is broken or something
sometimes nothing happens
then once it connects with no error
and then other times it says invalid client
all with the exact same code
no changes
istg this is broken
im getting 'invalid_client' with the same code before that worked
Mmm I tried this
discordRPCClient.login({
clientId: 'id',
scopes: [
"identify",
"email",
"connections",
"rpc",
"rpc.notifications.read",
"rpc.voice.read",
"rpc.voice.write"
],
redirectUri: 'http://localhost:53134',
clientSecret: 'secret'
});
rpc.activity.read doesn't work idk why
and this worked for you?
yup
hmm
where did you get discordRPCClient from
oh i mean
im getting invalid client
after hitting authorize on the pop-up
oh it is just a new DiscordRPC client
discordRPCClient = new DiscordRPC.Client({ transport: 'ipc' });
ah ok
where did Constants come from
it is 'ipc'. I just have a json file with all of that info
ah ok
and you have var DiscordRPC = require('discord-rpc') before that right?
yup
interesting
i have literally the same thing
show your code
hide your secret, but not the id
I want to do this thing in express (so I can hide the clientSecret) in my electron app. I guess this will not help me to do what I want...
no I want to see the id
ok
i made a new application and replaced the old id with the new one and the old secret with the new one
and it still didnt work
it's clientSecret
hmm
strange
cause it worked earlier
HOLY
IT WORKED
BRO WHAT
HOW
XD
DUDE THX
OMG
RPCClient#login()
Performs authentication flow. Automatically calls Client#connect if needed.
Does anyone know how can I use this method without using clientSecret?
I have an express app wich generates an access_token and a refresh_token
you will have to use clientSecret somewhere, but since you have an access_token you should go straight to authorize(), which will require clientSecret
Let me check, ty
ok i meant to say authenticate() not authorize()
RPCClient#authorize() PRIVATE
Authorize
oh
yea its private but i think you can still use it
okok
RPCClient#authenticate() PRIVATE
Authenticate
yea and turns out authenticate doesnt really need clientSecret
according to the source
Nice, I'll try it, ty
yea np
You can just do
client.login({ clientId: '', accessToken: '' });
you can't pass a refresher token as you still need to provide your client secret to refresh it
I've tried using that, but It didn't work, this works fine
await options.client.authenticate('auth_token');
I guess this happens because I've already connected to the client using client#connect, so I just need to authenticate
yea, since you already connected, you dont have to login ans the login method does both auth and connect for you
I see...
I have a dumb question, I'm creating an electron app that will be public in the future, I can't put in the clientSecret in the source code right?
I'm asking for this because I cannot find an example on the internet :(
So I'm opting to create an express server which handles all credentials
Yes, you cant have the secret in the app,
I also have an electron app and I handle auth using the electron custom protocol
I wish discord would give us an option to host atleast 1 serverless function
Would make life so much easier
Given the limitations of developer RPC, is there a reason you can't just provide users the source code and let them make their own application + token?
If you use your own, you are capped at 50 people, and they have to go through localhost anyway
^^^^^^^
SyntaxError: Malformed arrow function parameter list```
Not sure what i've done wrong but any help would be appricated
async, not await
damn it, yeah sorry
const client = new DiscordRPC.Client({ transport: "ipc" });
const { id } = require("./config.js");
DiscordRPC.register(id);
client.on("ready", async () => {
await client.setActivity({
largeImageKey: "kayne",
largeImageText: "kayne",
startTimestamp: Date.now()
})
});
client.login({ id }).catch(err => console.log(err))```
Why does this always return ```Error: connection closed```?
login takes clientId not id
yeah i got that
i just put id as the variable
oh wait
does it need to spelt exactly like that?
yes
either do clientId: id or rename id to clientId
alright thanks
guys i am trying to install discord-rpc package but it shows some errors
Show the whole log
@nimble yarrow
You dont need to ping me on every message...
sorry haha
well u know the solution'
?
And the rest of the log? Its not complete
Including what you wrote
oh
thats it
the discord-rpc version in your package.json seems to be outdated
let me see
i have to install the 4.0.1 right?
that's the version of your package, not of the dependency
showing error too when i try to install that
oh haha
here
but it shows the same error
maybe try installing with --no-optional?
npm i discord-rpc--no-optional?
wym
separate from the name
oh okay
npm i discord-rpc --no-optional
yeah
same err
wtf is happening
try updating npm
if npm is on the latest update, try uninstalling and reinstalling it
I would try to delete the package-lock.json and the node_modules folder than run npm i
const RPC = require('discord-rpc');
const clientId = '469789887298535424';
const scopes = ['rpc', 'rpc.api', 'messages.read'];
const client = new RPC.Client({ transport: 'websocket' });
client.on('ready', () => {
console.log('Logged in as', client.application.name);
console.log('Authed for user', client.user.username);
});
client.login({ clientId, scopes });
H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\client.js:111
reject(new Error('connection closed'));
^
Error: connection closed
at WebSocketTransport.<anonymous> (H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\client.js:111:16)
at Object.onceWrapper (node:events:646:26)
at WebSocketTransport.emit (node:events:526:28)
at WebSocketTransport.onClose (H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\transports\websocket.js:42:10)
at WebSocket.onClose (H:\IdrisGaming\Discord Bot\RPC\node_modules\ws\lib\event-target.js:136:16)
at WebSocket.emit (node:events:526:28)
at WebSocket.emitClose (H:\IdrisGaming\Discord Bot\RPC\node_modules\ws\lib\websocket.js:246:10)
at Socket.socketOnClose (H:\IdrisGaming\Discord Bot\RPC\node_modules\ws\lib\websocket.js:1127:15)
at Socket.emit (node:events:526:28)
at TCP.<anonymous> (node:net:687:12)
rpc.api isnt a valid scope
also you should use ipc instead of websocket
what's the difference?
one works
the other doesnt

still the same error ._.
const RPC = require('discord-rpc');
const clientId = '469789887298535424';
const scopes = ['rpc', 'messages.read'];
const client = new RPC.Client({ transport: 'ipc' });
client.on('ready', () => {
console.log('Logged in as', client.application.name);
console.log('Authed for user', client.user.username);
});
client.login({ clientId, scopes });
how about using the id of your application...
ah
H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\client.js:178
const e = new Error(message.data.message);
^
Error: OAuth2 Error: invalid_request: Missing "redirect_uri" in request.
at RPCClient._onRpcMessage (H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\client.js:178:19)
at IPCTransport.emit (node:events:526:28)
at H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\transports\ipc.js:138:18
at decode (H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\transports\ipc.js:92:5)
at Socket.<anonymous> (H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\transports\ipc.js:120:7)
at Socket.emit (node:events:526:28)
at emitReadable_ (node:internal/streams/readable:578:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 5000,
data: {
code: 5000,
message: 'OAuth2 Error: invalid_request: Missing "redirect_uri" in request.'
}
}
the error is pretty clear
what's a "redirect_uri" ?
I just need to pass a random URL in it?
you pass whatever redirect url you have
basically
I tried discord-rpc's npm page and I got this:
H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\client.js:64
const e = new Error(r.status);
^
Error: 400
at H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\client.js:64:21
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RPCClient.authorize (H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\client.js:215:22)
at async RPCClient.login (H:\IdrisGaming\Discord Bot\RPC\node_modules\discord-rpc\src\client.js:143:21) {
body: { redirect_uri: [ 'Not a well formed URL.' ] }
}
add a redirect url in the oauth2 page
done
then pass the same url to redirectUri in client.login
and then pass clientSecret to client.login as well
the discord-rpc docs seriously needs to be rewritten
any success?
I'll try right now
ok
thanks for info
np
it works fine
thanks!
np
is there something like « a bot which is in more than 100 guilds cannot do a RPC for a user » ?
no?
wdym?
a limit
a limit for rpc?
^
How can Discord.js RPC write activity status if it requires approval?
activities.write allows your app to update a user's activity - requires Discord approval (NOT REQUIRED FOR GAMESDK ACTIVITY MANAGER)
rpc.activities.write for local rpc server access, this allows you to update a user's activity - requires Discord approval
At the same time, all other functions except setActivity do not work without permission
again, no
the user has to approve the application when the rpc starts, its a popup in discord?
yeah I read your answer he was just asking ._.
there is no popup window. I'm interested in the very fact that djs RPC does activity, which is possible only with the separate approval of the discord, if I understand correctly
and where do you have that from
I don't quite understand what you mean
where did you read that
oauth2 isnt rpc tho?
I don't recall rpc requiring discord approval
Yeah rpc scope doesn't require authorization
Do someone know what is qos?
{
automaticGainControl: true,
echoCancellation: false,
noiseSuppression: false,
qos: false,
silenceWarning: true,
deaf: false,
mute: false,
input: {
availableDevices: [ [Object], [Object] ],
device: '{0.0.1.00000000}.{ecd61229-2e38-4800-a135-af4660f36c5f}',
volume: 100
},
output: {
availableDevices: [ [Object], [Object], [Object] ],
device: '{0.0.0.00000000}.{aeb959dd-a06b-4a0e-ac20-d24a6a0b5d8d}',
volume: 100
},
mode: {
type: 'VOICE_ACTIVITY',
autoThreshold: false,
threshold: -44.92307692307692,
shortcut: [],
delay: 20
}
}
RPCClient#getVoiceSettings()
Get current voice settings
qos | boolean | state of voice quality of service
Okok, ty c:
The screenshot above. That's not it?
Don't care about the screenshot I'm speaking from experience.
I'm literally using the rpc scope without any redirect_uris or authorization
Could be the rpc lib uses an older version or smth and the screenshot is from new, dunno
It's so confusing...
you only need to be whitelisted to do it over websocket, not for ipc
ah that explains it
makes sense
the docs really needs to be redone
Feel free to
i dont have time rn
ill see if i can do it later
No-one cares/knows enough/has time to do it
exactly
What's the bottom line? The RPC does not require permission, but then why does selectTextChannel and other functions not work?
did you enable those scopes
rich presence is pretty much the only thing you can do with rpc without oauth2
the rest requires authorization
So the rich presence does not require oauth2?
no
Yeah, it's hard enough to understand. Thanks anyway
Where can I find more information about it?
about oauth2?
More about those cases where oauth2 is not required (if you're talking about the rich-presence feature being pretty much the only one that doesn't require authorization)
i'm not sure if there are any others
I just don't quite understand why rich presence doesn't require authorization, but is mentioned in the oauth2 article
the article says "for local rpc server access"
that's why i made the distinction between websocket (using the local rpc server) and ipc
Do I understand correctly that ipc in this case is a situation where, for example, the application changes the user's presence in discord on the same device?
yeah
Thank you so, so much! 💟
Is there a way to get a user voice settings by id?
something like RPCClient#getVoiceSettings()
Can you do Client.clearActivity without stopping the current process?
My Console always gets closed when doing client.clearActivity
Probably because the process has nothing else to do
i get this error Error: Could not connect
Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.
Thank you for using the Chewie express.
it used to work but it dosnt now
The answer stays the same
show your code if you dont know any further
where do you host that
my pc durng development
and during production
no it only runs during development
i just reloaded discord and it connected :/
That's the point. It has something to do
client.on("ready", async () => {
console.log("ready")
console.log(client.user?.username)
setInterval(() => {
config = JSON.parse(
fs.readFileSync(
path, "utf8"
)
);
let i=0
Object.keys(config).forEach(key => {
if(key == ""){
i+=1
}
})
let lenght = Object.keys(config).length
if(i == lenght-1){
console.log("cleared")
setTimeout(() => {
client.clearActivity()
}, 3000);
}
else{
client.setActivity({
details: config.Details,
state: config.State,
buttons: [
{
label: config.Button1,
url: config.Url1,
},
{
label: config.Button2,
url: config.Url2,
},
],
largeImageKey: config.LargeImage,
largeImageText: config.LargeImageText,
smallImageKey: config.SmallImage,
smallImageText: config.SmallImageText,
startTimestamp: config.StartTimestamp,
endTimestamp: config.EndTimestamp
}, process.pid);
}
}, 5 * 1000);
});
client.login({ clientId: config.ClientID});
It has to check on interval if there is a new value (I update the JSON and get a new value if updated every 5 seconds)
why dont you just set the new activity, there is no need to clear it in the first place, discord is just gonna update it for you
But I don't want anything as Activity
I am not exactly sure what u mean
What exactly do mean?
I meant what I said, but your code doesnt make much sense to me either 
every few seconds it gets the JSON value and sets it. When the JSON has empty values then the Presence should be cleared. But when this happens it stops randomly
So IDK what to do lmao
can an rpc app thing read channels in guilds?
i could make a discord bot and then have the code for starting rpc in that bot 
RPC doesn't work with bots
😦
so i could not have a bot activate the rpc client?
thats annoying lolz
ight rpc is a lost cause
RPC is meant for users, not for bots
A bot doesnt need RPC
i know
but i want to use a bot to change the rpc
and start it
That does work, if you run the bot on your local machine.
oh
nice
trying around with scopes for rpc was a waste of an hour of my lifge
so if this works thats great
have a button to change rpc and activate it 
so how can I clear the activity without the process getting ended?
clearActivity works for me
clearActivity
sended it @nimble yarrow
sry I wasn't there @nimble yarrow
sucks, now I'm not available
Moin @steady edge
this isnt a small talk channel
Yeah I sended it @nimble yarrow If u got time then u can look over it
hmm
does this set RPC on the bot ?
no
Hello, does the latest discord-rpc supports node 8? I know this thing is old asf but i must use it sadly
if not, which discord-rpc version that supports node 8
first of all
why do you need such an old version of node
i want to make adobe extension, i wan't to use the CEP 9.0 which uses node 8
ohh
interesting
mm, let me try something
https://github.com/lolitee/adobe-discord-rpc/ there is actually extension that does this, but it need CC 2019 which i think uses node 12 which is not supported with older version
want to create something that support older version
god turns out CC 2017 uses iojs 1.2.0
well the only way is to use external library, run with local latest nodejs instead of using after effects one
finally did it
nice
god it take so long
because this thing is not directly tied to after effects (using external app, so i guess i need to make this app autostart
Thx @nimble yarrow I found the wrong value and fixed it.
I get this error when i use ipc transport:
Error: Could not connect
at Socket.onerror (/home/runner/rich/node_modules/discord-rpc/src/transports/ipc.js:32:16)
at Object.onceWrapper (node:events:642:26)
at Socket.emit (node:events:527:28)
at emitErrorNT (node:internal/streams/destroy:164:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)```
Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.
so i cant make rpc in repl.it?
yep
so i cant keep it alive 24/7.. :/
yep
ok
Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.
rpc doesn't not works on bots and in replit, you must run it on your pc
hmm
read what chewie sent above
I am the devil of
Things to consider when getting a connection closed/could not connect error
so i am trying to make a bot where i can press buttons to set my presence. So far, works like a charm. Only issue is when i close dc and open again. I tried setting an rpc.destroy and then logging it in again, but doesnt seem like that works either. Any thoughts on if this is possible?
youd think destroying the rpc client and logging in newly would allow you to set you presence with it again
also dont see the difference between closing the rpc and opening it again through the console and calling rpc.destroy
discord-rpc is not for bots, its for local desktop clients only
Wasn't my question.
I have a BOT where I can press buttons to set MY presence
yea that’s what im saying
many people mistake this channel for rich presence for bots
this channel is for rpc for local clients
you should be asking your question in #djs-help-v14
dude
read their question again
their talking about bots
this channel is for ‘discord-rpc’
aka the library for interacting with local clients
they want rich presence for bots, which this channel isn’t for
this is that I’m saying rn
in the docs for discord.js I don’t see anything about rpc.destroy
they are not talking about bots, the bot is running on the same machine, which makes it possible to manage rpc with the bot
read their message again
which you failed for a third time now
ohhhhhh
lol
rip I understood something else
ok sry abt what I said I understood your question wrong, but wdym by “close dc”?
do you mean close discord?
When they stop discord and start it again.
ah ok
Xd
The discord bot handles my presence, but it doesn't allow my rpc to reconnect (or even do anything) when I've closed the discord app
It's weird, even if I make rpc destroy itself and log it again it just doesn't want to
so after closing, it stops working even if you re open discord?
Yes
strange
Like it's lost connection and doesn't reopen it
interesting
And annoying
Xd
@zinc matrix you can't use the same client multiple times
?
after it's destroyed/disconnected you need to create a new client
Ah
Well thats shit
haha
okay
use ipc instead of websocket, also rpc.api doesnt exist anymore
yea someone should
it’s so outdated
It's possible integrate chrome extension with Discord RPC?
no
@deft crypt you can run a server (like express) for the rpc stuff on localhost and let the extension interact with that
Alright, thank u. I made a radio player for the chrome browser and I want integrate wit discord rpc when playing something station
What language is that?
C#? Java? Idk
Not js tho
that’s c#
thanks
that's C++ / C due to use of memset and pointer-of operators
const RPC = require('discord-rpc');
const clientId = '851945606799949844';
const scopes = ['rpc', 'messages.read'];
const client = new RPC.Client({ transport: 'ipc' });
client.on('ready', () => {
console.log('Logged in as', client.application.name);
console.log('Authed for user', client.user.username);
client.selectVoiceChannel('960837263405764618');
});
// Log in to RPC with client id
client.login({ clientId, scopes });
const e = new Error(message.data.message);
^
Error: OAuth2 Error: invalid_scope: The requested scope is invalid, unknown, or malformed.
at RPCClient._onRpcMessage (D:\github\email\node_modules\discord-rpc\src\client.js:178:19)
at IPCTransport.emit (node:events:394:28)
at D:\github\email\node_modules\discord-rpc\src\transports\ipc.js:138:18
at decode (D:\github\email\node_modules\discord-rpc\src\transports\ipc.js:92:5)
at Socket.<anonymous> (D:\github\email\node_modules\discord-rpc\src\transports\ipc.js:120:7)
at Socket.emit (node:events:394:28)
at emitReadable_ (node:internal/streams/readable:573:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 5000,
data: {
code: 5000,
message: 'OAuth2 Error: invalid_scope: The requested scope is invalid, unknown, or malformed.'
}
}
what's wrong with scope?
Nothing - But you are missing clientSecret and redirectUri in client.login()
thank you
this did not fix the error
Then you missed something.
you dont have redirectUri or clientSecret
you need to give those as well
Thats what we already elaborated, thanks for repeating me.
oh lol
didnt read that properly

How do I use rpc with scopes without exposing clientSecret?
u cant sadly
If I can't, I guess no one can. It means I can just extract this key from other apps that use discord rpc
I guess so
what u can do tho
I just thought of it
An app to mute discord remotely
And unmute
send like an encoded version or an encrypted version of clientSecret to a server
actually nvr mind lol
Yeah I can't control discord client from my server
yea for that especially u would need clientSecret
I realized that lol
I don't know why discord haven't implemented this themselves
something to hide clientSecret?
Nah, remote muting and unmuting
well they kind of have it in the discord overlay
Using discord client from other device
but then fully remote isn’t done yet
why would you do this tho?
I usually speak from my desktop PC cause it has a good mic, but sometimes I work from my laptop and lay on my couch
mhm
oh ic
I move my mic closer to me so others can hear me, but I can't mute and unmute
why not?
oh wait
ur on the call from the desktop?
Yea
ohh ic
to do something like that
if you could make a p2p connection between the desktop and laptop
and send the rpc calls through there
I have a prototype without the remote part, I think I'll just make an API for this app
wait i just remembered
iirc mute and deafen is synced through desktop and web right?
cause MAYBE muting on one desktop could mute on the other
idk if it will work tho
Idk tbh, I don't use web
like desktop as well
Desktop definitely not
iirc I muted on one laptop on the desktop app and the other laptop it muted
but I wasn’t in a vc
Hmm
it’s bc it runs on electron
I don't think it works
i remember it worked without being in a vc
idk abt being in a vc tho
If I connect to a vc from one PC, it doesn't show my mute status on other PC to me
On Android it doesn't even show me on vc participants list 
same here when im on ios
sadly it doesnt :(
this has nothing
is there any other docs for rpc with node?
there is an example if you wanna to see that https://github.com/discordjs/RPC/tree/master/example
Yeah used that but don't know the use of those keys
hi! I'm trying to use the rpc package, but I have an "invalid origin" error... any way to fix this?
I copied the code from the documentation, and replaced client id with my actual client id.
show it
remove rpc.api, replace websocket with ipc and provide a clientSecret and redirectUri to login if you want to use scopes
i tried using this:
client.login({ clientId, scopes, clientSecret: process.env.CLIENT_SECRET, redirectURI: "http://127.0.0.1:3233/lgi" });
but it returns me "OAuth2 Error: invalid_request: Missing "redirect_uri" in request."
(but at least the authorization popup opens)
I have the same error when using redirect_uri or redirectUri
@nimble yarrow
do you have redirectUri in the application page?
and is it the same one as the one you put there?
yup
yup too
did I say redirectUri or redirectURI
none or them are working tho
it will always be redirectUri and you have to have the same uri set on the dashboard
thats all there is to that error
nothing less, nothing more
huh
actually
show your dashboard
oh wait im dumb
I actually forgot to put the redirect uri on the dashboard
thought so
sorry for making you losing your time, I thought I already set it
Nice. Somehow my rpc doesn't work anymore. Idk why but it just stopped working. Error is always that it timed out
It worked before
Hi, I've recently started learning about RPCs, as per my understanding, it's basically some functions exposed on a particular port of server but I can't really understand is that how is it any better from normal REST api client that we already use to communicate with discord?
Also, why do we need electron for rpc call, is it used only for browser client libraries?
we dont need electron
and rpc is the only way to communicate with the actual user, thus its locally
I was checking example you've setup in rpc repo, it uses electron, is it only for gui for that example?
we can't use rpc with bots? 
there are some RPCEvents mentioned in constants that bots can use tho
that is correct
this constraint is on discord or the library?
discord
thanks

i was wondering, can detail, state, and largeImage have links?, like how spotify rpc will take u go the artist, song, album in the web/app?
Spotify is a special case
RPC assets must be uploaded to the webportal
Nope they support urls now thanks to Ian 1
WOT
This epic
Nope it was Mason I think, #889939268733132870 message
guys What is Discord-Rpc
see channel topic
oh tnx
how do I sub to an event in v4.0.1??? with callback
(specifically interested in ACTIVITY_JOIN and ACTIVITY_JOIN_REQUEST
Custom wallpaper? OwO
<RPCClient>.on("event", (callback) => {});
Hey, I was wondering if it's possible to remove/fake the origin. I'm trying to establish a connection between a webpage (chrome) and my discord client. But it gives me an invalid origin error everytime.
dont think rpc runs from chrome
Only because chrome adds an origin header
my goal is to remove that header
because if i do so it will work
Sadly we aren't experienced in Chrome extensions/modifications
put it in a preload
how would i clear the presence?
but i just got this error ```js
C:\Users\Fr0g_\node_modules\discord-rpc\src\transports\ipc.js:155
this.socket.write(encode(op, data));
^
TypeError: Cannot read properties of null (reading 'write')
at IPCTransport.send (C:\Users\Fr0g_\node_modules\discord-rpc\src\transports\ipc.js:155:17)
at C:\Users\Fr0g_\node_modules\discord-rpc\src\client.js:159:22
at new Promise (<anonymous>)
at RPCClient.request (C:\Users\Fr0g_\node_modules\discord-rpc\src\client.js:157:12)
at RPCClient.clearActivity (C:\Users\Fr0g_\node_modules\discord-rpc\src\client.js:540:17)
at Timeout.onTimeout (C:\Users\Fr0g\Desktop\myRPC\dddddd\node_modules\rrpc\index.js:45:12)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)```
if you mean bot activity status like Playing Servers etc thing : client.user.setPresence({ activity: null }); this could work
help
discord-rpc
not discor rpc
I suggest you read the error
but the project is the same
Exactly
Its not supposed to be
??
because discord- is not a module..
oh i am dum
Xd
client.user.setPresence({ activity: null });
^
TypeError: client.user.setPresence is not a function
at Timeout._onTimeout (C:\Users\Fr0g_\Desktop\myRPC\dddddd\node_modules\rrpc\index.js:122:17)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)```
client.destroy()
doesnt work
client.clearActivity() doesnt work either
the library is a mess
discord.js v13 right?
no
i wasnt using djs
im using discord-rpc
its for the user
const rpc = require("discord-rpc");
var client = new rpc.Client({ transport: 'ipc' });```
You don't do client.user?
Unless the code changed
wdym
oh
that still doesnt work
client.setPresence isnt a function
idk
the docs lied
It's setActivity
Unless it got changed
OH
OH IT WORKS TYYY
TYYY TYY TYYY
YESS
IV BEEN LOOKING FOR DAYS
You should look at RPC docs, not at djs docs lul
i did
they had smthn like clear activity
and that didnt work
i even looked at the code example they gave
I'm pretty sure rpc docs don't have client.user tho
yeah they dont
its just client
client.clearActivity([pid])
And that does what the name implies
it yeets the activity
it didnt work for me
what does instance do in args ?
Is there a way to fetch more than 50 messages using the rpc?
nvm found it
hi
bye
Guys, can anyone help with understanding the RPC discord? I'd be very grateful. I would like to ask about the process of working with it in practice
hi guys, can i connect a discord rpc with just opening a program without getting the discord token of the user? (only with the id)
do you mean clientSecret?
i mean to log with the rpc to a user id
for example put this rpc to an user that opened the program
just make sure that code gets executed when the user opens the program
discord needs to run in the background
everything else is automated
ohhh so when the user open the program it put the rpc automated?
and it search the discord user automated too?
rpc connects to the rpc server that gets started by the discord application
nice
and for what is this? const client = new rpc.Client({ transport: 'ipc' })
transport ipc?
thats just the transport mode
there is websocket and ipc, but websocket is whitelisted only
i see
if my image name is drl what i have to put in large_image?
drl.jpg
or just drl
it either takes a url or an asset name
nice
so without the .jpg?
I mean asset name from here
https://imageing.org/shared/3WPzrnm.png
yeah yeah
so this should work right?
kindly dont ghostping me, thanks
Guys, can I ask for help with understanding the RPC?
What is the difference between IPC and WS in this case?
sorry xd but it should work?
try it
lets see
connection closed? xd
Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.
ohh yeah in my rdp i don't have discord downloaded
then thats your issue
or at least one of them
working fine 🙂
also can i put that rdp into a bot?
or it's just for users
btw @nimble yarrow is it working with bot.on etc?
i see yeah
why it says 'connection timed out'?? after a seconds
Did you close your discord? Otherwise your internet connection may have disconnected I think
guys, am I correct in assuming that these functions cannot be used without discord approval?
I'm in the sense that it's not possible without it at all
well, the same thing is written in front of the rpc.activities.write, but it works
• "Can I use Rich Presence for my bot?" - No.
• "Will I ever be able to use Rich Presence for my Bot?" - Ask Discord.
Can someone explain why my RPC isn't working?
const { Client } = require('discord-rpc');
const config = require('../settings/config.json');
const client = new Client({ transport: 'ipc' });
const { log, error } = new (require('../log/console'));
function buttons() {
client.request('SET_ACTIVITY', {
pid: process.pid,
state: config.status.state,
details: config.status.details,
activity: {
assets: {
large_image: config.assets.image_key,
large_text: config.assets.image_text,
},
buttons: [
{ label: config.button_one.label_name, url: config.button_one.label_url },
{ label: config.button_two.label_name, url: config.button_two.label_url },
],
instance: config.instance || true
},
});
client.on('ready', async () => {
log("CUSTOM BUTTONS",`Auto-Linked to ${client.user.username}#${client.user.discriminator} & Showing!`)
});
client.login({ clientId: config.client_id }).catch((error)=>{
error("BUTTON ERROR", error)
});
}
module.exports = buttons;
[9:23:19 PM] INFO [CUSTOM BUTTONS]: Auto-Linked to 2G4U#6908 & Showing!
You are not calling the buttons method ?
its called
it just doesnt display
i just want to ask, is discord-rpc is available on mobile? i don't really think if it was possible, but i just want to make sure
i don't think so
.😅☝️
apa tcuy
const DiscordRPC = require('discord-rpc')
const client = new DiscordRPC.Client({ transport: 'ipc'})
require('dotenv').config();
(async () => {
client.on('ready', async () => {
await client.setActivity({
buttons: [{label: 'DISCORD SERVER', url: 'URL'}],
details: 'Listening to chill music',
largeImageKey: 'rpc_icon',
largeImageText: 'Music'
}).catch(err => console.log(err))
console.log('Rich presence enabled.')
})
await client.login({ clientId: process.env.applicationID}).catch(console.error)
})``` Is there a reason why this doesn't do anything
Is it outdated?
async function isn't running
client.login() doesnt need to be awaited
so that whole async function is useless
Ty, that worked
How to set up Discord RP with a button?
in vscode

Wth is this code
Never saw that
WoW, complex for nothing..
Why did they remove the RPC docs from the discord.js website?
it's a bug at the moment iirc
Oh alright
Btw, where can I take a look at the docs?
Is there an external website or a fork of it?
I tried using archive.org, but it looks like the # in the url breaks everything in the archive because they try to url encode it
<@&839912195994812420>
Because that will work lol
wat
Tagging mod
there was a guy who needed mod attention, so yes, worked
not sure what you are on about now
Oh jee sorry, hope you find something to make your day better.
I was asking is rpc deprecated?
as there isn't any update since 2021 (maybe)
anyways
there wasnt a need for an update
my application is showing null idkw
I doubt that but it doesn't matters if community is here
btw can you help me on that?
want to change the name of my rpc
currently it shows the name of app made in dc dev portal
but I want to change it as I wan't
You cant change it
I thought client.application.name = "My new name" might work
Since it's showing the name of the app from dev portal... just change the name of the app on the dev portal?
Though true. You cannot change it from your code directly and definitely not via an assignment
Hey, is the doc for RPC down?
It redirects me to the welcome page
for now, yes
The RPC clients seems to be ignoring the redirectUri that I add during the login.
import RPC from 'discord-rpc'
import 'dotenv/config'
const rpcLoginOptions = {
clientId: process.env.CLIENT_ID,
scopes: ['rpc'],
redirectUri: "https://discord.com/"
}
const client = new RPC.Client({ transport: 'ipc' });
client.login(rpcLoginOptions).catch(console.error);
Get this error:
do you get that error if you don't pass the uri at all?
Is there way to check if there are unread messages?
don't think so
Sadge
Yes
did you set the url in application options?
Oh that's what the error probably means. Can it be "https://discord.com/" ?
It's redirect_uri iirc
for dapi
not for discord-rpc
redirectUri is for oauth
the way that works is that you pass the uri, and if it matches the uri you set as allowed in the app options on discord's website, they allow the oauth to continue
but you don't really need oauth for rpc
But I'm trying to get the voicesettings don't I need it for that?
Ah yeah sorry I misunderstood
where does it say that you need oauth authentication for that
After accepting the popup on discord.
? show
It throws me that error.
ok, sethttp://localhost as redirect uri in the app settings
and try then
Same.
It says missing not invalid :/
It seems like it's ignoring it. And where can I set it up on the website?
so you didn't set it on website, but passed as option
don't pass anything as option, but set that on website
Oh
Okay wait
With no options : body: { redirect_uri: [ 'Not a well formed URL.' ] }
http://localhost
You should pass the same Uri you specified in the site
With or w/o the option I get 'Not well formed URL.'
Oh
I'm a step further now
now that I think about it, I think you also need the client secret, not sure I'm wrong tho
But for the things you mentioned I think you need it
'invalid_client' the next error. Is that the client_id is invalid?
is it id of the app?
Yeah
or yours by any chance
Well I assumed it was the application id you get from the website
Do I need to setup something on the client before I run the service?
Yeah I just checked my old RPC code and you actually need the client secret
how come that i don't
might be because i don't actually pass any scopes
aha
That's maybe why
Yeah, RPC without scopes doesn't need authentication
so yeah, don't pass scopes, don't pass uri
You're right
should work™️
Tried with password
If you only need to set a status you don't need scopes neither redirect Uri or anything, just the client id. If you're really sure you need other scopes you should add clientSecret (or client_secret idk) as the secret you get in the main page of your application in the Dev portal
it's js, so camelCase, discord-rpc translates
I actually want to listen to when I mute myself
And unmute
Don't I need rpc for that?
well, you would be using RPC anyway, with auth or not
I thought I needed auth for anything related to my account
Or is auth only to perform any actions?
try with rpc.voice.read scope
but then you need to set the clientSecret and uri
It's working now.
Should I use a client.subscribe or client.addEventlistener ?
iirc if you don't subscribe, nothing will emit
Does it was to be wrapped around the client.on('ready') ?
Wait let me test before asking stupid quesitons.
Where did you find this scope?
Aha thx
Oh to listen to voice state you need to get the channel_id?
I got it! 😄
I'm amazed how this works good.
const client = new RPC.Client({ transport: 'ipc' });
client.on('ready', async () => {
client.subscribe('VOICE_SETTINGS_UPDATE');
client.addListener('VOICE_SETTINGS_UPDATE', (payload) => {
client.setVoiceSettings({ deaf: !payload.deaf });
console.log('Is Muted', payload.deaf)
})
});
client.login(rpcLoginOptions).catch(console.error);
no clue
rpc doesnt work in a browser lol
what does discord rpc do
show the "Playing a game" rich presence
ok
then why do they export for browser?
wdym 
browser CDNs
again, wdym
why do you think it should work with a browser

electron apps perhaps
it technically can work from browser via websocket, but you need special stuff for websocket to work
but since you can't make the websocket work, you effectively cannot use it from browser
saw in the example
what special stuff?
whitelisting
sorry but i am not getting it
you need to be whitelisted to use it
which just doesn't happen
oh discord will whitelist you to make it work?
no, thats the thing 

will discord ever make RPC through WebSockets public?
that's on Discord, for now you need to be whitelisted but that's a no
oh so no updates from discord's side
cannot find client
you need to be a bit more specific than that
I hope you realize that thats not the whole code
ok
And it's a loop which you should not use.
This will spam your deaf status on discord
//Variables
const rpc = require("discord-rpc");
const { clientId } = require('./config.json');
rpc.register(clientId);
const client = new rpc.Client({
transport: 'ipc'
})
const scopes = ['messages.read'];
//Variables
//Ready event
client.on('ready', () => {
console.log('RPC Loaded!');
client.request('SET_ACTIVITY', {
pid: process.pid,
activity: {
details: 'hmm',
state: 'hmm',
assets: {
small_image: 'hmm',
small_text: 'hmm',
large_image: 'hmm',
large_text: 'hmm'
},
buttons: [
{
label: 'Invite Shadow Bot!',
url: 'https://discord.com/api/oauth2/authorize?client_id=940748261441028116&permissions=1644971949559&scope=bot%20applications.commands'
},
]
}
})
});
//Ready event
//Client login
client.login({ clientId, scopes }).catch(e => {
console.error(`[Error]:\n`, e)
})
//Client login
I'm trying to make an rpc
Do we need to put the app id or client token in clientId? I tried putting both but didn't work.
It always says Could not connect in console
Pls help
application id
Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.
I pass all checks
I put app id but still said couldn't connect
then you wouldnt have the error
What could be the error?
Is something wrong in my code?
show the full error
so you didnt pass all checks
you cant use it on replit
Huh!? Why?
• Is your code running on the same machine as the Discord app?
rpc connects to your local discord client
without that, no connection
What should i use then?
wdym, you have to host it on the same machine where you use discord
I use Replit on mobile and discord on mobile too
you cant use it on mobile either
Uh...
and replit is still not local, replit is cloud based
Do you know any local host for mobile because i don't have any computer device
then you wont be able to use rpc
Bruh ☠️
buy a rasbperry pi and run discord and the rpc there
Discord can run on a raspberry pi ?
sure?
Oh that must be new then, because I didn't find any discord package for armhf processors
oh
I have a raspberry and I remember very well that I couldn't do that, so I was using the browser version. But maybe it has changed
there seem to be ways to get discord on a rasp
(dpkg would throw an error like this package is for amd64 and not armhf)
Oh ?
https://github.com/Botspot/pi-apps pi-apps for example seem to have discord
Oh.. I didn't know about that
How can I detect when I lose connection to Discord? The docs are down so no idea 
RPC = Remote Procedure Call actually
(or Rich Presence Client for someone else)
Well, now you know 
Well, I highly suggest to read the rules again.
This is a support channel and not a shitpost channel.
Can anyone help me?
node js is not working for me
this channel is for rpc only, for other questions #archive-offtopic or #useful-servers
Anyone? Right now if I connect to RPC, it works fine, but if I close Discord, nothing happens i.e. the code continue to runs.
So how do I check if its still connected so I alter my code to log that it was disconnected and to try to reconnect?
I tried a try catch as this runs every 15 seconds:
rpc.setActivity({ ...type });
but the catch was not triggered
Because you didn’t awaited it
Better to use .catch() if you don’t solve the promise (if it returns a promise)
what happend to the rpc docs?

pog, now any other docs i can use?
nope
ok I tried awaiting it and putting it in a try catch
try {
// Check if the user is currently watching something and if not, run on a timeout.
console.log(`${formatDate()} | ${chalk.red.bold.underline('Trakt:')} Not Playing.`);
await rpc.clearActivity();
} catch {
console.log('lost connection to discord');
}
the catch was not triggered, also tried put a .catch() and still, its not catching
I am really confused as to why though, surely you cant run an rpc.clearActivity() without discord
the client should automatically get terminated when it loses connection to discord
Thats what I would think, but it just continues to log 'not playing'
I just started the script while Discord was closed, and then closed it after it ran:
where does it log closed discord now
i wrote that
just to show when I closed it
remove your try/catch es and it should crash the app when it loses connection?
all of them
Yeah it didn't throw any error, do you seen anything painfully obvious I did wrong? https://pastie.io/eoemsy.js
SOLVED
If u dont mind me asking, how did u achieve that? Running into the same problem for quite a while now and docs hv vanished 🤡
No idea if there is a better way, but we have no docs and next to no support for discord-rpc. and this method works fine for what I want 🙂
thank u so fucking much 
Hello greetings, I have a concern about the "npm i discord-rpc-electron" I am trying to implement it but I get a module error, where should it point to?
That package is not made by discord.js
thats discord-rpc and not discord-rpc-electron
No problem, this issue also gave me trouble for so long, happy to finally have it solved!
so there is a calender app called cron. i want to add rich presence to it myself. can i do that?
probably
depends if it supports extensions
or if u could find a way to detect if its running or not
its not open source
so i cant go into the code and add the files
well then im not sure
rip so i need the code then right
not really
it really depends on what u need to do with the rich presence
Archived to focus issues on #986520997006032896 and kept read-only to facilitate in-app search (CTRL+F) for solutions to problems that have already been asked.
Please tag your posts accordingly