#archive-rpc-help
21942 messages · Page 12 of 22
is that need to be asked here ?
i don't think you will get answer for that specific question here.
Where can i take a quick research about that thing
or just to learn little bit more about rich presence in djs
djs has no rich presence, it's separate app as bots cannot have rpc
ohhh
I get it
but i guess you could go for examples or discord documentation
pretty sure that gives somewhat of an overwiew
Great , thanks anyway 🙂
?docs rpc
?docs
@rare flame, what would you like to search for?
Type cancel to cancel the command.
@rare flame look at the topic
oh thx
oops
Hello, I'm trying to implement a rout that get user's DMs, to do so I noticed I had to use RPC, but I have troubles implementing it
I am implementing it like a normal discord js client expect I add Transport: web-socket in the constructor
and when I do a .on('message' ...) I get a crash due to a heap overflow
Im using this ```js
const DiscordRPC = require('discord-rpc')
const clientId = "id"
const scopes = ['rpc', 'rpc.api'];
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
rpc.login({clientId, scopes})```but i get an error that i need a redirect_uri in the request?
(node:7356) UnhandledPromiseRejectionWarning: Error: OAuth2 Error: invalid_request: Missing "redirect_uri" in request.
at RPCClient._onRpcMessage (/home/j122j/Desktop/discordrpc/node_modules/discord-rpc/src/client.js:177:19)
at IPCTransport.emit (events.js:311:20)
at /home/j122j/Desktop/discordrpc/node_modules/discord-rpc/src/transports/ipc.js:134:18
at decode (/home/j122j/Desktop/discordrpc/node_modules/discord-rpc/src/transports/ipc.js:92:5)
at Socket.<anonymous> (/home/j122j/Desktop/discordrpc/node_modules/discord-rpc/src/transports/ipc.js:120:7)
at Socket.emit (events.js:311:20)
at emitReadable_ (_stream_readable.js:562:12)
at processTicksAndRejections (internal/process/task_queues.js:83:21)
(node:7356) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:7356) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```full error ^
@smoky scroll try adding google or something as a redirect in your oauth section of your app in the dev portal and set google as the redirect url, not sure why rpc would need this @steady sparrow knowledge plz
Wait, fkn kt 🤦♂️ @carmine mica
idk where do i put the redirect uri
In the dev portal
Oauth section
in my code
In the dev portal
Oauth section
bruh
but i need to set it in my code?
not just on dev portal
Doubt, I don’t see any redirect props in rpc
thats why i posted it here
It was@already set in the dev portal?
no
i get this and when i autorize it sends the error in the console
Sec lemme try this shit
wait
i need to put a redirect_uri in login options
wait
i put a redirect uri and it says im missing one?
Where tf did you get that from
from sourcecode
?docs rpcclient#login rpc
async login(options = {}) {
let { clientId, accessToken } = options;
await this.connect(clientId);
if (!options.scopes) {
this.emit('ready');
return this;
}
if (!accessToken) {
accessToken = await this.authorize(options);
}
return this.authenticate(accessToken);
}```
```js
async authorize({ scopes, clientSecret, rpcToken, redirectUri } = {}) {
if (clientSecret && rpcToken === true) {
const body = await this.fetch('POST', '/oauth2/token/rpc', {
data: new URLSearchParams({
client_id: this.clientId,
client_secret: clientSecret,
}),
});
rpcToken = body.rpc_token;
}
const { code } = await this.request('AUTHORIZE', {
scopes,
client_id: this.clientId,
rpc_token: rpcToken,
redirect_uri: redirectUri,
});
const response = await this.fetch('POST', '/oauth2/token', {
data: new URLSearchParams({
client_id: this.clientId,
client_secret: clientSecret,
code,
grant_type: 'authorization_code',
redirect_uri: redirectUri,
}),
});
return response.access_token;
}```
it uses redirectUri from options in login
Huh? This is an internal method
client.js in src folder
k, i got it to work by specifying the clientid and clientsecret
so i need to put clientsecret?
ye seems so
hmm can you send the code?
oh wait
got it with google redirect
wait
you dont need a redirect if you put clientsecret
rich presence is the only usage that doesn't require client secret
rpc.api takes control of the user's client, very important that the rpc is authorized
@carmine mica what permission do I have to give myself to send chat invites? all invites result in this
Pretty sure normally you're not many to be able to without some approval thing
@quick lichen you shouldn't ever need to do that so don't worry about it
?
im talking about this
oh that's not a chat invite
should work normally
hmmmmmmmmmmm
So i want my discord commands in a different folder because clean but when i put the command for playing something on the bot in there it does not register the command any more. Is there anything i'm doing wrong?
this does not look like it's related to rpc
oh fuck wrong channel
sorry about that
all good
?hasbin
To share long code snippets you can paste them into https://hastebin.com/, press CTRL + S or click the save icon and send the link. It makes it easier for us to help you.
Alternatives: https://paste.nomsy.net/, https://hasteb.in/, https://sourceb.in/
not rpc related (deleted)
what's RPC
Right but what is it
this is rich presence
Okay let me rephrase
I know what rich presence itself is, but what does discord.js have to do with it.
nothing
rpc is separate app to do that
djs made a lib for rpc
Ahh okay
so it is more of an extension?
no
it's completely separate
bots cannot have rpc
I meant off the original discord.js module
no
it's completely separate
bots cannot have rpc
and clients cant be bots
.-.
how do i set up a rich presence
nvm
i need help with this ``` 'use strict';
/* eslint-disable no-console */
const { app, BrowserWindow } = require('electron');
const path = require('path');
const url = require('url');
const DiscordRPC = require('../');
let mainWindow;
function createWindow() {
mainWindow = new BrowserWindow({
width: 340,
height: 380,
resizable: false,
titleBarStyle: 'hidden',
webPreferences: {
nodeIntegration: true,
},
});
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true,
}));
mainWindow.on('closed', () => {
mainWindow = null;
});
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
app.quit();
});
app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});
// don't change the client id if you want this example to work
const clientId = '675539643596406804';
// only needed for discord allowing spectate, join, ask to join
DiscordRPC.register(clientId);
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const startTimestamp = new Date();
async function setActivity() {
if (!rpc || !mainWindow) {
return;
}
const boops = await mainWindow.webContents.executeJavaScript('window.boops');
rpc.setActivity({
details: booped ${boops} times,
state: 'Test',
startTimestamp,
largeImageKey: 'layerrff2',
largeImageText: 'layerrff2',
smallImageKey: 'snek_small',
smallImageText: 'i am my own pillows',
instance: false,
});
}
rpc.on('ready', () => {
setActivity();
// activity can only be set every 15 seconds
setInterval(() => {
setActivity();
}, 15e3);
});
rpc.login({ clientId }).catch(console.error);```
it is't working...
?dnw
Against popular belief "does not work" is not sufficient information to provide to receive help.
What's the expected (wanted) behaviour, what's the actual (unwanted) behaviour? Do you get any errors? What's your relevant code that might be causing the issue?
???
What isn’t working
the whole thing
no error in consle
For starters do you have discord rpc downloaded and in two directories up from the parent of that folder? 
Basically: did you clone the exact repo or only the example folder
wdym
Show your folder structure
wdym
Are you using an ide? The folders on the side bar
For example:
MainFolder
src
index.js
im using server.js
-_-
how do u set this thing up anyways?
If ur gonna copy the example and expect it to work you gotta clone the entire repo
howd u do that?
git clone theurlyougetfrompressingtheclonebuttoningithub
where do i put that
In terminal
i cant
ima go eat dinner
lmfaooo imagine having to deal with someone like this
this is not rpc related (deleted)
Hey! I am trying to setup a discord RPC however I am just getting "undefined" when I try to login, I am following the Rich Presence example but I think it might be outdated?
const clientId = '685644933797117999';
const DiscordRPC = require('discord-rpc');
const rpc = new DiscordRPC.Client({ transport: 'websocket' });
var boops = 0
startTimestamp = new Date()
function setActivity(){
boops += parseInt(Math.random()*5)
rpc.setActivity({
details: `booped ${boops} times`,
state: 'in hell',
startTimestamp,
largeImageKey: 'large',
largeImageText: 'Big',
smallImageKey: 'small',
smallImageText: 'Tiny',
instance: false,
});
}
setInterval(() => {
setActivity();
}, 15e3);
rpc.login({ clientId }).catch(console.log);```
I have made my own client and have the right assets
But I just get an error of undefined
I'd love any help
I have also tried with the client secret in the login data as well but that did not work either, same error
oh wait, discord RPC has been depricated
Time to find a libray that does the new API
it is not deprecated
oh?
I am confused then
The discord api docs say it is, and I always get undefined errors?
oh I might have fixed it? idk how?
does it say sdk?
rpc sdk is deprecated. rpc itself is not
well it is logged in now
yeah
I just got confused
However I can't seem to get it to set the activity
Yeah I cant even get the example from the git to work
It doesn't error or anything, it just does not set rich presence
Ohhh I am silly
I had display in presence off on my discord
?lmao
?dnw
Against popular belief "does not work" is not sufficient information to provide to receive help.
What's the expected (wanted) behaviour, what's the actual (unwanted) behaviour? Do you get any errors? What's your relevant code that might be causing the issue?
lol
well sadly I had no more information to give :p
I did say that there were no errors and it seemed to be working other then the fact that it wasn't showing up, so I did give all the info I had
anyway. does anyone know if you can set a rich presence on a bot?
yes, no
Would it be necessary to hide the client secret for an electron app?
The worst thing they can do is pose as an imposter for oauth, but that wont really do much anyway
i wouldn't advertise the secret
like people can see the secret in devtools and stuff
in the discord client
when rpc connects
its not a huge security thing
ok
so just do some base hiding then
you can also set up a server
that does authentication
and sends an authed token back to your app
but thats probably overkill
was thinking of doing that, but im like "do i really need to?"
if you remove your client secret it should also still work, just requiring a special oauth model instead
const RPC = require('discord-rpc');
const scopes = ['rpc', 'rpc.api',];
const client = new RPC.Client({ transport: 'ipc' });
let win; // for discord.js reviewers, this is an electron app
client.on("ready", () => {
console.log(client.user.username)
win.webContents.send('username', client.user.username);
...
})
ipcMain.on("login", event => {
client.login({ clientId: "id", clientSecret: "secret" });
});
works fine.
is this a feature or a cache problem?
because putting in "id" and "secret" (or any other string) works fine
but im not sure if thats safe to do
sorry if this is a novice question but what is discord RPC used for?
Stuff like this, just took the first one i saw on the right side there
Since this evening, my rpc client gets an "Error 1000: unknown error"
when trying to login using:
client.login({ clientId: config.clientID, scopes: ['identify', 'rpc.notifications.read', 'rpc'], clientSecret: config.clientSecret, redirectUri: '<valic callback uri>' })
i have not update the application for a few months, and i did try updating my client secret
this setup has been working since december 2019
cloud anyone shed light on what this might be?
yes the application id an secret are registered under my acount, so rpc whitelisting should not be needed
check the discord console or smth
we aren't any better at guessing what "unknown error" means than you are
"GET https://canary.discordapp.com/api/v6/oauth2/@me 401" unauthorized
whent it tries to authenticate 
401 means you didn't provide valid authentication
but thats most likley because i first try to auth with the last known accesstoken
which will lickley fail, and then i tried the code above, to get a new access token
it doesnt log anything after rejecting my old access token though
becides the "1000: uknown error"
¯_(ツ)_/¯
hoped that you guys would know that discord has done an internal update or something
do you happen to know who i can contact for this?
it happens in both canary and ptb versions of discord
not stable?
i dont have stable installed right now
i guess ill try that to just to be sure
i can confirm that stable does exactly the same thing as ptb and canary
the connect popup shows, i click authorize or connect
and it stays on the screen, but sends an error in the background to my application
very vague
and the console shows nothing?
only the same error 1000 unkown error
and my application does 🤷♂️
anything interesting in the network pane?
failed requests etc
only the previous access token which is invalid anyways
but i do see a valid response from the autorize route with a new access token
but for some reason the discord client doesnt seem to parse it and return the callback or read the callback 🤷♂️
client id isn't a secret btw
i know, but just in case 😛
and the response
seems to both be fine 🤷♂️
i am confusion 😦
If someone happens to know the problem, or wants to talk about this, please @ me 😄
can you send a welcome message to webhook?
Can somebody write for me gban command?
lol this is #archive-rpc-help
I need help with starting with this cus I'm literally confused
How to give permission for manage the channel with this code ?
tempChannel.autoCreateChannel(client, {
userLimit: 5,
nameStartsWith: "Join to Create"
// nameStartsWithTemp: "//"
@twilit grail how is this rpc?
rpc ?
this channel is for rpc
lol
thats the only thing they wrote
and that has nothing to do with rpc
lmao
lmfao
This is rich presence right?
@hidden geode did you figure out your rpc auth issues from last week? I was experiencing the same issue you described - no code changes, suddenly stopped working, error 1000, etc.
Out of the blue my RPC app started working again today 😐
no, i had to restart my pc later that day
and after that discord updated
it worked after that
Ah, ok. Must've been an issue on the discord client then. Thanks!
probably, ye 😄
Mk
How can I create a super simple way sdk app that i can run
In js
How do you use this?
@plucky cargo theres no stats
anyone, help?
stats?
yeah
@left fjord
how do I add stat to it @left fjord
by adding stat to it
with code
how
thats my question
@left fjord
by coding it
what i am supposed to tell you
what the hell is "stat" you want to add
const clientId = '685644933797117999';
const DiscordRPC = require('discord-rpc');
const rpc = new DiscordRPC.Client({ transport: 'websocket' });
var boops = 0
startTimestamp = new Date()
function setActivity(){
boops += parseInt(Math.random()*5)
rpc.setActivity({
details: `booped ${boops} times`,
state: 'in hell',
startTimestamp,
largeImageKey: 'large',
largeImageText: 'Big',
smallImageKey: 'small',
smallImageText: 'Tiny',
instance: false,
});
}
setInterval(() => {
setActivity();
}, 15e3);
rpc.login({ clientId }).catch(console.log);
This?
omg how, im so confused
How can i create a sdk app in js
and be able to run it
Ik im stupid
same
sorry 4 ping @smoky scroll can you help me? im verry confused of how this worsk
please don't ping people
yeah no, absolutely not
sorry, but I need some help
sucks, post in this channel and wait
I have nothing to do with RPC as is the case for most
alright
Mk
'use strict';
/* eslint-disable no-console */
const DiscordRPC = require('discord-rpc');
const clientId = 'token-here, there is a token here i swear';
const rpc = new DiscordRPC.Client({ transport: 'websocket' });
const startTimestamp = new Date();
rpc.setActivity({
state: `Playing Safari!`,
startTimestamp,
largeImageKey: 'safari',
smallImageKey: 'safari',
instance: false,
});
rpc.on('ready', () => {
setActivity();
// activity can only be set every 15 seconds
setInterval(() => {
setActivity();
}, 15e3);
});
rpc.login({ clientId }).catch(console.error);
undefined
(node:1137) UnhandledPromiseRejectionWarning: Error: connection closed
that 3 me @astral terrace
nvm
?
nvm
how can i amke one?
Idk either
read the docs
WHats transport/
who knows RPC hereeee?
Hello!
I'm so interested in discordjs RPC and I downloaded this(https://github.com/discordjs/RPC.git) and then run example but rich presence has no change. Why/?????? 😦
And i got an error of undefined 🙂
@astral terrace @languid plank I dont know much about RPC but i do know this, you must be whitelisted by Discord to use the websocket, which is only available through application. Change it to ipc
Ok
Welp
at IPCTransport.send (/Users/carter/Documents/swiss-plus/node_modules/discord-rpc/src/transports/ipc.js:151:17)
at /Users/carter/Documents/swiss-plus/node_modules/discord-rpc/src/client.js:158:22
at new Promise (<anonymous>)
at RPCClient.request (/Users/carter/Documents/swiss-plus/node_modules/discord-rpc/src/client.js:156:12)
at RPCClient.setActivity (/Users/carter/Documents/swiss-plus/node_modules/discord-rpc/src/client.js:522:17)
at Object.<anonymous> (/Users/carter/Documents/swiss-plus/rpc.cjs:13:7)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
(node:1706) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1706) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
ReferenceError: setActivity is not defined
at RPCClient.<anonymous> (/Users/carter/Documents/swiss-plus/rpc.cjs:23:3)
at RPCClient.emit (events.js:223:5)
at RPCClient.login (/Users/carter/Documents/swiss-plus/node_modules/discord-rpc/src/client.js:138:12)
at processTicksAndRejections (internal/process/task_queues.js:94:5)
@languid plank I don’t get your question? Can you provide a visual example of what you mean by “how do I add stat to it”
like add images and text to it
can anyone provide me discord logo for rpc
512x512
size*
maybe here? https://discordapp.com/branding
According to official documentation rpc is in private beta and not accepting a new developers state. So if I use djs for rpc it will work?
djs has no correlation with rpc
also, the beta is for restricted endpoints of the rpc
Better don't help me, I don't exist.. Bye..
I don't think this is RPC related
Oh fuck
@cyan troutleft
is it possible to see what guild/voice channel a user is in with rpc?
as far as i know i can send presences but idk if i can fetch data from discord from the client
oh okay gotcha
sorry thank u
nice
Is it possible for your bot in written with discord.js to have a custom rich presence status?
See pins.
I did but I'm still confused a bit since I saw someone mention that discord bots can't have rich presence. Apologies
I did but I'm still confused a bit since I saw someone mention that discord bots can't have rich presence. Apologies
@deft moat
https://canary.discordapp.com/channels/222078108977594368/379350641761320982/595420074110877701
Thank you for clearing that up for me.
discord RPC Means Discord Rich Presence?
yes
Um. No. It means the usual, Remote Procedure Call.
https://en.wikipedia.org/wiki/Remote_procedure_call
Rich Presence is just a part of that system.
Wait wut
(node:10596) UnhandledPromiseRejectionWarning: undefined
const RPC = require("discord-rpc")
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: "698082963975569478", scopes: ['rpc', 'rpc.api', 'messages.read'] });
same for me also undefined
Hey, I've been trying to get game invites to work. But I get Clydes message that my message was undelivered when I try to invite to the game, but weird thing is Spectate works fine. Any idea what it could be?
const client = new RPC.Client({
transport: 'ipc'
});
client.on('ready',async () => {
let lobby = await client.createLobby(2, 10, { });
client.setActivity({
state: 'Testing',
details: `Testning 123`,
startTimestamp: Date.now(),
instance: true,
matchSecret: lobby.secret,
spectateSecret: lobby.secret + "-spectate",
joinSecret: lobby.secret + "-join"
});
});```
Fixed if anyone else is experiencing it you need to set partyId as well. TS doesn't seem to have partyId option
What are the benefits of using RPC ?
You get rich presence for your application
Lol
what is ipc exactly
Inter Process Communication
Processes talk to each other
Is it bad practice to initiate a load of promises without waiting for the callback
E.g
for(condition){
thingthatdoesntinstantlyresolve()
}
Actually that should be otherjs
Error: child "activity" fails because [child "timestamps" fails because [child "end" fails because ["end" must be larger than or equal to 1]]]
I dont know where the error comes from
Send your setActivity

const obj = {
state: payload.topic,
details: `In a meeting`,
startTimestamp: Date.now().valueOf(),
instance: true,
largeImageKey: "zoom",
largeImageText: "Zoom",
smallImageKey: "live",
smallImageText: "A meeting is on going"
};
(payload.duration < 720) ? obj.endTimestamp = payload.duration * 60000 : 0;
I am doing setActivity(obj)
you can't do that
cant do what
because if it's vfalse
your endTimestamp becomes 0
something cant end before it starts
no
Im never defining the endTimestamp
obj.endTimestamp = payload.duration * 60000 : 0;
Its not that

(payload.duration < 720) ? obj.endTimestamp = payload.duration * 60000 : 0;
Oh I see
Console log obj.endTimestamp 
well I didnt recieved an error
and it logged undefined
Error: Could not connect
at Socket.onerror (C:\Users\BoraC\Desktop\Projects\Zoom-Discord-Rich-Presence\releases\v0.0.1\src\node_modules\discord-rpc\src\transports\ipc.js:32:16)
I have 2 diffrent js files
which has the same code
when I run the first one it works as expected
but in the second one
it gives that error
Actually only on vs code
it works
👋 I wanted to write a Discord Rich Presence plugin for Figma.
Figma is running on Electron and its plugin system allows the use of Browser API.
I've tried using discord-rich-presence with the example given with no luck. What is the best way to debug discord-rich-presence?
^ Follow up
Do I have to provide an OAuth token when connecting to RPC?
Everywhere I look it states I only need to login with the Client ID
const client = new Discord.Client({ transport: "websocket" });
const clientId = "123123123123123";
const scopes = ["rpc", "rpc.api", "messages.read"];
client.login({ clientId, scopes });
Uncaught (in promise) Error [TOKEN_INVALID]: An invalid token was provided.
Discord.Client? Are you actually using RPC?
Yeah sorry I should clarify.
I've been the webpack bundle of Discord.js
const Discord = require("./discord.js")
My code has to execute in an iframe that Figma provides, making this whole ordeal a lot more complicated than anticipated.
I have no access to node at runtime
(\❓ do you mean require("discord.js")?)
ah yes sorry
It still sounds like you're using the discord.js library and not discord-rpc.
oh, you're right. Sorry, I assumed it was part of the bundle.
Can i add rich presence for my bot user?
why do I get Error: Could not connect
About several million reasons
lol
how do i get the name of the current application?
hi
um
the rpc example seems to be a little outdated im guessing?
are you saying that RPC has been updated since when the example was created?
Help me pls,how to install canvas it you error?
This is neither the channel nor really the server for canvas issues
yea, iirc The rpc example assumes you clone the repo so it uses a relative path to the module. everything else should be fine tho?
Hi, i've been using the discord rpc (ipc) local server for my razer chroma application for a while now
and it has worked fine, but since a few days, i dont know how long, because i had my accesstoken cached,
it doesn't connect anymore without access token
i am receiving the following error
{
constructor: 'Error',
code: 5000,
data: {
code: 5000,
message: 'Redirect URI cannot be used in the RPC OAuth2 Authorization flow'
},
stack: 'Error: Redirect URI cannot be used in the RPC OAuth2 Authorization flow\n ' +
' at RPCClient._onRpcMessage (...\\node_modules\\discord-rpc\\src\\client.js:171:19)\n' +
' at IPCTransport.emit (events.js:200:13)\n at ' +
'...\\node_modules\\discord-rpc\\src\\transports\\ipc.js:134:18\n' +
' at decode (...\\node_modules\\discord-rpc\\src\\transports\\ipc.js:92:5)\n' +
' at Socket.<anonymous> (...\\node_modules\\discord-rpc\\src\\transports\\ipc.js:120:7)\n' +
' at Socket.emit (events.js:200:13)\n at emitReadable_ ' +
'(_stream_readable.js:558:12)\n at processTicksAndRejections ' +
'(internal/process/task_queues.js:84:9)'
}
with this code
im running this in an electron app
client = new DiscordRPC.Client({ transport: "ipc" })
client.login({ clientId: config.clientID, scopes: ['identify', 'rpc.notifications.read', 'rpc'], clientSecret: config.clientSecret, redirectUri: 'http://localhost:1608/rzr-discord-chroma-callback' }).catch(async (e) => {
console.error(e)
}
try another localhost port?
i tried mutiple ports, no success
@hidden geode the error message says your problem lol
without the redirect uri, it will auth as a normal rpc application and will not provide an access token, which i need for authenticating to the local ipc/rpc server
to subscribe to notifications
you can subscribe to events with the client directly
client.subscribe('NOTIFICATION_CREATE', { whatever }, (notification) => {})
no need to login?
because when i auth without a redirectUri, it will fire the client ready event
But when i subscribe with the client to that even it will tell me that i used the wrong scopes or invalid auth
i use the same scopes as i've been using since december, rpc, rpc.notifications.read and identify
@hidden geode using client id, client secret, and rpc.notifications.read, i'm able to subscribe to NOTIFICATION_CREATE
ill give it a double check
client = new DiscordRPC.Client({ transport: "ipc" })
client.on('ready', () => {
log.info(`Logged in as ${client.user.username}#${client.user.discriminator}`);
//RPC notification event
client.subscribe('NOTIFICATION_CREATE', (message) => {
console.log(message)
})
})
as soon as that client.subscribe is called, it will throw:
code: 4006, message: 'Not authenticated or invalid scope'
🤷♂️
(can't you just use ${client.user.tag} instead of ${client.user.username}#${client.user.discriminator})
probably, but thats not really an issue right now 😛
it seems that tag is not provided in the client.user object

@hidden geode public_flags aren't sensitive data
but anyway did you ask for the rpc.notifications.read scope
client = new DiscordRPC.Client({ transport: "ipc" })
client.login({ clientId: config.clientID, scopes: ['identify', 'rpc.notifications.read', 'rpc'], clientSecret: config.clientSecret, redirectUri: 'http://localhost:1608/rzr-discord-chroma-callback' }).catch(async (e) => {
console.error(e)
}
yes, i used this one, but without the redirect uri, and only rpc.notifications.read
Perhaps you need rpc as well?
both with all the ones i posted and only rpc.notifications.read, has the same outcome
Is this related?
where can i get help for my js problem?
Everytime I want to you any of methods or subscribe to anything i get Error: Not authenticated or invalid scope
const scopes = ['rpc', 'messages.read', 'rpc.notifications.read'];
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
rpc.on('ready', () => {
rpc.subscribe('NOTIFICATION_CREATE', (message) => {
console.log(message);
});
});
rpc.login({ clientId, scopes, clientSecret }).catch(console.error);
Can somebody please help me with issue?
is your app whitelisted?
i need to get my app approved by discord to use all the events?
Idk, how can I check it?
If you don’t know it’s probably not whitelisted.
last I saw discord was no longer accepting rpc applications that it was now like #closedBeta
RPC has been closed beta for a while
why cant I run with ipc
You can run with ipc, you can’t run with websocket
yes
but I cant run with rpc neither
this is my whole file
I am getting UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'write' of null
Error: OAuth2 Authorization Error: Unknown Error
nvm
I think I got it
no I still get Error: OAuth2 Authorization Error: Unknown Error
You need to run setactivity after the ready event
I think I got it
I did that in here
but still it give OAuth error
can you add discord rpc to a bot?
no
uhm i have rpc running on a selfbot but i just can´t stop the rpc how can i do that?
You can stop the rpc by not running a self bot
means there is no way to only stop the rpc client?
wow thank you
you cant have rpc on a selfbot because bots cant have rpc
selfbots are also against discord tos
i don't know if i just don't understand it but when you go to my profile you see that rpc is already running on my account through a bot. but i can currently only stop the rpc by closing the bot client
you cant run rpc through a bot. the rpc and bot could part of the same nodejs process, though.
ah okay yes i understand. but how can I reset this rpc?
(im assuming you are running rpc in a nodejs process) end all nodejs procesess on your computer, shut down your computer and open discord on your phone (is the rpc still showing?), delete the application from https://discordapp.com/developers/applications
you can stop the rpc client by calling destroy on it
Very big update I see 
rpc would break without that update
please stop pointless comments
Can you use rpc without desktop application?
No
As it's the desktop app that runs the rpc server
Did you mean to ask in #archive-djs-v12-voice-deprecated?
had no idea that rpc does that
Yes lol sorry
👍
👍
whats discordjs rpc btw? (dont hit me w/ that lmgtfy SMH)
you can read the topic 👀
is there any way to define the client who i would set the rpc without running the desktop app?
no
the desktop client hosts the rpc server
no desktop client no rpc
damn, thats bad... so no way to run the rpc on 2 accounts at the same time?
can i fake this? that i pull the needed data from discord and pass it directly to my rpc
i don't remember client having option to have 2 accounts logged in at once, so its rpc server will put data to currently logged in account
i mean that i can put the data that rpc gets from the logged in account manually and then use rpc without a dc desktop client
desktop app has the rpc server you connect to
and i cant host the rpc server manually?
i don't think discord supplies such thing as a standalone
hm okay... thanks
i thought maby i can log it in like an bot client to rpc
again, you connect to the discord app running on your pc, which runs an rpc server. app takes what you send to it and applies the rich presence to the currently logged in account
for example, for that reason bots cannot have rpc
yes I understand but I still wanted to try it anyway. even though it probably won't work
I use the example code ( https://github.com/discordjs/RPC/tree/master/example ) but I get the error:
C:\Users\username\Home\Sort\RPC-master\RPC-master\example\main.js:31
app.on('ready', createWindow);
^
TypeError: Cannot read property 'on' of undefined
at Object.<anonymous> (C:\Users\username\Home\Sort\RPC-master\RPC-master\example\main.js:31:5)
[90m at Module._compile (internal/modules/cjs/loader.js:868:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:731:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:644:12)[39m
[90m at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)[39m
[90m at internal/main/run_main_module.js:17:11[39m```
did you run npm i in the parent directory @visual sparrow
last time i tried i had to do that
oh no
ill try
oh wow its installing so much
yeah
electron big
anyway see here it works
my hand hurts
I'm connected via Wifi xD
oh is this BetterDiscord?
shhh
Never seen that before
there is no avaibility to run rpc on an virtual maschine like debian?
I own an VPS
its the desktop app that runs rpc server
you would have to install desktop environment on your vps and install discord in it
ouf I'll look what I can do
first of all I have to istall git!?
I have installed all packages now in the RPC-Master dir. I'm using the example files:
app.on('ready', createWindow);
^
TypeError: Cannot read property 'on' of undefined
at Object.<anonymous> (C:\Users\username\Home\Sort\RPC-master\RPC-master\example\main.js:31:5)
[90m at Module._compile (internal/modules/cjs/loader.js:868:30)[39m
[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)[39m
[90m at Module.load (internal/modules/cjs/loader.js:731:32)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:644:12)[39m
[90m at Function.Module.runMain (internal/modules/cjs/loader.js:931:10)[39m
[90m at internal/main/run_main_module.js:17:11[39m```
Please Mention me on help
Ok found out
at Timeout._onTimeout (C:\Users\username\Home\Sort\RPC-master\RPC-master\src\client.js:99:47)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)```
Whats the problem, why does it times out?
are you using websocket or ipc?
@visual sparrow
I fixed it already
@visual sparrow please contact me if you finally run rpc on derbien/raspberry pi. i´m trying too
its the desktop app that runs rpc server
you would have to install desktop environment on your vps and install discord in it
but this would not work so easiely on derbian i think
@wispy vortex it is possible, but very dumb to do so.
try ipc
every time i try ws i get that same error
What does rpc stand for?
Remote Procedure Call ?
Oo
Okay
I'm new to this stuff and just noticed the channel
Rich Precense?
presence*
@left fjord why? think its great
VPSes are in no way meant to emulate graphics for your DE
how can I run the example code for rpc? when i go into the module, example folder doesnt exist
nvm i cloned it from github
follow up question about this: https://canary.discordapp.com/channels/222078108977594368/379350641761320982/701710851341811725
i was able to do some more hunting for the problem
in the discord-rpc package in the authorize function there is the following call
const { code } = await this.request('AUTHORIZE', {
scopes,
client_id: this.clientId,
rpc_token: rpcToken,
redirect_uri: redirectUri,
});
https://github.com/discordjs/RPC/blob/master/src/client.js#L211
when wanting to connect to the local rpc server on a client to receive message notifications this will result in the issue i described in the message i linked
when removing the "redirect_uri" from this call the error is no longer occurring
the second call in this function
const response = await this.fetch('POST', '/oauth2/token', {
data: new URLSearchParams({
client_id: this.clientId,
client_secret: clientSecret,
code,
grant_type: 'authorization_code',
redirect_uri: redirectUri,
}),
});
https://github.com/discordjs/RPC/blob/master/src/client.js#L218
works fine as is
is there any reason for the recirect_uri to be passed in the first call?
if not, can it be removed in the next version?
Do I need D.JS to use RPC?
no, they are independent
What does destroy do?
Does it stop RPC?
The assets keep being reset
Looks like you don't have git installed, try doing that first
@uneven falcon
👍
tks
i have the RPC working for showing presence but how do i receive a join request, or spectate request?
@cyan plinth this might help-
// The events for the ones you requested are available on the DAPI Documentation
// Specific events for the ones you mentioned-
// https://discord.com/developers/docs/topics/rpc#activityspectate (ACTIVITY_SPECTATE)
// https://discord.com/developers/docs/topics/rpc#activityjoinrequest (ACTIVITY_JOIN_REQUEST)
// args for the event |
// V
<RPCClient>.subscribe('evt_name', {}, cb_function);
thank you @wary thorn
@wary thorn its not doing anything
The callback is how you will listen
I would suggest having it "emit" the event on the client, since it is an EventEmitter, and naming it to the event
Anyone have the docs for rpc?
or like a yt tutorial for it
The docs are literally this: https://discord.js.org/#/docs/rpc/master/class/RPCClient
I noticed lmao
my bad
Are there any guides for this?
const RPC = require('discord-rpc')
const clientId = 'ID Here'
const scopes = ['rpc', 'rpc.api']
const client = new RPC.Client({transport: 'ipc'})
client.on('ready', () => {
console.log('Ready!')
})
client.login({clientID, scopes})
I've tried starting this but I get this error
(node:5359) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5359) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.```
clientID != clientId
oh welp
That must be why
I expected it not to have any effect..
How do i get through the Oauth?
Like I mean how do I get the redirect uri
I don't plan on letting people join, I only plan on using it for displaying a status
@lethal whale
Someone else should try to help you, I'm only really helping through docs, no first hand experience of RPC.
Oh alright my bad
Thanks
Maybe is there anyone you know who can?
if anyone can help pls ping me thanks
Anyone who can help...?
I fixed it up and now getting this eror
(node:6449) UnhandledPromiseRejectionWarning: Error: Could not find endpoint
I fixed the url redirect
but still that error
Where are you running this code?
Anyone can help? I tried starting the RPC example, it starts fine, I can click the sneak, but... I dont really see how this has anything to do with discord? Its a webpage that tracks my clicks, what am I missing?
the example that tracks your clicks is just the frontend example, which doesn't have anything to do with discord. but the backend updates your rich presence based on data it retrieves from the client, clicks in this case. https://discord.com/developers/docs/topics/rpc
But how is that an example then? o.0 Also I'd have assumed that i'd need to be prompted to enter some login or soemthing, this just started an electron app with some clientID (which i've no clue what it is - but the code said "dont touch if you want example to work") so im a bit confused :S
In other words i've not really authorized my account anywhere, how would this "change" my client's status, for example
I might be going about this the wrong way, maybe I dont even need rpc
client id is the application's id which's name will be displayed in the rich presence (SnekBot in the example as far as I know). you can use any application's ID, including your bot, if you have one. the example is that because RPC is mostly used by games to update your presence/activity.
In other words i've not really authorized my account anywhere, how would this "change" my client's status, for example
it communicates with localhost as far as I know, so if you're logged in, your client grabs data from there and updates your presence/activity accordingly.
Umm, how can I set a RPC for my bot?
bots can't have RPC
Mhm, but, it doesn't do any of that which is what the problem is, my status doesn't change. Though, I think I've wondered off into a wrong direction, I think I dont need RPC for what Im trying to do. :S
Oh
Thanks
Thanks
@thick surge you should see this https://gc.gy/58481349.png
discord clients run a local server which programs you run can connect to
the programs tell discord their client id and then they can show presence
Hmm I dont see that so its weird :S But it turns out RPC is not what i need in the end so doesnt matter, thanks for help regardless
not sure if disabling showing game you're playing affects rpc, but probably does
Yup that was it
discord-rpc doesn't use user's token at all, right?
the lib doesn't
I wonder how the lib can show rich presences, only specifying application's ID
discord clients run a local server which programs you run can connect to
the programs tell discord their client id and then they can show presence
It only appears on application's owner?
no, you can use any application's ID
Oh ok
Thanks
How did he access to this program? 🤔
Oh, maybe electron
that's not supported here
why i cant setup the rpc
the example from github from discord.js
> discord-rpc@3.1.1 example C:\Users\gino\Desktop\RPC-master
> electron example/main.js
App threw an error during load
ReferenceError: app is not defined
at Object.<anonymous> (C:\Users\gino\Desktop\RPC-master\example\main.js:34:1)
at Module._compile (internal/modules/cjs/loader.js:880:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:892:10)
at Module.load (internal/modules/cjs/loader.js:735:32)
at Module._load (internal/modules/cjs/loader.js:648:12)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
at loadApplicationPackage (C:\Users\gino\Desktop\RPC-master\node_modules\electron\dist\resources\default_app.asar\main.js:109:16)
at Object.<anonymous> (C:\Users\gino\Desktop\RPC-master\node_modules\electron\dist\resources\default_app.asar\main.js:155:9)
at Module._compile (internal/modules/cjs/loader.js:880:30)
the error
the example shouldn't produce that error
i dont know how it works
wait i install it again
> discord-rpc@3.1.1 example C:\Users\gino\Desktop\discord emojis\RPC-master\RPC-master
> electron example/main.js
'electron' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! discord-rpc@3.1.1 example: `electron example/main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the discord-rpc@3.1.1 example script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\gino\AppData\Roaming\npm-cache\_logs\2020-06-03T09_11_37_265Z-debug.log
C:\Users\gino\Desktop\discord emojis\RPC-master\RPC-master>
now i got this
this is a new install
install electron globally
npm install electron
^^ ?? ^^
@vapid lake
-g
npm i electron -g
i got a popup
> discord-rpc@3.1.1 example C:\Users\gino\Desktop\discord emojis\RPC-master\RPC-master
> electron example/main.js
App threw an error during load
Error: Cannot find module 'node-fetch'
Require stack:
- C:\Users\gino\Desktop\discord emojis\RPC-master\RPC-master\src\client.js
- C:\Users\gino\Desktop\discord emojis\RPC-master\RPC-master\src\index.js
- C:\Users\gino\Desktop\discord emojis\RPC-master\RPC-master\example\main.js
- C:\Users\gino\AppData\Roaming\npm\node_modules\electron\dist\resources\default_app.asar\main.js
-
at Module._resolveFilename (internal/modules/cjs/loader.js:797:17)
at Function../lib/common/reset-search-paths.ts.Module._resolveFilename (electron/js2c/browser_init.js:7012:16)
at Module._load (internal/modules/cjs/loader.js:690:27)
at Function.Module._load (electron/js2c/asar.js:738:28)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Users\gino\Desktop\discord emojis\RPC-master\RPC-master\src\client.js:5:15)
at Module._compile (internal/modules/cjs/loader.js:967:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1004:10)
at Module.load (internal/modules/cjs/loader.js:815:32)```
npm i node-fetch -g
??????????
not globally
just run npm i with no other arguments
npm i node-fetch
no, install all dependencies
I feel like this is out of the scope of the channel now, though
it not work
if i run the example
it not count
at EventEmitter../lib/renderer/ipc-renderer-internal.ts.exports.ipcRendererInternal.send (electron/js2c/renderer_init.js:1841:20)
at EventEmitter.<anonymous> (electron/js2c/renderer_init.js:1803:26)
(node:12484) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12484) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Hello ! I keep getting this error :
at Socket.onerror (/storage/emulated/0/discord/rpc/node_modules/discord-rpc/src/transports/ipc.js:32:16)```
I think it doesn't work because of my OS (which is android, yes really). Is there anyway to fix this ?? I just tried reinstalling the lib but same error. Is this library not supporting android ? (I tried running the code with the Discord app openned and even the browser version)
Only desktop apps run an rpc server
oof
.
Only desktop apps run an rpc server
@ebon fox ok thanks
np
and is there a way to use the rpc without having discord running?
whats the point of having RPC if it wont even show on your profile?
and is there a way to use the rpc without having discord running?
no
hello!
I'm trying to integrate discord rpc to my mini-game project using electron.js (nodeJS). The display part is working as intented, but when i try to invite people to play, i get that weird error from Discord:
(i've tried in private messages and on servers, it's the same message everytime, but the "invite to spectate" works fine tho)
Here is my code:
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
DiscordRPC.register(clientId);
async function setActivity() {
if (!rpc || !main) {
return;
}
rpc.setActivity({
state: state,
startTimestamp,
largeImageKey: largeImageKey,
largeImageText: largeImageText,
smallImageKey: smallImageKey,
smallImageText: smallImageText,
partyMax: 8,
partySize: 1,
joinSecret: "someJoinSecretCode",
matchSecret: "justAnotherTest",
instance: false
});
}
rpc.on('ready', () => {
console.log(rpc.user);
rpc.subscribe('ACTIVITY_JOIN', ({ secret }) => {
console.log(secret);
// Handle join
});
rpc.subscribe('ACTIVITY_SPECTATE', ({ secret }) => {
console.log(secret);
// Handle spectate
})
rpc.subscribe('ACTIVITY_JOIN_REQUEST', (user) => {
console.log(user);
// Handle join request
})
setActivity();
setInterval(() => {
setActivity();
}, 15e3);
});
rpc.login({ clientId }).catch(console.error);
Any ideas where i can be wrong?
?docs guild.Members
#app-commands for personal usage
ah
sorry
I have a question about the entire DJS RPC itself.
Who/What person wod use RPC?
Just wondering.
A desktop application that would want to interact with your discord client @smoky scroll
Interesting. Thanks for the response.
@smoky scroll all the games that show info in discord use rpc
some other things like logitech gwhatever use rpc to bind custom hotkeys and stuff
some audio apps use rpc to control discord's audio settings
Can i make status with discord.RPC for my bot?
bots can't have a rich presence
Oh
😦
@glad zephyr yes, your and the user your trying to dm must be in the same server, either that or the user has the bot blocked.
Look at the error message Clyde is sending you.
yea i know that
but i'm sending this to a server
then i've tried in a private group with friends
and also with my alt account
it's working when using the game sdk
but not the discord-rpc
what i should do?
Install git
hey everyone, I have this website:
https://jstris.jezevec10.com/
that I turned into an electron app with this npm package
https://github.com/jiahaog/nativefier
everything works fine but I realized that I need to manually add the game for it to show in game activity, and I want this to be done automatically which is how I found out about rich presence and the djs-rpc package, my question is: where and how am I supposed to add this? all I need is to show "playing jstris" for anyone who uses the electron app, I don't care about anything else.
if you can help me with this please ping me 🙏
RPC is usually done in the main process, in which you retrieve data from the renderer process. I don't know how that package works, but I'll look into it.
thank you very much
all I know is that nativefier has an option to inject Javascript so idk if it could be done like that
Why don't you try it :)
I did of course
but I either didn't do it correctly, or didn't use the rpc correctly, or it doesn't work like that
welp, I was able to use rpc really easily in the electron-quick-start app
I guess I'll just make the electron app myself
How to start out learning rpc?
you can try reading the docs but theyre incomplete, you can read discord's documentation and read the source code
Il your need a simple set activity rpc with integrated question and colors...
Just go to https://github.com/MrNossiom/CustomDiscordRichPresence...
If your need more help just contact me...
And PLEASE DISCORD JS UPDATE YOUR DOCS ABOUT RPC
devsnek lazy

okay thx
what is rpc
why do i get this when i invite to join
I got this in the console of dev tools of Discord (Ctrl + Shift + I)
maybe because im not setting the party id, how do i set the party id?
This is all docs says, it doesnt say anything about what to put in the first param
and according to Discord docs, we should do { party: { id: "id here", size: [1,2] } } (or similar)
which i tried, but then (thanks to VSC's autocomplete) realized this library uses partyMax and partySize
but can't find how to set the party id.
This should be documented in my opinion
Just looked at the source code, it was partyId
okay it worked
thanks anyway
I am literally just running the example, and getting an error. what am I doing wrong?
const RPC = require('discord-rpc');
const clientId = '725924742569132093';
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('488060543693750293');
});
// Log in to RPC with client id
client.login({ clientId, scopes });
$ node --trace-warnings index.js
(node:19580) UnhandledPromiseRejectionWarning: undefined
at emitUnhandledRejectionWarning (internal/process/promises.js:151:15)
at processPromiseRejections (internal/process/promises.js:211:11)
at processTicksAndRejections (internal/process/task_queues.js:98:32)
(node:19580) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:19580) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:161:11)
at processPromiseRejections (internal/process/promises.js:213:13)
at processTicksAndRejections (internal/process/task_queues.js:98:32)
https://github.com/devsnek/discord-rich-presence/issues/5 might be this? but idk
I dont understand why it cant connect to discord rpc. i tried out https://marketplace.visualstudio.com/items?itemName=icrawl.discord-vscode which uses this package and it connects fine
I switched from windows to linux and got the same issue over there
ok I figured that out, but now after I launch my app it always prompts on discord for access then i get this error
(node:5119) UnhandledPromiseRejectionWarning: Error: Not authenticated or invalid scope
at RPCClient._onRpcMessage (/home/mcpqndq/repos/rpcTest/node_modules/discord-rpc/src/client.js:177:19)
at IPCTransport.emit (events.js:315:20)
at /home/mcpqndq/repos/rpcTest/node_modules/discord-rpc/src/transports/ipc.js:134:18
at decode (/home/mcpqndq/repos/rpcTest/node_modules/discord-rpc/src/transports/ipc.js:92:5)
at Socket.<anonymous> (/home/mcpqndq/repos/rpcTest/node_modules/discord-rpc/src/transports/ipc.js:120:7)
at Socket.emit (events.js:315:20)
at emitReadable_ (_stream_readable.js:562:12)
at processTicksAndRejections (internal/process/task_queues.js:83:21)
(node:5119) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
code:
const RPC = require('discord-rpc');
const clientId = '725924742569132093';
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('81384788862181376');
});
// Log in to RPC with client id
client.login({ clientId, scopes: ['rpc'] });
@round orbit you need permission from discord for certain scopes
Is the one for rich presence one of those
@round orbit no, rich presence is available with no scopes
Rpc has scopes, and some of them are whitelisted.
Rpc itself isn't a scope
o
If I just want to use rich presence do I use no scopes.
link doesn't work?
those are docs
What does rpc do?
@frosty lagoon a collection of APIs for games to communicate with your discord client
oh
So the docs is just 1 example?
how can i set up status for visual code
like iam getting error when i install vscode-discord
that's unrelated to this channel
this is also a thing
no
could someone with my ip address put rich presence on me
@unborn stream what?
cuz to use rpc you need to access localhost:something so if someone had my ip can they do this remotely?
@unborn stream no
rpc server is not listening for everything coming to it. since it's listening specifically on localhost and not on 0.0.0.0, it only accepts connections from localhost.
ok
so theoretically i could make a server to forward from 0.0.0.0 to localhost to control it remotely?
rpc works over ipc
you need special permission from discord to use rpc over tcp
what i mean is if i had a server that is connected to my rpc i can control it remotely
my server process would be connected to discord client
So uh im trying to sift through an array that i get from a json file but when i try and send the string inside an embed the chars are improperly encoded any ideas on where im going wrong?
$data = json_decode(file_get_contents(__DIR__ . "/data.json"), true);
foreach ($data as $user => $data) {
if (strpos($user, $target) !== false) {
$matches[] = " - $user";
}
}
$matches = [];
$mtime = microtime(true);
$took = round(((microtime(true) - $mtime)), 3);
if ((count($matches) <= 50) && !empty($matches)) {
$message->channel->send("", ["embed" => [
"title" => count($matches) . " Matches for \"{$target}\"",
"description" => implode("\n", $matches),
"color" => 0x63ffd0
, "footer" => [
"text" => "Ran by: {$message->author->username}#{$message->author->discriminator} | Took {$took}s", "icon_url" => $message->author->getAvatarURL()
]
]]);
} else {
return false;
}```
Hey
If I upload and save an image asset, and reload it dissapers
This isn't website support
Can you provide an rpc oauth2 access token or whatever somehow with discord-rpc?
ya
rpcToken
thanks
/home/miha/Desktop/EasyRPC/node_modules/discord-rpc/src/client.js:637
...r,
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/miha/Desktop/EasyRPC/node_modules/discord-rpc/src/index.js:6:11)
yes i did
what's your installed node.js version, looks like it doesn't support spread syntax yet
wait what how is it 10, i updated it like a couple days ago
well it didnt use the new version as the default :/
didnt fix it
12.18.2
node version
:(
Can i use djs rpc in my site? (I know XD but can i?)
old node version was NOT the issue
:(
@stray minnow https://gc.gy/62359652.png
?
@stray minnow works fine in 12.18.2
not for me
I have this error when I try to use the rpc client...
UnhandledPromiseRejectionWarning: Error: Could not find endpoint
at findEndpoint (/Users/Milo_Moisson/Desktop/Programmation/Bot Discord/RPC/node_modules/discord-rpc/src/transports/ipc.js:45:11)
at findEndpoint (/Users/Milo_Moisson/Desktop/Programmation/Bot Discord/RPC/node_modules/discord-rpc/src/transports/ipc.js:55:12)
This is my code:
const RPC = require('discord-rpc');
const chalk = require('chalk');
const { clientId, clientSecret } = require('./config');
const scopes = ['rpc', 'messages.read'];
// Import
// User Questions Script
// Set User RP
const RPClient = new RPC.Client({ transport: 'ipc' });
// Login
RPClient.on('ready', () => {
console.log(chalk.red('Ready !'));
});
RPClient.login({ clientId: clientId, clientSecret: clientSecret, scopes: scopes });
I don't understand...
This is the part where is does not work:
async function findEndpoint(tries = 0) {
if (tries > 30) {
throw new Error('Could not find endpoint');
}
const endpoint = `http://127.0.0.1:${6463 + (tries % 10)}`;
try {
const r = await fetch(endpoint);
if (r.status !== 401) {
return findEndpoint(tries + 1);
}
return endpoint;
} catch (e) {
return findEndpoint(tries + 1);
}
}
He cannot fetch the endpoint... But why ?
And why I get en error when I try to create a new client with transport 'websocket'
@carmine mica
@rough isle that means it can't find the client in your computer
And can I do to fix that ?
Because My discord is open ?
@carmine mica
@rough isle idk
did you install it with snap?
is the code running on the same device as your client?
did you install it with snap?
Waht is snap
is the code running on the same device as your client?
Yes
@carmine mica

Do you have an example that work ?
Just a simple one
your code should work
And why do I have an error undefined
well it might tell you your scopes are invalid cuz you aren't whitelisted for them but it should work
With no place where there is errors
idk
if you consistently get undefined as an error try attaching a debugger and stepping through the code until you find the relevant throw
There's a debuger attached...
I use vs code
@carmine mica
that doesn't help
step through
I think vscode has a button for stepping
Yes
It fail on login
I already know that...
step into the rpc code
not just your code
I already did that...
step to whatever throws the error
like for the login func ?
what inside the login func throws the error
It is client.js:110:9
The reject has nothing so it console.log underfind
this.transport.once('close', () => {
this._expecting.forEach((e) => {
e.reject(new Error('connection closed'));
});
this.emit('disconnected');
reject(); // <-- this one...
});
nice
?
@carmine mica
@carmine mica What do I do next ?
update to 3.1.2
I did it
And next
@carmine mica
¯_(ツ)_/¯
But it just change the error
well the connection closed
So there is nothing to do ?
idk
i'm sure there's a problem somewhere
but i can't debug your computer
@carmine mica:
what is does on yours
just to see if normal...
@rough isle that's normal
Why ?
discord.rpc
how i can create update Overwrite voice channel
not something to ask here, but: https://discord.js.org/#/docs/main/stable/class/GuildChannel?scrollTo=updateOverwrite, a VoiceChannel is also a part of GuildChannel, as it extends, so yes. please ask further discord.js related questions in #archive-updating-to-v13 instead
Anyone know why it says could not connect?
@smoky scroll same problem with me happens
Anyone know why it says could not connect?
@vital salmon I found the fix
i'll dm you it :))
@smoky scroll bro not that Spotify
Rpc
I wnat visual studio code rich presence
i'll dm you
well
nvm
it was an example
on how it wrks
rpc.createLobby("DevelopmentPool",4)
.then(p => {console.log(p)})
.catch(e => {console.log(e)})```
Creating a lobby in my ready event
at RPCClient._onRpcMessage (C:\Users\jeffr\Desktop\SGL\node_modules\discord-rpc\src\client.js:177:19)
at IPCTransport.emit (events.js:223:5)
at C:\Users\jeffr\Desktop\SGL\node_modules\discord-rpc\src\transports\ipc.js:134:18
at decode (C:\Users\jeffr\Desktop\SGL\node_modules\discord-rpc\src\transports\ipc.js:92:5)
at Socket.<anonymous> (C:\Users\jeffr\Desktop\SGL\node_modules\discord-rpc\src\transports\ipc.js:120:7)
at Socket.emit (events.js:223:5)
at emitReadable_ (_stream_readable.js:576:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 4000,
data: {
code: 4000,
message: 'child "type" fails because ["type" must be a number]'
}
}```
results in this error
Am I doing something wrong?
So I found out what's causing this
first argument must be either "PRIVATE", "PUBLIC", 1, 2
fixed that
at RPCClient._onRpcMessage (C:\Users\jeffr\Desktop\SGL\node_modules\discord-rpc\src\client.js:177:19)
at IPCTransport.emit (events.js:223:5)
at C:\Users\jeffr\Desktop\SGL\node_modules\discord-rpc\src\transports\ipc.js:134:18
at decode (C:\Users\jeffr\Desktop\SGL\node_modules\discord-rpc\src\transports\ipc.js:92:5)
at Socket.<anonymous> (C:\Users\jeffr\Desktop\SGL\node_modules\discord-rpc\src\transports\ipc.js:120:7)
at Socket.emit (events.js:223:5)
at emitReadable_ (_stream_readable.js:576:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: 1000,
data: { code: 1000, message: 'Unknown Error' }
}```
getting unknown error now
the error comes from discord
its as unknown to me as it is to you
RPC.Client().user is a user of discord i mean the discord of the person pc ;-; i dont know how to say i mean the user of discord not the bot
it shows discord user id?
My Code```js
const RPC = require("discord-rpc")
const clientId = '732932007386021980';
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 });
Error:
nvm
understanded how to
how to delete a message sent by a bot? .then message.delete({timeout:2000})??
is normal djs #archive-djs-v12-deprecated
hey
umm so did djs rpc can be use to discord bot ?
no
hi
This RPC Client does not seems to works while using scopes or websocket...
Does the DJS memebers are trying to keep this project alive or does he is over ?
I tried on Mac and Windows...
@smoky scroll The websocket transport does not work and scopes either
@carmine mica
@rough isle are you whitelisted to use the websocket transport
Haw can I check ?
@carmine mica
you would know if you were lol
I am on a administrator session
you have to ask permission from discord to use websockets
In the dev portal ?
i don't know how they do it these days
@carmine mica And for the scopes ?
Is it because RPC is in private beta ?
rpc isn't in private beta
and you'll have to be more specific than "scopes don't work"
If you connect without scopes it works for me
But else it does not work
what does "scopes do not work" mean
does it mean that when you try to connect with scopes, the client deletes all your files?
or perhaps that it rick rolls you
@carmine mica How do I get a message with the messages.read scope and with ipc transport ?
I use:
const RPC = require('discord-rpc');
const chalk = require('chalk');
const { clientId, clientSecret } = require('./config');
const scopes = ['rpc', 'messages.read'];
// Import
// User Questions Script
// Set User RP
const RPClient = new RPC.Client({ transport: 'ipc' });
// Login
RPClient.on('ready', () => {
console.log(chalk.red('Ready !'));
});
RPClient.login({ clientId: clientId, clientSecret: clientSecret, scopes: scopes });
RPClient.subscribe('MESSAGE_CREATE', console.log)
Is this ok ?
you need to subscribe to a channel to get MESSAGE_CREATE events
Oh ok
Like this ? :RPClient.subscribe('MESSAGE_CREATE', {channel_id: '379350641761320982'}, console.log)
i don't remember off the top of my head
This is like that on the wiki
But it does not work
Also Ive got this error: Could not find endpoint
So I does not find the server
But it does not work
Logic
that means it couldn't connect to your local client
Yes but why ????
¯_(ツ)_/¯
you're running this code on your local computer right
Yes
¯_(ツ)_/¯
did you install discord with snaps or smth
Does it work on yours ?
no with original installer
x
? @carmine mica
x
x
Wut ?
hmm
oh right i forgot
????
Ok...
@rough isle there might be a bug in discord
Ok
thanks
@rough isle i've verified there's no bug, you're most likely missing permission to use the event
??
facts
hi
i am wondering how can i show the time
of the music playing
anyone knows a way?
i see this channel is relatively active
is the rpc api public now?
is it?
how to use RPC
i mean
i want RPC like this via a bot
State: Hosted by [HMO] SCRplayer2403
Details: Hosting a training
Party size- 1
Party max- 20
Join- The training channel
hey
lets say i want to have my bot to say this in the rpc
but i have no idea where to put the code
code:
static void UpdatePresence()
{
DiscordRichPresence discordPresence;
memset(&discordPresence, 0, sizeof(discordPresence));
discordPresence.state = "Ik ben een discord bot gemaakt door Ties113#9851";
discordPresence.details = ">help";
discordPresence.largeImageKey = "catto";
discordPresence.largeImageText = "Very cool guy";
discordPresence.smallImageText = "Level 100 Chad";
discordPresence.partyId = "ae488379-351d-4a4f-ad32-2b9b01c91657";
discordPresence.partySize = 1;
discordPresence.partyMax = 2;
discordPresence.spectateSecret = "MTIzNDV8MTIzNDV8MTMyNDU0";
discordPresence.joinSecret = "MTI4NzM0OjFpMmhuZToxMjMxMjM= ";
Discord_UpdatePresence(&discordPresence);
}
@trim shale discord.gg/discord-developers for help with game sdk
ok thx
I could get an answer there
why tag me?
lol
i dont know anything
i can tim sort
sorry
so i get this when i attempt to connect to discord rpc
at IPCTransport.<anonymous> (/home/ararouge/rpc/node_modules/discord-rpc/src/client.js:118:16)
at Object.onceWrapper (events.js:421:26)
at IPCTransport.emit (events.js:314:20)
at /home/ararouge/rpc/node_modules/discord-rpc/src/transports/ipc.js:137:18
at decode (/home/ararouge/rpc/node_modules/discord-rpc/src/transports/ipc.js:92:5)
at Socket.<anonymous> (/home/ararouge/rpc/node_modules/discord-rpc/src/transports/ipc.js:120:7)
at Socket.emit (events.js:314:20)
at emitReadable_ (_stream_readable.js:564:12)
at processTicksAndRejections (internal/process/task_queues.js:79:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12133) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12133) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
const DiscordRPC = require("discord-rpc");
const start = new Date();
const scopes = [ "rpc" ];
let rpc = {};
let object = JSON.parse(require("fs").readFileSync("conf.json"));
let status = {};
const setactivity = () => {
rpc.setActivity(status.status);
};
const changegame = () => {
status = object[Math.floor(Math.random() * object.length)];
status.status.startTimestamp = start;
rpc = new DiscordRPC.Client({ "transport": "ipc", scopes });
rpc.login({ "clientId": object.id });
rpc.on("ready", () => {
setactivity();
setTimeout(rpc.destroy, 30000);
setTimeout(changegame, 30000);
});
};
changegame();
this is my code
@ararouge#6722 you might want to try the discord-rich-presence module
ok nvm
Where i can ask questions about Web build ?
Hi
For use the discordrpc in web browser, how can I do?
how to make rich presence in my java app?
by realising that java is not javascript
smpg
o im search in github]
rpc to java
1:1 tip 🙂
🙂
java is not javascript.
now stop the troll
java is not javascript.
@left fjord i know
now stop the troll
@left fjord this is not troll
oh im braindead
this server is js
not java
my bad
sry
:d
For use the discordrpc in web browser, how can I do?
@smoky scroll can anyone help me?
@Cosis#0846 you need to be whitelisted by discord first
ok nvm
just few hours after they asked me in dms and i answered that they need to wait
o]
?docs
@proven forge, what would you like to search for?
Type cancel to cancel the command.
cancel
The command has been cancelled.
https://discordjs.guide/ @smoky scroll
?docs
@dusky axle, what would you like to search for?
Type cancel to cancel the command.
embed
cancel
?docs
@rigid orchid, what would you like to search for?
Type cancel to cancel the command.
Embed
#app-commands is a thing, and it is not this channel
hey, what's the process to be whitelisted by Discord?
?docs
@smoky scroll, what would you like to search for?
Type cancel to cancel the command.
message.channel
