#archive-rpc-help
21942 messages · Page 14 of 22
Why this section is ded
const client = require('discord-rich-presence')('YOUR-CLIENT-ID-HERE');
client.on('connected', () => {
client.updatePresence({
state: 'discription',
details: 'discription',
startTimestamp: new Date(),
largeImageKey: 'YOUR-IMATE-LARGE-HERE,
smallImageKey: 'YOUR-IMAGE-SMALL-HERE',
});
console.log("we are connected!");
});
I figured it out
it was going ahead and looking at the wrong path when finding the ipc
oh
yep
Hello, how can I get the RPC large image/small image on connect ? (using client id + secret id)
(you can ping me)
Hello how can i jump lines in the rpc state or make a slider because my text is not complete in the rpc ?
You can't
I can't login
hi was is the websocket transport and what's de difference with the rpc ?
Why is this extension used?
I mean what it does.?
this is rich presence
@left fjord i know but where can i use this extension?
that specific one is an extension in vscode
Can't this extension be used in bots😂?
no
bots cannot have rich presence
Ohk so this extension is made for making software and adding rpc to it.
right?
yes
Ohk
I'll have to learn how to make softwares with js.

@left fjord Can you help me with this?
I mean is there any library?
??
electron
@unborn stream can we make games for Discord in electron.js?
what are games for discord
boop the snek is the best game,cant imagine a better one tbh
i asume that means games that use the rich presence.
is it normal that i can just log onto my rpc using the client id?
is there any way to change state and details without affecting time
discord rpc
dead channel?
What is that lib? What is it for?
client.on('connected', () => {
client.updatePresence({
state: 'discription',
details: 'discription',
startTimestamp: new Date(),
largeImageKey: 'YOUR-IMATE-LARGE-HERE,
smallImageKey: 'YOUR-IMAGE-SMALL-HERE',
});
console.log("we are connected!");
});```
what does this do?
const RPC = require('discord-rpc')
const clientId = '783236336173842443';
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 });
Connection closed Error.

Use ipc instead of websocket
anyone knows why it fails to install?
wait hold on, ill send logs
npm WARN Could not resolve dependency:
npm WARN peer register-scheme@"github:devsnek/node-register-scheme" from discord-rpc@3.1.4
npm WARN node_modules/discord-rpc
``` Any ways to fix this? I get that errors when I do `npm i discord-rpc`
@smoky scroll that's not an error
that's a warning
oh
lemme
show the err
npm ERR! code 1
npm ERR! command failed
npm ERR! command git ls-remote ssh://git@github.com/devsnek/node-register-scheme.git
npm ERR! 'git' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
@smoky scroll iirc it is because you don't have git installed so better just install it
aye I just installed git
and it worked
thank you!
why is this error coming? ```internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'C:\Users\parthiv\Desktop\WhisBot'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}```
please stop posting your error in every channel
ok
does discord rpc adds rich presence to bots or users
?
Bots cant use rich presence
Only nornal discord users
Discord API doesnt allow rich presence for bots
ok
Also I used the example code ```js
const RPC = require('discord-rpc');
const clientId = '779007882573774868';
const scopes = ['rpc', 'rpc.api', '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('781506259235897346');
});
// Log in to RPC with client id
client.login({ clientId, scopes });```
Websockets just causes connection closed
how do i use discord rpc
hey.. can i use rpc on my discord bot?
What is rpc?
discord doesn't really display more than 24 hours
after that it just starts from 0
I used this code, I get no errors
and its still not working
const RPC = require('discord-rpc');
const rpc = new RPC.Client({
transport: "ipc"
});
rpc.on("ready", () => {
rpc.setActivity({
details: "Join xensis!",
state: "discord.gg/**********",
startTimestamp: new Date(),
largeImageKey: "teo_mask",
largeImageText: "I said join xensis, not hover over my picture...",
});
console.log("Rich presence has started")
});
rpc.login({ clientId: "768192429148471336" });
no
H
for some reason I keep seeing my IDE instead of my RPC
very sad
i.ex.
Any ideas how I'd solve this?
(Yes, I am using WebStorm, JavaScript and discord-rpc lib)
ok I turned it off and that fixed it but would love to test without having to close IDE lmao
Also a quick question, how does one add the Join/Ask to join buttons?
Like how do you tell RPC that you have a lobby.
I am not aware what the metadata is what <RPC>.createLobby(type, capacity, metadata); wants
Where could I find this?
Hello, does this module require Python ? because when i install it i have a python error lol
Probably requires python 2.7 to build some dependencies
Nothing unusual
but before when i install the module it works without python
Ya know it'd be easier to help if you'd say what the error is
node:8603) UnhandledPromiseRejectionWarning: Error: Could not connect9:47 PM
at Socket.onerror (/rbd/pnpm-volume/31b211f4-3324-486e-8d8d-9126c83eac48/node_modules/.registry.npmjs.org/discord-rpc/3.1.4/node_modules/discord-rpc/src/transports/ipc.js:32:16)
Error any one?
@spring dune ^^ sorry for ping
Why tag me I'm a beginner in RPC lmao
Also that is literal "Could not connect"
Can i show you my code?
Sure
Just post here kek
const RPC = require('discord-rpc');
const rpc = new RPC.Client({
transport: 'ipc'
});
rpc.on('ready', ready => {
rpc.setActivity({
details: "Making video",
state: "Testing",
startTimestamp: new Date(),
largeImageKey: "786624259954835457",
largeImageText: "hello world"
/* smallImageKey: "short",
smallImageText: "hi",
*/
});
console.log("rich presence is now active");
});
rpc.login({
clientId: "786624259954835457"
});
This not working showing me that error😔
Ten#0010 ^
Error plzz any one
How to do discord-rpc ? pls
Check the links in the channel topic
pollEmbed(msg, title, options, timeout, emojiList, forceEndPollEmoji);
i didnt understand how can i use that command
and what that has to do with rpc
which channel i have to use?
that is not rpc, and that also doesn't look like djs
Hey there anyone?
node:8603) UnhandledPromiseRejectionWarning: Error: Could not connect9:47 PM
at Socket.onerror (/rbd/pnpm-volume/31b211f4-3324-486e-8d8d-9126c83eac48/node_modules/.registry.npmjs.org/discord-rpc/3.1.4/node_modules/discord-rpc/src/transports/ipc.js:32:16)
Error any one?
@primal ingot check your clientId
ClientId is ok idk why this errror 😔
Is the id copied from the video tutorial you saw, or your own client id?
Also does the application have an image with the same name as the client id, as you've defined it as such?
Yahh its my bot client id
I mean application client id
#archive-djs-v12-deprecated @bright roost
yes saw it bruh, thx
Go there
Hi guys! Just a quick question, what should the clientId be ? Thanks! ❤️
App id
what is my fault
When I'm using Discord-rpc - When I close it, it close. But if I set it up on my Raspberry PI. Will it so still display for me?
no
rpc app has to run on same pc discord does
Sick. Thanks.
I have this error in official document's example code too
Can anyone explain connectToLobby a bit more for me?
I keep getting: Error: Lobby service is unavailable.
I'm using ipc as my transport
@spring dune you most likely do not have permission to use it
It requires permission?
@carmine mica
yes
Hi what can we do with the party id and ask to join in node js ?
what is the rich performance code
Thats rich presence not rich preformance
how do i make the time show 19:30 minutes left? instead of showing 19:30 elapsed
elapsed it's because you set a endtimestamp less important that the startTimestamp @clear cipher
Hi what can we do with the party id and ask to join in node js ?
whats does that supposed to mean??
Pass when it ends
With a separate property
could u show me a example
could anyone show me a example of how to do this
and instead of making it show PLAYING A GAME could i change it to something else? just like when a user uses spotify it says Listening to spotify and not playing spotify.Could i maybe change it to something like watching youtube or something like that
where can I find the docs of the args?
is it possible to change the rpc background color?
No
the error I get: Error: OAuth2 Error: invalid_request: Missing "redirect_uri" in request.
here's my code: https://srcb.in/rxWlBsQRVz
idk how to set the redirect uri
I actually did it but I get a Bad request error
@unkempt meadow what does your party id ?
what?
line 15
it's a random id
is it usefull ?
idk actually not in my case
ok
i think go on your developpers portal in the oauth of your app
still getting this error:
what's this
anyone?
pass an endTimestamp to the activity
Oh
let endTimestamp = new Date()
rpc.setActivity({
details: `booped ${boops} times`,
state: 'in slither party',
endTimestamp,
largeImageKey: 'snek_large',
largeImageText: 'tea is delicious',
smallImageKey: 'snek_small',
smallImageText: 'i am my own pillows',
instance: false,
});
Like that?
let d = new Date();
const endTimestamp = new Date(d.getFullYear(),d.getMonth(),d.getDay(),d.getHours(),d.getMinutes() + 20,d.getSeconds(),d.getMilliseconds());
rpc.setActivity({
details: `Watching ${anime}`,
state: `On episode ${ep}`,
endTimestamp,
largeImageKey: large_img,
largeImageText: anime,
smallImageKey: 'animedao',
smallImageText: 'On https://animedao.to',
instance: false,
}).catch(e => console.log("\x1b[33m%s\x1b[0m",e))
it says 00:00 left
the date constructor doesn't take multiple arguments, just use Date.now() + 20 * 60 * 1000 if you want it to end in 20 minutes
can you have two scripts connect to regular and canary instance at the same time?
I'm trying to use the RPC package with React using the websocket method but i'm getting this error in the console. How can i fix this?
My code:
const rpc = new Client({
transport: "websocket"
});
rpc.on("ready", () => {
rpc.setActivity({
details: "Test",
state: "test",
startTimestamp: new Date()
});
console.log("Rich presence now active.");
})
rpc.login({
clientId: "789853560376000523"
}).catch(err => console.log(err))
I tried using IPC but that doesn't work in browsers.
ugh, the ipc backend would support setting your ipc client id, but the rpc.login just doesn't...
is it possible to make the time 12:00 / 20:00? I just realised that is the same as endTimestamp but I still wanna know if its possible
@mighty pendant i think for the login,theres no clientId option,in the example,its a string
let clientId = "789853560376000523"
rpc.login({ clientId }).catch(err => console.log(err))
How is this any different though? 🤔
ur giving a string to a option that does not exist,what do u think?
but how is
let clientId = "789853560376000523"
rpc.login({ clientId })
any different from
rpc.login({clientId: "789853560376000523"})
Yours is just using the shorthand
you could write your snippet as
let clientId = "789853560376000523"
rpc.login({ clientId: clientId })
._.XD
I have never understood rpc.
Does it check if discord is on the pc and runs it through that?
it doens't "check"
it simply connects to it
oh
Does it work with mobile too?
like if I make an nodejs app here on my phone
no
mobile app does not have rpc server
oh right
there was an experiment with game detection, that was running as a separate service, but it was long ago
ah
I was looking at the RPC documentation and it say RPC is in a private beta. I've used Discord.js-RPC before though
Am I missing something?
could I change the type of the status? Like can i change PLAYING to WATCHING?
can i change my application name? I mean not manually but by code
How could I make so my RPC tells how long it's been on?
rpc.setActivity({
startTimestamp: new Date()
});
Thank you!
Completely noob javascript question, how do I get access to unsubscribe in here (from rpc client.js):
/**
* Subscribe to an event
* @param {string} event Name of event e.g. `MESSAGE_CREATE`
* @param {Object} [args] Args for event e.g. `{ channel_id: '1234' }`
* @param {Function} callback Callback when an event for the subscription is triggered
* @returns {Promise<Object>}
*/
subscribe(event, args, callback) {
if (!callback && typeof args === 'function') {
callback = args;
args = undefined;
}
return this.request(RPCCommands.SUBSCRIBE, args, event).then(() => {
const subid = subKey(event, args);
this._subscriptions.set(subid, callback);
return {
unsubscribe: () => this.request(RPCCommands.UNSUBSCRIBE, args, event)
.then(() => this._subscriptions.delete(subid)),
};
});
}
Is await rpc.subscribe() sufficient?
const { unsubscribe } = await client.subscribe(...)
I have this and it seems to work:
let activityJoinRequestUnsubscriber = null;
// other code here
if (!lobbyIsPrivate) {
activityJoinRequestUnsubscriber = await rpc.subscribe('ACTIVITY_JOIN_REQUEST', (args) => {
rpc.sendJoinInvite(args['user']['id']).catch(console.log)
})
} else if (activityJoinRequestUnsubscriber !== null) {
activityJoinRequestUnsubscriber.unsubscribe()
activityJoinRequestUnsubscriber = null
}
I should check that unsubscriber is null before setting it again
but also, this entire thing I wanted to do doesn't work anyway so I'll just remove this roundabout way of sending the invite
I thought discord wouldn't send those invite to join messages when someone asks to join when you are subscribed to ACTIVITY_JOIN_REQUEST but it does
hey, I've searched for a long time but still didn't find anything...
everytime I try to run example, I'm getting body: { redirect_uri: [ 'Not a well formed URL.' ] }
doesn't matter what redirect url I type (on that site where you create apps), it throws this error... (using ipc ofc)
I too am curious
how would i add buttons like this?
buttons aren't documented on discord's side, hence there's no support for it in discord-rpc
damn
^^ this guy has the same question as me xD
what is this ? .setCertifiedDevices(devices)
Tell discord which devices are certified
and this ? .captureShortcut(callback)
Capture a shortcut using the client The callback takes (key, stop) where stop is a function that will stop capturing. This stop function must be called before disconnecting or else the user will have to restart their client.
thx
what are transport options in constructor options
nvm got it
how do I add buttons like this
the user said they used discord-rpc
transport options are ipc or websocket and it choose the way to communicate
with discord
if buttons aren't supported by discord how did they made those ?
how can we interact with the invite code in discordjs-rpc ?
documented != supported
you can still add buttons, but discord-rpc won't support them in setActivity
how can i add them @karmic jolt ?
look at the internal structure of the setActivity() method and use that to make a request to the websocket
but with transport ipc is it ok ?
sure
ok in the node modules files
thx
and question do you know if we can make someone open a browser when clicks join party ?
as in a custom button with that label or the rpc party function
can you voc i don't really understand
export interface Presence {
state?: string;
details?: string;
startTimestamp?: number | Date;
endTimestamp?: number | Date;
largeImageKey?: string;
largeImageText?: string;
smallImageKey?: string;
smallImageText?: string;
instance?: boolean;
partySize?: number;
partyMax?: number;
matchSecret?: string;
spectateSecret?: string;
joinSecret?: string;
}
``` Here is the presence in node_modules i don't see any button
because, as i said, discord-rpc doesn't support them
you're looking at the types, not the source
i don't really understand what is the source ?
yes i am there but where can i add the button
add an array like buttons: [{ label: 'hi', url: 'https://example.com' }] to the activity object at the bottom
and discord will add a button ?
try it
ok
it works but it don't redirects
thats normal, you cant click your own buttons
i will try with href redirect or other words
ah ok
try to click on mine ?
does it redirect to google ?
yes
thx
how did you know that ?
and why they don't documentate it ?
there's a pr open for that
ok thx
i follow you on github @karmic jolt
cool
Hey i have a question what can we do with client secret party id etc with discord js rpc ? Can we redirect to a link ?
Is there an example floating around using .subscribe() for voice state changes? I can't seem to grab anything, despite being auth'd. ie, client.user is available.
Looked back a bit through chat history, seems there have been some other issues with 4006 error codes. Seems like I can get user info but can't subscribe to any events, or get guilds, channels, etc, despite having scopes for rpc, rpc.api, guilds, etc.
Would love some guidance if possible.
const clientId = '';
const clientSecret = ''
const scopes = ['rpc', 'rpc.notifications.read', 'guilds'];
DiscordRPC.register(clientId);
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
rpc.on('ready', () => {
console.log('Authed for user', rpc.user.username);
rpc.getGuilds(1000)
.then(c => {
console.log(c[0].name);
})
.catch(error => {
console.log(error);
})
rpc.subscribe("VOICE_STATE_UPDATE", (s) => {
console.log(s);
}).catch(error => {
console.log(error);
})
});
rpc.login({ clientId: clientId, clientSecret: clientSecret, clienscopes: scopes }).catch(console.error);
hi how to add buttons to rich presence
?
hi
@where everyone
iam using easy rp
if you're using some program you'll need to ask the people who made it
can i subscribe to any events like client.subscribe("*")
this sounds like an horrible idea
you want to have different callbacks for every event
not a giant callback with at best a switch statement in it
?help
[A]utomating the API in that way /is/ abuse. Automatically doing "X" every N is generally not a good idea. Where X could be posting a message, changing someone's nickname, renaming a role, changing a channel topic, etc...
Generally bots should only react to user actions...
Although, for very large N we generally don't care. But for small N, we do care. Think rainbow bots, etc....
~Jake@Discordapp 21/01/2018
source (Discord API): https://discordapp.com/channels/81384788765712384/381887113391505410/404566425454247938
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?
This is not #app-commands
How should I reconnect to discord when the user restarts theirs?
Even better question, how can I connect to discord if the user didn't start my app with discord open
function clearDiscord() {
rpc._connectPromise = undefined;
// noinspection JSAccessibilityCheck
rpc._subscriptions = new Map();
rpc.removeAllListeners('connected')
// noinspection JSAccessibilityCheck
rpc.transport.removeAllListeners('close')
}
This is what I found that works
This used to be a thing I think: https://github.com/discordjs/RPC/pull/67/files#diff-627fe08d8bba6a4fa76e7c5ed36ef6f16d126733e65e19236b391de0d34f1fe0R107
This used to be a thing for exactly no time at all as it was reverted the next commit:
How to check the position at which we joined the server
How the client know whom to give rpc?
@fathom lion you should create a new client instance for each connection
And create new listeners after it has connected?
So the examples are pretty out of date, every example makes the client/connection a const
the examples don't handle reconnecting lol
where is the event list for the rpc?
Also i couldn't find a full RPCLoginOptions
the event list is on official docs?
oh yeah that was my bad
what about RPCLoginOptions ?
i just found a little information about scopes on RPCLoginOptions
i saw guilds.join on discord scopes list, and i just thought it means we can make our client join a discord server?
like isn't that against discord TOS?
That is not what that means no
so what that means?
not just that, if we can move a user a to a voice channel from another one, it makes the client a kind of bot tho
and again discord TOS problem....
guilds.join is only for redirect links being able to join users to a guild
ok, i got about hte guilds.join,
about the move and stuff:
if we are using a kind of bot on our client to do the move and other things, isn't that makes it some kind of illegal?
(with discord-rpc lib)
No it's not , discord voice has some difference rules , and it's allowed to move users
oh ok didn't know about that
so about the login options
let's say i have a linux os
i have my discord logged in with my chrome or browser
how can i make the index.js that has discord-rpc to connect to the client logged in the browser?
and set data to it?
or even can we like, be logged out of the discord account from that os, and set rpc from another device?
Well now that last part seems kinda against the TOS of discord , but the first part should work just like a regular discord client
but if the last one is illegal, it means spotify is doing an illegal job tho, because i have spotify with other device running and the spotify account is linked to this discord account, and i will get the rpc still....
No , because spotify ITSELF is doing that
You are using a 3rd party RPC client that is unaffiliated with discord, trying to login a client that might not be expecting the action
Do you see the issue with that
no i didn't want to login to my account
i just wanted to give the 3rd party app(like my website) to set the rpc for me
without having any access to the client, like is that even possible?
so you just mean the Spotify is kind whitelisted to set this kind of data to our client, but not us?
I kinda misread what you were saying
But also, yes kinda , because spotify is a connection to your account
but wasn't there a connection for 3rd party apps too?
like our owns?
No I mean like, spotify is a CONNECTION, like one that you manaully add to your account on purpose for the sole fact of receiving that rpc
ok so that makes it legal
No it doesn't
for the spotify
i meant
No
i mean for the spotify company(or organization or whatever)
but isn't there anyway to make a connection for our 3rd party app (example a website)?
No i-
This kind of connection is what I mean ^
They have implicit access to do that because you connected them
I know about it, i was just thinking maybe discord has something for the developers too
Well yea , rpc should do that
sadly discord doesn't looks like have it for us tho
ok so about be logged in a browser
having a browser open an launching the index.js will do the work? (i use ipc as the connection tho)
Not sure if the website runs rpc server
i just got that as an example
Hey
I've noticed the ability of having custom buttons in rich presence, the only library that mentions these is djs-rpc.
My current code is
'use strict'; //whatever this is
const RPC = require('discord-rpc');
const clientId = '794670590555324418';
const client = new RPC.Client({
transport: 'ipc',
});
client.on('ready', async () => {
console.log("Ready")
await client.setActivity({
details: `Ali's Network`,
state: 'Hello',
largeImageKey: 'alibot',
largeImageText: 'Client by Ali\'s Network',
buttons: [
{label: 'Test', url: 'https://snek.dev/'},
{label: 'Work', url: 'https://thkc.space/'}
]
});
});
client.login({ clientId });
I'm currently running this but the buttons don't appear and I don't get any errors
Hey guys how do I use discord rpc to update my own status upon opening an app (e.g. Zoom Meetings) on their PC
I'm trying to use discord-rpc to enable rich presence for my discord profile but when I run the node program i get this error:
Error: connection closed
at IPCTransport.<anonymous> (C:\Users\Daniel\Documents\discord-presence\node_modules\discord-rpc\src\client.js:118:16)
I'm using Canary 73889 (844e5af)
Host 1.0.16
Windows 10 64-Bit (10.0.19041)
use client.request
can you access the client's images from the client id
Can we make a rich presence for the bot ?
no, those endpoints are only available to users
Oh ok
Maybe
try something like this ? ```js
activity : {
details: rpc.details ? rpc.details : undefined,
state: rpc.state ? rpc.state : undefined,
assets: {
large_text: rpc.assets.largeImageText ? rpc.assets.largeImageText : undefined,
large_image: rpc.assets.largeImageKey ? rpc.assets.largeImageKey : undefined,
small_text: rpc.assets.smallImageText ? rpc.assets.smallImageText : undefined,
small_image: rpc.assets.smallImageKey ? rpc.assets.smallImageKey : undefined
},
buttons: [{
label: rpc.buttons.primary.buttonLabelText,
url: rpc.buttons.primary.buttonRedirectUrl
},
...
Looks a little weird since I'm using a config.json
😓 sorry if this dosent help I'm not the most advanced person
It says could not connect:
const RPC = require('discord-rpc');
const clientId = '763367310273806366';
const client = new RPC.Client({
transport: 'ipc',
});
client.on('ready', async () => {
console.log("Ready")
client.login({ clientId }).catch(console.error);```
will i have to run it on computer or i can run it on any online repl?
??
?try
Try out the code before asking if it works.
Its not letting me install discord-rpc, any tips?
install git.
@solid ocean do you have a link to that?
no I don't. Google "how to install git on <your os>"
@solid ocean that did not fix the installing error..
does anyone know a fix?
the fix is installing git, make sure its added to path
What is this error : RPC_CONNECTION_TIMEOUT
you tried to set RPC too many times consecutively
AHHH ok
@sacred ore how do you make this? 😳
couldn't find anything for the buttons
its buttons: [ { label: ' ', url: ' ' }, { label: ' ', url: ' ' } ]
thanks 😳
@sacred ore is there a way I can get the code for the buttons thing in the rpc?
uh no
oop okay
const RPC = require('discord-rpc')
const clientId = '0';
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 });
I get this error
const client = new RPC.Client({ transport: 'websocket' });
^
TypeError: RPC.Client is not a constructor
Do you have the package installed correctly? Also, I wouldn't recommend using 'rpc.api' in the scopes
discord-rpc didnt install properly the first time 
im just using code example in the docs
idk anything about scopes
Well, that might be a problem then, you should make sure the discord-rpc is installed correctly.
Also, use 'ipc' for transport instead of 'websocket' or you'll also have problems with that in a bit.
Also, if you're just using RPC for just the RPC, then 'messages.read' isn't really necessary for your scopes either.
rpc.setActivity({
details : details,
state : state,
largeImageKey : 'agent',
largeImageText: 'Pooog',
smallImageKey : 'agent',
smallImageText : 'teest',
startTimestamp : new Date(),
})
is there more stuff i can add apart from these ?
Hello, Discord RPC allow only whitelisted urls for buttons? I tried some variants and nothing worked.
you need to install the master branch for buttons
I have already installed, but when I am clicking the buttons, no redirecting
you can't click your own buttons
wow, didnt know
How? git clone https://github.com/discordjs/rpc in node_modules?
npm i discordjs/rpc
I installed through npm install git+https://github.com/discordjs/RPC.git
Oooo thanks!
Please stop crossposting in every channel, especially since your problem has nothing to do with djs rpc or commando
Is it supposed to log Error: connection closed when i run the example?
Error: connection closed with a valid token
token?
it's a client id
and it is a real one
const DiscordRPC = require('discord-rpc');
const rpc = new DiscordRPC.Client({transport: 'ipc'});
rpc.login(myclientid);
myclientid is my actual id
(node:12704) UnhandledPromiseRejectionWarning: Error: connection closed
is it your user or your application id?
app id
@karmic jolt
sry ping
Its showing connection closed for me too 
are you running that on the same pc where you have the discord program open?
yeah
then not sure what else could be causing that
It's for a game client
const DiscordRPC = require('discord-rpc');
const { app, BrowserWindow } = require('electron');
const rpc = new DiscordRPC.Client({transport: 'ipc'});
let win;
async function createWindow() {
win = new BrowserWindow({ width: 1920, height: 1080, icon: __dirname + '/icon.ico' });
win.setMenu(null);
win.loadURL("https://krunker.io", {userAgent: "Chrome"});
win.setTitle('[РАША] Clan-Only Client');
win.on('page-title-updated', (evt) => {
evt.preventDefault();
});
/*rpc.setActivity({
largeImageKey: "thumbnail",
largeImageText: "[РАША] Clan-Only Client",
state: "Test",
details: "Discord RPC",
partySize: 0,
partyMax: 1
});*/
}
rpc.on('ready', () => {
app.whenReady().then(createWindow);
});
rpc.login(clientid);
electron
oh nevermind, i see
the login parameter should be .login({ clientId: clientid })
thanks!
works for me

const RPC = require('discord-rpc');
const rpc = new RPC.Client({
transport: 'ipc'
});
rpc.on('ready', () => {
rpc.setActivity({
// Stuff HERE
});
console.log("RPC Ready");
});
rpc.login({
clientId: "ID HERE"
})
Error
(node:6436) UnhandledPromiseRejectionWarning: Error: connection closed
you need to pass both the clientId and client secret to rpc.login
but it worked yesterday
and whats the key to pass client secret?
hmm did you update discord-rpc?
nope
many versions ago it didn't need the client secret
still doesnt
i'll try passing that, whats the key? 
clientSecret : ""
?
yeah
clientSecret
client secret is only needed for specific rpc methods, rich presence doesnt belong into that category
oh sorry then it worked for me so i thought we needed that
nope, connections closed
I want rpc source code
I get the error
UnhandledPromiseRejectionWarning: Error: connection closed
While trying to use discord-rpc
devsnakes's wrapper works fine tho
same issue while running npm run example
on the source code
using macOS 11
@potent quailone?
fuck....
sorry for the ping....
@rose bolt do you have transport set to ipc?
no websocket...
tried it on ipc
didnt work
same error
So you have this?
websocket is private and you cant use it
you must use ipc
i tried both....
Are you using the right client is
Id
yes
sorry had some weird internet issue....
i tried again with ipc
now shows UnhandledPromiseRejectionWarning: Error: OAuth2 Authorization Error: Unknown Error
Why can't I add time with the button?
I get this error when I add
startTimestamp is indeed not a valid property (https://discord.com/developers/docs/topics/gateway#activity-object for reference)
@karmic jolt
0 result
exactly
😦
look at the activity object on the discord docs site, there's a property which lets you set timestamps
I have been searching for 2 days, no result
Is there a way to add both button and time?
you can also install the master branch npm i discordjs/rpc which supports buttons on the setActivity() method
Discord rpc will work without even using the app right?
Yes
The only reason the app is In the example is to show that it can be updated from external variables from other applications like games you make etc
huh
how can rpc work without discord app
my rpc isnt showing
code:
const RPC = require('discord-rpc');
const cl = require('cli-logs');
const rpc = new RPC.Client({
transport: 'ipc'
});
rpc.on('ready', () => {
rpc.setActivity({
details: 'Developing a bot',
startTimestamp: new Date()
});
cl.connect('RPC is now active')
});
rpc.login({
clientId: 'my client id'
});
nvm
I think they meant the electron app
"app" is ambiguous
so "i think they meant discord app"

Welp we'll see 🙈
sorry, where's that docs cuz I couldnt find it
It's not
bruh
Lol
how tf then
Well the api tells you what it wants , so when you mess up it says sumn like "buttons: [Object[0]]" expected an object" etc etc, so I just kept working my way thru until I got it right
yeah ik but I would never know this by just lookin at the docs
which was posted here before this answer
It's not actually merged tho, hence why not documented and I had to bullshit my way thru finding it
Glad advaith is always ontop of things tho
it's right there
anyone?
plz give me djs diccord invite link
@left fjord
TNX
I want it to be in 2 things but I get errors like this
Isn't that feature available or am I just not able to do it?
im using
buttons: [{ label: 'test', url: 'some url' }]
for buttons but its not working
if this is not the way I should do it , how can I ?
?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?
if you need example
var rpc = require("discord-rpc")
const client = new rpc.Client({ transport: 'ipc' })
client.on('ready', () => {
client.request('SET_ACTIVITY', {
pid: process.pid,
activity : {
details : "text here!",
assets : {
large_image : "image-name",
large_text : "my Status" // THIS WILL SHOW AS "Playing <Status>" from the outisde
},
instance : false,
buttons : [{label : "test1" , url : "https://github.com/discord/discord-rpc"},{label : "test2",url : "https://github.com/discord/discord-rpc"}]
}
})
})
client.login({ clientId : "client-ID-HERE" }).catch(console.error);
thanks ,but what's pid ?
this is be index.js of your RPC files! :/
you can see js buttons : [{label : "test1" , url : "https://github.com/discord/discord-rpc"},{label : "test2",url : "https://github.com/discord/discord-rpc"}]
i used this , nothing got changed
by using client.setActivity({
when i use client.request , it asks me for a pid
what's pid ?
idk
check your DM i send all the src
How do I make rpc work if discord is closed and then opened again????
add timer for every 15 sec
rpc.on('ready', () => {
setActivity();
setInterval(() => {
setActivity();
}, 15e3);
});
That sounds like unnecessary amount of requests
15 seconds for example, you can set to 60 minutes or something like that
Is rpc even possible in android? 
no
Why?
because the mobile app does not have an rpc server
Ohh ohk
What happened if i open my discord in Android browser?
Same?
browser doesn't work on any device
it needs to be the desktop app
Ohk ty
Is it possible to set a custom activity for RPC? Like streaming, listening, or even a custom one if possible?
Not really
thanks!
When I upload an image to the rpc section of my application, it deletes it automatically when I refresh the page. Why is this?
did you save?
It's there, but doesn't always show unless you bugged the system like i did
this is why:
what
the connection is broken so it doesn't work
someone help 😦
does anyone know how to add the 'join' button?
pls help
dnfsdkfbndsjkfsdb ffdjkgfdnbgkdfjgbdfhjgfbdgjhfdgbdrft
stop spamming
stop mini-modding?
anyone knows if is it possible to insert links here?
it isn't
You need to fill in the party information, have a join secret, implement joinGame
Discord caches these, but this takes solid 5 minutes or more. When the image starts appearing on your app then it should also appear in the application page
That's answering this question
@fathom lion tysm but idk where to find the joinGame() method
and how do i check for a broken connection?
I think the rpc client emits 'disconnected' that is a good start. Also if the connection fails, an error is thrown
joinGame is probably in discord docs, that's what it was called before
rpc.subscribe('ACTIVITY_JOIN', ...
For how I do it, before devsnek said I should make new connection
thanks
what is the problem
you tell us
I get this error when doing button discord rpc
Can we have a full updated example?
on error make new client
hmmm im kinda bad at this cuz my rpc doesn't work:
- when discord is started after my app
- on app restart
decide what you consider to be an error that implies reconnecting is needed
and when that happens
create a new client
and login?
ya
so onError() {
rpc = new DiscordRPC.Client({transport: 'ipc'});
rpc.login();
}
cool, thanks
I got so close... Only it times out 😦
every time i try
why?
and invites don't work
wth
so what is transmitted matchSecret or joinSecret?
@carmine mica now my status is stuck as well
///////////////////////////////////
// Discord RPC //
///////////////////////////////////
// RPC Login Code.
const DiscordRPC = require('discord-rpc');
const { time } = require('console');
const { electron, chrome } = require('process');
const { webContents } = require('electron');
DiscordRPC.register('797056762649247745');
let rpc = new DiscordRPC.Client({transport: 'ipc'});
function initRPC() {
rpc = new DiscordRPC.Client({transport: 'ipc'});
rpc.login( {clientId: '797056762649247745'} );
rpc.addListener('ACTIVITY_JOIN', (args) => {
args = args.split('.');
let gameID = args[0];
window.location(`https://krunker.io/?game=${gameID}`);
});
rpc.addListener('ACTIVITY_JOIN_REQUEST', (args) => {
rpc.sendJoinInvite(args['user']['id']);
});
}
initRPC();
// RPC Status Code.
let gameData = null;
setInterval(() => {
let data = fetch(`https://matchmaker.krunker.io/game-info?game=${new URLSearchParams(location.search).get('game')}`)
.then(r => r.json())
.then(rData => {
gameData = rData;
}) .catch(err => {});
},1000);
var setActivity = setInterval(() => {
if(!rpc) {
return;
}
// Get all variables here.
{...}
// Set activity
rpc.setActivity({
largeImageKey: "thumbnail",
largeImageText: `Kills: ${kills} | Deaths: ${deaths} | Score: ${score}`,
smallImageKey: classNameEdit,
smallImageText: "Playing as " + className,
details: gameData[4].i,
state: gameType,
partySize: gameData[2],
partyMax: gameData[3],
startTimestamp: t1,
endTimestamp: t2,
instance: true,
joinSecret: new URLSearchParams(location.search).get('game')
}) .catch(err => {
initRPC();
});
}, 100);
add js to your codeblock like this:
```js
code here
```
let rpc = new DiscordRPC.Client({transport: 'ipc'}); this get overwritten
if(!rpc) { isn't this always true? not sure how Client casts to bool
.catch(err => {
initRPC();
})
pretty sure you don't want to init another client when you fail to set activity, activity can fail on reasons other than the client missing
pretty sure rpc.addListener('ACTIVITY_JOIN', needs to be rpc.subscribe('ACTIVITY_JOIN',
tysm @fathom lion once again
i did it glitched somehow
then how do I re-initialise on disconnect
rpc.on('disconnected' or look what the event is called
didn't it get removed?
vs code shows me:
or do I sub to the event
idk what else to say other than you don't have any reason to always trust your IDE...
client.request('SET_ACTIVITY', {});
as the inputs for the request, for the imageText should i add it on the assets or the main activity ?
and what should i call that? like largeImageText or what?
rpc.setActivity is already a function that does everything activity related, isn't it?
No need make a raw request yourself
for buttons it needs tho
Then just copy paste the code from source/github (which might even already have button support)?
well the only code i got is without imageText
This one
wait u mean djs-rpc is updated?
Probably not released, but buttons are working on master
i installed djs-rpc from npm, should i install the master from github or it will work on the last npm too?
cuz last publish on npm is 4 month ago
If you manually call the request same way it is done on master then it should work
(but idk how npm works or how you package your app or anything so ymmv)
well it does work but that's not my question
im asking about largeImageText where should i call that? on the assets or the main activity ?
or even largeImageText is a true thing to call?
Large image text is just a string. It's the tooltip that appear when you hover over the large image
So wdym you want to call that
look
we are sending a request with data right?
for having largeImage on our rpc we call that like this in assets on activity :
{
pid: process.pid,
activity: {
assets: {
large_image: 'pfp4'
},
details: 'tt',
state: 'tt',
buttons: [
{ label: 'label', url: 'url' }
]
}
}
you see we call it large_image in here for the sending raw request
so for the largeImageText what should we call it? and were should we call it?
i know raw events are different and i couldn't find anything on discord docs
An you couldn't look at the source code or read the discord documentation? You need to name that key "large_text"
i really didn't find anything in discord docs and i never had in my mind to look at the djs-rpc source code
I'm on mobile but this is what djs does
thank u so much! ❤️
@fathom lion Can you tell which mobile application you are making code from?
Can I activate my bot from the application you made a code for?
the image is a screenshot of github, wdym "making code from" ???
so im getting an error when setting up a discord-rpc module
all my packages are corrct
can anybody tell me whats wrong by looking at the error because i dont want to give out my client ids
is anyone familiar with the code for discord rich presence?
im kinda new to js and i was just wondering what are the limitations
Is it possible to make the join button take you to a link with a url parameter?
yes!
Can you tell me how
it's literally above
buttons: [ {label: 'button name', url: 'place url link here'}, ],
Is it possible for the game join button?
Not the custom ones
not really
what are you trying to do? are you a game developer?
Not really for a game
I wanted to do something like lobbies, the join button would take you to etc.com/see?id={the id}
ya no
join secrets are produced by the discord sdk, you cant really do that with a link
Hey so, i've been trying to setup the RPC client, which causes an error, this is the code:
let rpc = (new (require('discord-rpc')).Client({
transport: 'ipc'
}));
rpc.on('ready', async () => rpc.request('SET_ACTIVITY', {
pid: process.pid,
activity: {
state: 'Invite the bot and join us!',
details: 'Entertainment',
assets: {
large_text: 'VXC'
},
buttons: [{
label: 'Invite',
url: '<Some URL>'
}]
}
}));
rpc.login({
clientId: '<Client ID>',
clientSecret: '<Client secret>'
});```
And this is the error:
```js
Error: Could not connect```
Am i missing something?
dont use rpc.request, and also you dont need clientSecret
Should i use <RPCClient>#setActivity() instead?
yes
K lemme try
Still getting the same error
show current code
let rpc = (new (require('discord-rpc')).Client({
transport: 'ipc'
}));
rpc.on('ready', async () => rpc.setActivity({
state: 'Invite the bot and join us!',
details: 'Entertainment',
largeImageText: 'VXC',
buttons: [{
label: 'Invite',
url: '<Some URL>'
}]
}));
rpc.login({
clientId: bot.user.id
});```
put the whole set activity inside brackets
rpc.on('ready', async () => {
rpc.setActivity({
//stuff here
})
})```
I don't think that would change anything tho, just arrow function syntax
it shouldnt
but ya know
some things are stupid
let rpc = (new (require('discord-rpc')).Client({
transport: 'ipc'
}));
rpc.on('ready', async () => {
return rpc.setActivity({
state: 'Invite the bot and join us!',
details: 'Entertainment',
largeImageText: 'VXC',
buttons: [{
label: 'Invite',
url: '<Some URL>'
}]
});
});
rpc.login({
clientId: bot.user.id
});``` Same thing
hm odd
i dont know if its needed or not, but do you have rich presence assets added to the bot?
I do, at least one
how come its not listed in the setActivity
Huh?
largeImageKey
I don't think the issue is even related to that method
It's from <RPCClient>#login()
well i have no fuckin idea cuz thats what i have
Odd
rpc.login({ clientId }).catch(e => { console.log(e) });
Lemme see
Seems like it's coming from here
ik im looking at it rn
its coming from line 35
and i cant figure out why
actually no
wtf
Error: connection closed
at IPCTransport.<anonymous> (project path\node_modules\←[4mdiscord-rpc←[24m\src\client.js:118:16)
←[90m at Object.onceWrapper (node:events:483:26)←[39m
←[90m at IPCTransport.emit (node:events:376:20)←[39m
at project path\node_modules\←[4mdiscord-rpc←[24m\src\transports\ipc.js:141:18
at decode (project path\node_modules\←[4mdiscord-rpc←[24m\src\transports\ipc.js:92:5)
at Socket.<anonymous> (project path\node_modules\←[4mdiscord-rpc←[24m\src\transports\ipc.js:120:7)
←[90m at Socket.emit (node:events:376:20)←[39m
←[90m at emitReadable_ (node:internal/streams/readable:565:12)←[39m
←[90m at processTicksAndRejections (node:internal/process/task_queues:79:21)←[39m
Process finished with exit code 1```
why can't I log in?
show the code
const RPC = require('discord-rpc');
const rpc = new RPC.Client({transport: 'ipc'});
rpc.on('ready', async () => {
await rpc.setActivity({
startTimestamp: new Date(),
buttons : [
{
label : "test",
url : "https://youtu.be/dQw4w9WgXcQ"
}
]
});
console.log("RPC set");
});
rpc.login({clientId: "95879008242761739"});```
but my IDE is messing up the params, such as
and
are you sure you have the right discord-rpc?
Wait, the reason might be because I'm trying to open an RPCClient in the same place where I'm hosting my bot? @sacred ore
no thats not why cuz its what i do
I installed from discordjs/rpc, isn't that stable?
Hmm strange
that could very well be the reason
it needs to run on the same pc where discord is open
Wait what
ah yea i forgot it needs to connect to the client on the computer
you cannot host ipc connections on a vps or similar
Damn, lemme see
yea rpc only works if its able to find a running discord process.
is it possible to run Discord on a VPS then? lol
uh i mean, sure?
it would take some work
ive done it before tho.
but youre probably just better off hosting it on the pc instead of wasting resources on discord running
Wait, does it seriously have to be done on a PC? Not possible with mobile using for example Termux?
yea it doesnt work using the mobile app either im p sure
Damn, at least we tried 
its why i like hosting my bot on my pc
cuz i can just include it in the bot file
You're not using a VPS for your bot?
hell no
Welp, i'll try again when i get a PC soon 
alright 🤣
// RPC Login Code.
const DiscordRPC = require('discord-rpc');
const { time } = require('console');
const { electron, chrome } = require('process');
const { webContents } = require('electron');
DiscordRPC.register('797056762649247745');
let rpc = new DiscordRPC.Client({transport: 'ipc'});
function initRPC() {
let rpc = new DiscordRPC.Client({transport: 'ipc'});
rpc.login( {clientId: '797056762649247745'} ) .then(() => {
rpc.subscribe('ACTIVITY_JOIN', (args) => {
args = args.split('.');
let gameID = args[0];
window.location(`https://krunker.io/?game=${gameID}`);
});
rpc.subscribe('ACTIVITY_JOIN_REQUEST', (args) => {
rpc.sendJoinInvite(args['user']['id']);
});
}) .catch(err => {});
}
initRPC();
// RPC Status Code.
let gameData = null;
setInterval(() => {
let data = fetch(`https://matchmaker.krunker.io/game-info?game=${new URLSearchParams(location.search).get('game')}`)
.then(r => r.json())
.then(rData => {
gameData = rData;
}) .catch(err => {});
},1000);
setInterval(() => {
{...}
rpc.setActivity({
largeImageKey: "thumbnail",
largeImageText: `Kills: ${kills} | Deaths: ${deaths} | Score: ${score}`,
smallImageKey: classNameEdit,
smallImageText: "Playing as " + className,
details: gameData[4].i,
state: gameType,
partySize: gameData[2],
partyMax: gameData[3],
startTimestamp: t1,
endTimestamp: t2,
instance: true,
joinSecret: new URLSearchParams(location.search).get('game')
}) .catch(err => {
initRPC();
});
}, 100);
``` This is what I have so far, still not working 😦
Just spams me with RPC_TIMEOUT
?code
Codeblocks:
```js
const Discord = require("discord.js");
// further code
```
becomes
const Discord = require("discord.js");
// further code
Inline Codeblocks:
`console.log('inline!');` becomes console.log('inline!');
UnhandledPromiseRejectionWarning: Error: Could not connect
are you using websocket or ipc transport
Hi, What is is Discord-Rpc?
rpc is what allows other applications to talk to discord
it is mostly used for rich presence
Ah, I see tnx
This
The "Playing a game"
o
wait
i didnt scroll down lmfao
I want to use discord-rpc for status however it errors ```js
UnhandledPromiseRejectionWarning: Error: child "activity" fails because [child "assets" fails because [child "small_image" fails because ["small_image" is not allowed to be empty]]]
Because I dont want a small image
Can you give me the code of that
@hidden drum question: can you click on the buttons in my presence to see if they work? They're not working for me
idk if its just me tho
I dont know how to do discordrpc with disocrd.js
Only java
Works!
yay!
these new buttons are fun :)
can you tell me the code of it? I want to remove small image and yours doesnt have one so I can copy that part?
@halcyon hill
@hidden drum
import RPC from 'discord-rpc'
const client = new RPC.Client({ transport: 'ipc' })
client.on('ready', () => {
client.request('SET_ACTIVITY', {
pid: process.pid,
activity: {
assets: {
large_image: 'lnb'
},
details: 'The best multipurpose Discord bot!',
buttons: [
{ label: 'Check out the bot!', url: 'https://top.gg/bot/646156214237003777' },
{ label: 'More about me!', url: 'https://t1c.dev/' }
]
}
})
console.log('started!')
})
client.login({clientId: '799340370059591741'})
Ok
Thanks
np!
ipc
when i do websocket i get this error```
(node:24194) UnhandledPromiseRejectionWarning: Error: connection closed
you probably set it to null or an empty string instead of just not including it at all
hm, can you try closing it, fully quitting discord, reopening discord, and running it again?
i'm on browser right now
so reload? 
oh
you cant do it with browser
rip 😐
you need a running desktop client
i have the app tho 😳
then run it?
ok
do i close the browser
ayy pog it worked
when i press the button it doesn't do anything 😳
you cant click your own buttons
oh does it work for you?
yes, they work
k good 😳
You probably want to log in with test user in canary to test stuff like this
If you need two users to both have a presence you can modify rpc source code to connect to ID 1 client
nvm
will it be considered as API Abuse if i use discord.js and discord-rpc to make something which can change the text in your RPC using bot commands? like
!setuppertext this is pog
idk how that would work tho, isn't oauth whitelisted, or is it only whitelisted on browser?
Like, if a user needs to download an app to set their custom status, that app could have UI to do that, not everything needs to be a command
Ok
it's not for users
like only for me
and open source on github if people wanna set it up for themselves
sure, you could do that
ty
In client.js, _onRpcMessage(message) https://github.com/discordjs/RPC/blob/master/src/client.js#L194
const subid = subKey(message.evt, message.args);
if (!this._subscriptions.has(subid)) {
return;
}
this._subscriptions.get(subid)(message.data);```
Isn't it a mistake ? Rpc events seems to send back args in "data" field, therefore "args" field is always undefined and RPC subscription doesn't work
im trying to use rpc and i have this code:
const DiscordRPC = require('discord-rpc')
const clientId = '378317078219849759';
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
async function setActivity() {
if (!rpc) {
return;
}
rpc.setActivity({
details: 'Konatz bot,',
state: 'is the best bot.',
largeImageKey: 'snek_small',
largeImageText: 'BOII',
buttons: [{ label: 'Invite Me!', url: 'https://discord.com/oauth2/authorize?client_id=787531329587118100&permissions=8&scope=bot'}, { label: 'Join my test server!', url: '<INVITE>'}],
instance: false,
});
}
rpc.on('ready', () => {
setActivity();
client.log('success', 'RPC', 'CONNECTED!')
// activity can only be set every 15 seconds
setInterval(() => {
setActivity();
}, 15e3);
});
rpc.login({ clientId }).catch(e => { console.log('error', 'RPC_ERR', e) });
but i keep getting this error:
error RPC_ERR Error: connection closed
at IPCTransport.<anonymous> (/Users/admin/Desktop/konatz bot/node_modules/discord-rpc/src/client.js:118:16)
at Object.onceWrapper (events.js:422:26)
at IPCTransport.emit (events.js:315:20)
at /Users/admin/Desktop/konatz bot/node_modules/discord-rpc/src/transports/ipc.js:137:18
at decode (/Users/admin/Desktop/konatz bot/node_modules/discord-rpc/src/transports/ipc.js:92:5)
at Socket.<anonymous> (/Users/admin/Desktop/konatz bot/node_modules/discord-rpc/src/transports/ipc.js:120:7)
at Socket.emit (events.js:315:20)
at emitReadable_ (_stream_readable.js:569:12)
at processTicksAndRejections (internal/process/task_queues.js:79:21)
i guess it's about your login, that you didn't called clientId something like this:
{clientId: ''}
how do u propose i do it?
becuz i already defined clientID and i used it
you're supposed to pass the id of an application, not your user id
?
clientId is currently your user id
it should be an application id though
like my bot id?
sure
you can see client id on your discord application page
you can also create a new application for rpc
oh it worked
but
my buttons arent working now
did you install it from npm or github?
discord-rpc?
yes
i did this in terminal
npm i discord-rpc
ah, the npm version doesnt support buttons yet
oof
how do i do the github one
you need to do npm i discordjs/rpc, requires git to be installed
do i do npm i git to ghet git?
do i also need git-gui?
don't think so
k
i ran the brew install git
and it says updating homebrew
now its downloading
that should be fine
k
done
ill run npm i discordjs/rpc
@karmic jolt thx so much it works now
var RPC = require('discord-rpc')
const client = new RPC.Client({ transport: 'ipc' })
client.on('ready', () => {
client.request('SET_ACTIVITY', {
pid: process.pid,
activity: {
assets: {
},
buttons: [
{ label: 'GangRP Discord Server', url: 'https://discord.gg/nuUygHnns2' }
]
}
})
console.log('Started')
})
client.login({clientId: '799807572752072724'}).catch(console.error)```
buttont don't to somthing
I've noticed that the custom RPC buttons don't seem to open their set URLs when you are clicking on your own ones, but clicking on other User's RPC buttons works just fine.... 🤔
that is true
you cannot click on your own rpc buttons
idky why
in your rpc i can
@sacred ore
ik
but
you arent able to click ur own buttons
it wont open anything
have no idea why discord would do that but whatever
@sacred ore
buttons: [{ label: 'Invite Plexi', url: 'URL'}, { label: 'Join Discord', url: 'INVITE'}],
this is what i have
it still dosent work tho
lemme see full code
Does it log an error
nope
hold on
btw, urls cant be more than 32 chars
that might be an error
discord oauth invites are always more than that
its a bit messy rn but it works
const DiscordRPC = require('discord-rpc')
const clientId = 'INSERT CLIENT ID HERE';
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const client = new DiscordRPC.Client({ transport: 'ipc' });
async function setActivity() {
if (!rpc) {
return;
}
rpc.setActivity({
details: 'Support Small',
state: 'Bot Developers!',
largeImageKey: 'plexi',
largeImageText: 'Plexi | Discord Bot',
buttons: [{ label: 'Invite Plexi', url: 'INVITE URL'}, { label: 'Join Discord', url: 'ALSO URL'}],
instance: false,
});
}
rpc.on('ready', () => {
setActivity();
console.log("working!")
setInterval(() => {
setActivity();
}, 15e3);
});
rpc.login({ clientId }).catch(e => { console.log('error', 'RPC_ERR', e) });```
why is there two clients?
no ur issue
just weird
idk i took this from someone
also, how long is the bot invite
imma change it, but
its from me
its a short url on my domain
hm weird
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
async function setActivity() {
if (!rpc) {
return;
}
rpc.setActivity({
details: 'I am a fairly new bot,',
state: 'but ill do.',
largeImageKey: 'snek_small',
largeImageText: 'BOII',
buttons: [{ label: 'Invite Me!', url: 'https://synyster.page.link/Eit5'}, { label: 'Join my server!', url: 'http://gg.synyster.org'}],
instance: false,
});
}
rpc.on('ready', () => {
setActivity();
client.log('success', 'RPC', 'CONNECTED!')
// activity can only be set every 15 seconds
setInterval(() => {
setActivity();
}, 15e3);
});
rpc.login({ clientId }).catch(e => { client.log('error', 'RPC_ERR', e) });```
this is the code u stole
yeah
which in turn is basically just the example with tweaks
it might be because of my internet connection rn
no
im currently on a 50kbps connection
did you install discord-rpc from npm or github
github
u sure?
yes lmfao
rpc master should have buttons so idk
can you npm ls discord-rpc then, should also give the commit hash
i thought i installed the github version
but u didnt
i guess not, lets try again

discordjs/RPC#cbdd31f98b20de0222a793ae0b14018f8119cfb2 heres my commit hash btw
this one is confirmed working so
loggers, i figured it out
Does the main branch support buttons?
probably
Personally i like to use the discord-rich-presence module for ease
even tho ur talking the discord-rpc chat
what
you know that discord-rich-presence is a simple wrapper for discord-rpc, made by same person?
ohs hit really, wow im dumb
wait, why would it need a wrapper already
as opposed to
so its just qol
got it
where can i start learning rpc
what exactly u need to know
would rpc only work on browser or can it even work on the desktop?
other way around, only works on desktop
i use desktop but i keep getting an err of Could not connect
show code
const clientId = '';
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 });
just the one from the example really, just tryna mess with it
remove scopes
even const scopes = ['rpc', 'rpc.api', 'messages.read']; ?
yes
remove it from both login and the const
and also
client id is the one from the application right?
use ipc instead of websocket
and yes
do i need to do anything specific there?
just make an application i need the clientid correct?
the clients application id
const client = new RPC.Client({ transport: 'ipc' });
did that
alright
and do you have the clients id in there
(node:3556) UnhandledPromiseRejectionWarning: Error: Could not connect
show current code
const RPC = require("discord-rpc");
const clientId = ';
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 });
full code, including the client id
const RPC = require("discord-rpc");
const clientId = '736309841378672641';
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 });
and this is on the same computer as discord right, not on a vps or somethingother
yeah i have discord on my desktop and im running the code on glitch cause im just testing
wont work on glitch
has to be ran on ur computer
ohhh
ye
wait so i would need to install
node etc?
if its not installed alr on ur pc
then yes
u cant just run this via plain vsc correct?
yes u can
wait how
terminal
node .
lol
1s lemme open it rq
sorry i dont use alot stuff in terminal xd
'node' is not recognized as an internal or external command, operable program or batch file. yeah i need to get node cuz i dont run cmds on terminal
i just have all my stuff on a vps
yea just search up node.js and get the bin for windows
LTS or current?
current
wait no
lts has the updates
too
so just get lts
alr
14.15.4
yee thats fine
well i installed node
when i use node . i get an err which i dont quite get
although i did do npm install discord-rpc and it worked and its installed
lemm see the err
Error: Cannot find module' and then it just says the location of where i opened my workspace
do i need to run something in the node cmd prompt?
let me see the directory
wait node and the vsc file location arent in the same area, how do i change where my node packages install? from like the node cmd prompt
node packages should install to project dir
is the terminal not in ur project dir ?
no like if i open terminal in vsc and run npm install discord-rpc
it installs that to my workspace area but
if i do the same thing in the node command prompt
it installs it somewhere else
so how do i change the node command prompt download area
because npm installs to the current directory lol
send a ss of project dir
1s
wait so what do u want me to send again?
project dir
the directory with your rpc index file
ah 1s
this?
you dont have a package.json
run npm init
yeah i realised
made it
did it work?
how would i run it
node .