#archive-rpc-help
21942 messages · Page 11 of 22
How do I add image to this RPC?
{name: `Hobbe hotel, the best <3`, type: 1, url:"link"},
?pastebin
I'm trying to get discord rich presence setup and working but I'm running into the issue of it not being able to connect apparently. The documents page practically has nothing to really read unfortunately, same with the NPMJS page and its github :/
var rpc = require("discord-rpc");
var vaas_rpc = new rpc.Client({transport:"ipc"});
var clientId = "BOT CLIENT ID HERE";
vaas_rpc.on("ready",function(){
vaas_rpc.setActivity({
details: "Place Holder Details",
state: "Currently Beta Mode",
largeImageKey: 'Place Holder Image set in discord dev page',
largeImageText: 'Place Holder Text',
startTimestamp: new Date()
}).catch((reason) => console.error(reason));
});
vaas_rpc.login(clientId).catch((reason) => console.error(reason));```
@smoky scroll
- You may pass an object in login method
- Apparently adding your clientToken helps
vaas_rpc.login({clientId, clientToken})
Still unable to connect for me
Humm 🤔
What is your error message ?
Oh I'm sorry but I can't help on this one
🤔
Yeah can't figure out
Maybe someone else has a solution ?
check out discord-rpc package: https://www.npmjs.com/package/discord-rpc
documentation can be found here: https://discord.js.org/#/docs/rpc
(not possible for bots)
This is not possible for bots
Is there any way to make it like the Discord GameSDK where it doesn't show rich presence but it shows you are playing a game (with the icon)
Like this
wat
Icon this way is only there because discord has one
how can i wait the end of the function before sending the message ?
ouai mais moi je veux pas un temps donné je veux des que l'action est fini et je pense que c'est faisable via de l'async
ahh oui j'avoue
je testerai demain ^^
I am getting an error No Client ID Specified?
const DiscordRPC = require('discord-rpc');
const clientId = "the client id";
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
rpc.login(clientId).catch(console.error);
rpc.on('ready', () => {
rpc.setActivity({
details: "Playing Main Lobby",
state: "test",
startTimestamp: new Date(),
largeImageKey: "ct_logo",
largeImageText: "ChatTriggers",
smallImageKey: "hypixel",
smallImageText: "Main Lobby",
instance: true,
});
});```
You need to edit "the client id" with your client id
In Line 2
@strong chasm
Lol I know... It won't work..
And did you Change?
But never mind I got something else working.
Wdym did I change?
Wdym?
What is djs-rpc for?
@minor willow Discord - RichPrefrence
Presence, not preference
The RPC works with bots?
no
read the pins
does setting rich presence's activity require any auth when using websocket transport ?
@smoky scroll changing it every 3s might be considered API Abuse
also for your main Question: This does not seem to be a libary question but rather how to use basic node.js wich is not the scope of this guild
yeah, I'll change it to a higher number
thx
@solemn shell you cannot use websocket unless xou are in the private rpc beta
what
that is not true
Why would I be getting RPC_CONNECTION_TIMEOUT? My app has access to the internet and is not blocked by my firewall.
Note to everyone using Node.js then. First link is broken, use the second link instead. They both seem to give RPC_CONNECTION_TIMEOUT, but the non-wrapper version actually works.
https://www.npmjs.com/package/discord-rich-presence
https://discord.js.org/#/docs/rpc/master/general/welcome
aren't those 2 separate things
One is a wrapper. It says it in the documentation.
Actually it says it in the embed.
yeah...
is there any way to run rpc on glitch ?
with token of user
No
wait since when get commits & etc redirected to here?
there's been a webhook for the rpc repo for a long time
Is it possible to change your rpc while using a bot?
Example: You'll click on 🦈 and then your rpc is "fishing some sharks" then you'll click on 📖 an then you rpc is "Working for math" or sonething like that
rpc is for games, so you could develop a "game" that does that for you
UnhandledPromiseRejectionWarning: Error: OAuth2 Error: invalid_request: Missing "redirect_uri" in request.
import * as RPC from "discord-rpc";
const clientId = "619611548532342795";
const scopes = ["rpc", "rpc.api"];
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.setActivity({
startTimestamp: Date.now()
});
});
// Log in to RPC with client id
client.login({ clientId, scopes });
``` TS just for knowing what to do
Hi
Error: Could not connect
problem ?
@hidden linden try remove the scopes variable
Can I use this on myself? Or would that be a selfbot
rpc is meant for people, it's what allows you to do stuff like with the vsc extension or detailed game data
what is rpc?
Rich Presence
is it possible to read and/or write messages with rpc? if so, how?
no
it is
adding messages.read to scopes gives pretty
however, rpc.api gives that
@old fable
o_o
imagine clicking authorize without reading
xD
Is it possible to set the PLAYING A GAME from rpc to something like Listening... Watching...
Only bots and official presences (like spotify) can do that
Ah okay... Guess this will be. Thanks 😄
what is rpc though
hopefully for the last time, its rich presence
what is rpc though /s
is there any built in application for discord rich presence by discord.js
what do you mean?
I am looking for executable program write by node js to change discord rich presence
If it not exist I my try to write once
i dont understand
?npm discord-rpc
Not package one
The program
what program?
Program to change rich presence
https://github.com/Pizzabelly/EasyRP Like this one
But In JS
u can just make it but there is probably
i used one
yes
That reason why I looking for it
If it is maybe we can maintain it
It not it okies
We can start from scratch
@hidden linden
is it possible to use an Input() type thing for rich presence?
@lusty depot?
@smoky scroll false, if you set the type In the gateway
Via websocket
Uh what
You said you can’t set listening, or whatever, In the rich presence type when connected to the gateway you can change it
Cool but, I think not native with this libary 🤔
Yea I know, it’s a manual thing
Hey, i do'nt know why i got "empty item" when it's actually a real number
even if i replace tempviews[8] with "p" i have the same result
Well it worked with i+=1 instead of i++
Does djs-rpc come in a webpack?
i dont think so
it wouldnt be possible, probably
mainly because it uses ipc to connect with discord through your pc's internals
at least thats how i think it works, right?
But normal presence is possible with webpack?
yes
It works differently I take it?
yeah
looks like a web pack config to me
Is there a way to set the input of your RP when you login in? (Example: Input() )
You type in console and it sets a status
is it possible to change the application name (or the text that appears after Playing:) without doing it manually?
Create a new "bot"
@old fable whats that browser?
um. google chrome on ios?
oh, I've always used Safari so
how to get app image when we got app client ID
Also for application name
I want to get assets app image that uploaded to app client
what is accessToken supposed to be? this is in RPCClient.login(), client.js:134
@unborn stream I think that should be your access token
no shit sherlock
whats my access token
ok i got an access token, is it possible to send a message to a channel?
what can i put into the evt parameter of RPCClient.subscribe()?
thank you
How to fix this
define RPC
is it possible to do something like RPCClient.application.setName()or otherwise change the application name?
No
RPCClient#application is a readonly
@subtle comet how to define it
Cause const RPC = require('discord-rpc') not working
use node.js
@unborn stream What do you mean
I am using node Js
Electron to build application
okay whats the error
As the screen shoot
if you do const RPC = require('discord-rpc') then RPC is something else than undefined
it not working so I remove
It error when using const RPC = require('discord-rpc')
it says electron not found...
Electron run normal
If not using dícord-rpc
so far it looks like you're trying to call rpc from the ui process of electron not the node process
^enable node integration in main process or do rpc stuff in main process
I am call in it in main process of electron
Of course I know discord.js should run from B.E
Not F.E BTW
do you see any discord rich presence modules for javascript on npm?
?npm discord-rpc
install git
how can i make that? @left fjord
you use google
type literally how to install git
follow one of 7123965482937456 available guides
i did rpcclient.subscribe('MESSAGE_CREATE', { channel_id: <string>, }, callback) but the callback function didnt execute when i sent a message to that channeö, what did i do wrong or has devsnek done something wrong
did you request messages.read?
probably not
How can make, that the bot send a message at for example 3pm
i dont think you can send messages with rpc
ok i added messages.read to the scopes it still doesnt work
@GitHub#0000
@GitHub#0000
why are yall trying to tag a webhook
I have added the rpc to my electron app for rich presence.
but invites cause this error:
tutorials for djs rpc?
read the topic
[stdin]:2
message.split("--")
^
ReferenceError: message is not defined
at [stdin]:2:1
at Script.runInThisContext (vm.js:126:20)
at Object.runInThisContext (vm.js:316:38)
at Object.<anonymous> ([stdin]-wrapper:9:26)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at evalScript (internal/process/execution.js:80:25)
at internal/main/eval_stdin.js:29:5
at Socket.<anonymous> (internal/process/execution.js:192:5)
at Socket.emit (events.js:214:15)
at endReadableNT (_stream_readable.js:1178:12)
Wrong channel
I'm sorry
i have a strange issue, when i use the 'websocket' transport when i try and log in it gives me an undefined error
like it literally only says undefined:
code? @past anvil
can anyone help me install this on Linux Mint 19.2? Keep getting this error https://pastebin.com/VHHqBX2X
42 verbose stack Error: Refusing to install discord-rpc as a dependency of itself
TL;DR: looks like you tried to name your project discord-rpc, and you can't install a module of the same name in it.
why
they didn't bother to even paste that line to google, why give answer like that
isnt the rpc deprecated in favor of discord gamesdk
The SDK that this documentation references, Discord-RPC, has been deprecated in favor of our new Discord GameSDK. Replacement functionality for the Rich Presence SDK can be found in the Activity Manager of that SDK. This documentation can be referenced for education but does not entirely reflect the new SDK.
RPC SDK !== RPC
oh heck im baby
Theres a program that uses discord-rpc and a lot of people are getting unexpected token errors where it says ... (the code has that in multiple places), what causes that? It's in the discord-rpc module and it wasnt happening before
@arctic eagle
const discordRPC = require("discord-rpc");
const clientId = "blah";
const clientSecret = "blah"
const scopes = ['rpc', 'rpc.api', 'messages.read'];
discordRPC.register(clientId);
const client = new discordRPC.Client({ transport: 'websocket' });
client.on('ready', () => {
//setActivity();
console.log("hello");
console.log('Logged in as', client.application.name);
console.log('Authed for user', client.user.username);
});
client.login({ clientId, clientSecret, scopes }).catch(console.error);
if i replace 'websocket' with 'ipc' it works fine
Don't include your client secret. It is of no use in websocket connections. Also, including it disallows use of the messages.read scope. Sources: https://discordapp.com/developers/docs/topics/rpc#authorize and https://discordapp.com/developers/docs/topics/rpc#connecting
Only plausible use of client_secret in RPC:
"We also have an RPC token system to bypass the user authorization modal. This is usable by approved games as well as by users on a game's whitelist, and also disallows use of the messages.read scope. If you have been granted access, you can send a POST request to https://discordapp.com/api/oauth2/token/rpc with your application's client_id and client_secret..."```
Notice how the websocket url doesn't include a secret:
"For WebSocket connections, the connection is always ws://127.0.0.1:PORT/?v=VERSION&client_id=CLIENT_ID&encoding=ENCODING"```
I think this may fix your problem @past anvil.
I'm not sure how much of that applies to what the discord.js-rpc lib actually does, though.
ah ok
thanks! i'll give it a go and get back to you
i used 'message.read' because on the npm page it had some sample code with it in the scopes:
https://www.npmjs.com/package/discord-rpc
const clientId = '187406016902594560';
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 });
@arctic eagle
still happening
What did you change?
I'd say it's a websocket error, but I don't really know. Have you tried restarting Discord?
this is the code now:
const discordRPC = require("discord-rpc");
const clientId = "blah";
const scopes = ['rpc', 'rpc.api'];
discordRPC.register(clientId);
const client = new discordRPC.Client({ transport: 'websocket' });
client.on('ready', () => {
//setActivity();
console.log("hello");
console.log('Logged in as', client.application.name);
console.log('Authed for user', client.user.username);
});
client.login({ clientId, scopes }).catch(console.error);
removed the client secret and the message.read scope
is the clientId "blah" or is it there just so we dont gotta se your clientId
its so you dont see my clientId
i use my actual Id when i run the code
client id isn't a secret
Where do i report bugs in the libary?
library*
Open up an issue on the github repo
@carmine mica i tried using the example on the docs and they dont seem to work
@past anvil it's unemployed?
unemployed?
doesn't work so it's unemployed
in other words: ok, great story, but have you considered actually giving anything more on that fact, or we are supposed to perform magic to know the errors
ok
i do still get the 'undefined' error which i cant fix
what is the undefined error
i dont know
it only says 'undefined'
@carmine mica
fascinating
yeah i have 0 idea what is happening
it works fine with ipc
websocket requires whitelisting
you have to use ipc
Ohhhhh
i read that in the docs somewhere but i assumed it applied to something else
that makes sense thanks!
i'll stick to ipc for now lol
>npm i discord-rich-presence
npm ERR! path git
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn git
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/discordjs/rpc.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\stepm\AppData\Roaming\npm-cache\_logs\2019-10-14T10_55_28_695Z-debug.log
debug.log: https://paste.ubuntu.com/p/Gxk8HQNWHp/
help 🙂
@crystal zodiac Install git, make sure adding it to PATH is enabled, reboot for a good measure.
thanks @lethal whale
anyone know how to fix Error: Could not connect at Socket.onerror (/rbd/pnpm-volume/2cfb3d7b-323c-413a-b975-30aca12c9aea/node_modules/.registry.npmjs.org/discord-rpc/3.1.0/node_modules/discord-rpc/src/transports/ipc.js:32:16) at Object.onceWrapper (events.js:277:13) at Socket.emit (events.js:189:13) at emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) at process._tickCallback (internal/process/next_tick.js:63:19)
nvm
Im having a issue with the rpc im getting
const client = new rpc.Client({ transport: 'websocket' }); ^ ReferenceError: rpc is not defined
You didn’t define it
oh
so basically like requiring discord.js bur rpc
if im right const RPC = require("discord-rpc")
@prisma sparrow
Names are case-sensitive
RPC and rpc are different
Is this channel also for https://github.com/devsnek/discord-rich-presence ?
it is in the topic
Ok
So
I am creating a rich prescense GUI
When I tried the discord-rich-prescence it worked fine when I entered every value manually
like the example on the repository
But now I use electron for creating the GUI and I get the rpc client id from an input box
and the i get this error
Here is my full code
Oof, No one that can help...
Now i get this
THis is da code
k no one is gonna help
now only this
sorry for offtopic Trizly what theme are you using on VSCode?
One Dark Pro
The theme from Atom
anyone know how to fix (node:11624) UnhandledPromiseRejectionWarning: undefined (node:11624) 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:11624) [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.
code:
const clientId = 'id';
const scopes = ['rpc', 'rpc.api', 'messages.read'];
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);
});
// Log in to RPC with client id
client.login({ clientId, scopes });```
yeah
you need a .catch() on client.login
but it still wont fix the issue, if you try it you will get only a message that says 'undefined'
websocket is whitelisted so you have to use the ipc transport
@glacial yew
@past anvil im just using easyrp rn
ah right
i gave up lol
the discord-rich-presence package works pretty well
and the discord-rpc package does actually work, but only with ipc
oh lol
so i would change scopes to ipc?
transport
oh
let me try that rn
but of you're only using it for a presence then i would recommend just using discord-rich-presence
yea only for a custom prescence
i learned how to do it in c++ and c#
this is for js
ik
var rpc = require("discord-rpc");
var bot = new rpc.Client({transport:"ipc"});
var config = {
clientId:"242276511028084738",
clientSecret:"not for you to see"
}
bot.on("ready",function(){
bot.setActivity({
details: "test",
state: "test",
largeImageKey: 'test',
largeImageText: 'test',
startTimestamp: new Date(),
smallImageKey: 'test',
smallImageText: 'test'
}).catch((reason)=>console.error(reason));
})
bot.login().catch((reason)=>console.error(reason))
Im new to RPC and im wondering what im doing wrong, can anyone help me out?
@small mortar you have to login with the clientId
you also don't need to login with your clientSecret for what you're doing
also for the .catch() you can just use .catch(console.error)
Is this the channel to ask for help with discord-rich-presence npm?
yeah
I can't get joinRequest to work
It doesn't even get called
does it break before then?
wdym break?
it doesnt get called
like does the code stop working before then?
no, everything stays working
are you getting an error message?
Not that I can see
can i see the code?
Which parts would you like to see?
all of it
how many lines is it?
all of it is 300+ lines
but i can gist it
sure
does line 209 work? @fathom lion
doesn't joinRequest need to work first for that to work tho?
i dont see any documentation on joinRequest
It's discord's documentation, isn't it?
you press "Ask to Join" in discord and the game then needs to accept the request or deny it
on discord's documentation or discord.js's documentation?
discord's?
oh
ACTIVITY_JOIN_REQUEST which rpc subscribes to which discord-rich-presence wraps as joinRequest
i've never seen it before
has anyone ever tried it?
There's an example here: https://github.com/devsnek/discord-rich-presence/blob/master/test.js#L13L19
I'm tempted to just ping devsnek...
but at the same time, discord is trying to deprecate rpc
tbh i've never seen that before
yeah, maybe somebody else can help me then
it might be whitelisted
but i dont know
Rich presence is whitelisted, but you can still test it with up to 50 people before asking to get whitelisted
ah ok
so if anyone else wants to take a crack at it, feel free to ping me here
I actually want to get it working without having to use some other browser renderer
whats rpc
small detail pls
also curious ;D
Component of local discord client responsible for communicating with other apps.
^
i use it to make a silly game activity
@past anvil returns "undefined"
@small mortar what transport are you using?
Is it possible to change my game activity using this library?
Yes.
ipc
can i see the code?
Someone here?
using ipc transport the disc client closes the connection just after the handshake with this error whereas the client ids are fine
- the ipc process is no longer described in the disc docs
fixed
its a bug within disc ptb
@tender cosmos here
Is there any plans to get gamesdk working in node?
The lobby information was changed and rpc can't do full rich presence anymore
what do you mean by "full rich presence"
"Ask to Join" functionality, chat invites to your lobby. People forget it exists but that's what I wanted to do
isn't that hidden behind beta for rpc?
It's not even a thing anymore as I know. As lobby information has changed in the new gamesdk
rpc is deprecated
RPC is not
RPC SDK is
🤔
those are 2 separate things
RPC is more like a protocol to do things in discord from outside of it
I get it is. Gamesdk had to communicate with discord somehow
yeah, via rpc most likely
events for RPC
commands
I thought while your app wasn't whitelisted you could still test it yourself
You can scroll up, but i didn't get the rpc to send joinRequest events to my app
(I'm too drunk to think clearly right now tho so I'm not even sure what I want to do instead. But I still want to get full rich presence to work in node)
Discord-RPC links to https://github.com/discordapp/discord-rpc, which links to https://www.npmjs.com/package/discord-rich-presence as a wrapper on the bottom of the readme
Yeah, and one of these doesn't have support for lobbies. And form what I was told in the gamesdk server it's because lobby information was changed
If you can also change it for the old rpc idk
i almost literally pasted code from rich presence visualizer into discord-rich-presence
And does the button really work? I also got it to display but clicking it didn't trigger anything
not like i can't click it or something
Yeah, you need another pc and another account. (and I think you also need to invite that other account to your app's whitelist but I'm not sure about that)
sadly, can't test rn, need to catch some sleep
Sure, if you are going to tho please tell me the results. If I could get a node only solution it would be great
@fathom lion all the activity events should be working
last i tested they were working
i don't know about lobbies though, i've never had a reason to use them so i don't test them
but they should work in theory
and rich presence is definitely working still
so many people use it
i'd get so many issues on the repo if it stopped working
Yeah, I had no problems with anything else rich presence related, but when I got another account to click my "Ask to Join" button nothing happened on my side.
Any starting guide for djs-rpc
depends what you wanna do
I want to make rich presence for activity only
@past anvil
like mine?
Ya
How I can set that RPC in my account ?
Any hint ?
yeah you run it on your computer
it starts a local server that connects to any discord accounts that are logged in
i would change the ID to your own discord application
Ok
Any way to use that with mobile ?
start it on your computer and it should show on all your clients
What is state and details ?
Last doubt
on my one state is 'being lit' and details is 'They're all so cute!'
Ok
Thank you
np
@fathom lion ask to join also requires registering your game with discord locally
this usually happens automatically if its installed through the game store
if not, you have to use DiscordRPC.register()
So wait, there's no way to test it before applying for whitelist?
you can use DiscordPRC.register
but that requires running the game at least once
running the game at least once
meaning anyone could use it after running it once?
running the game once on each machine
ask to join requires that discord know how to launch the game
assuming your ask is granted
yeah, but what if the games are already running
🤷🏻
Ask to Join didn't work for me even when the games where already running
i haven't experimented too much with edge cases
my game is also installed through the discord store so
🤷🏻
discord doesn't have a store anymore tho
store channels
if you want you can try running a few instances of this manually https://github.com/devsnek/boop-teh-snek
setting up the websocket server and such
discord-rich-presence npm doesn't call register on its own? and there really isn't any way to access the rpc from there
hmmm
you could pr a thing
register method
if you edit a local node module, does it get used when you run npm start ?
¯_(ツ)_/¯
its not a complex module though https://github.com/devsnek/discord-rich-presence/blob/master/index.js
i don't even need to, I can just require rpc and just call the register method, it's exported by rpc package
hmmmm... I'm running the same .exe on both PCs
¯_(ツ)_/¯
I think I got gamesdk working in node with edge.js
There's one thing that got me thinking. Does the party id need to be filled in to use Ask to Join and chat invites? Because the button appears when you have join secret filled in, but it might no work without party id
Because that is one thing for sure that I changed when I implemented gameSDK instead.
is there a way to set up rpc on my bot that uses discord.js?
no
Is there a way to make RPC on an website?
*a website
no, but you can make one in the main process of an electron application
х
i want to update my rich presence by that code. But it doesn't work. Am i stupid or smth?
// content.js
var ws = new WebSocket("ws://localhost:6463/?v=1&client_id=605777168739598338");
function isOpen() { return ws.readyState === ws.OPEN }
function updatePresence(title, time, icon) {
title = title.replace(/["]/g, "\\\"");
var data = JSON.stringify(
{
cmd: "SET_ACTIVITY",
args: {
pid: 9999,
activity: {
details: title
}
},
nonce: Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1)
}
);
if (!isOpen()) return;
ws.send(data);
}
{
"manifest_version": 2,
"name": "Tomori Player",
"version": "0.1.0",
"browser_action": {
"default_icon": "icon.png"
},
"permissions": [
"ws://localhost:6463/*",
"tabs",
"webRequest",
"webRequestBlocking"
],
"content_scripts": [
{
"matches": [
"https://www.youtube.com/watch*",
"https://youtube.com/watch*"
],
"js": ["content.js"]
}
]
}
i'm working on chrome extension
or how do i import and use discord-rpc in chrome extension?
how is this rpc related?
@half zephyr It won't work, Discord will disconnect almost immediately if you connect with a browser, trust me i tried. You will need to have an application running in the background
@plucky cargo oooooof, thank you
What do you want to create a Rich Presence for btw?
parse current playing video from yt or song from soundcloud or etc and send it's title to rpc
Welp, you can take a look at my project PreMiD, it does the exact thing with 260+ websites
First try was a python script which uses chromedriver to open new chrome window and parse html page from it
https://github.com/TomoriBot/Tomori-Player
wow, you're owner of premid?
yep
I saw it but didnt use yet
Give it a try then :P I can dm you the link
hey, is it possible to login to an account using discord.js and set the rich presence?
no
i can't install discord-rich-presence module
help
ping me when you know issue
Error I get
do you have git
Most likely not as its failing to spawn git
how to work on rpc
plz teach
?rpc
https://npmjs.org/discord-rpc #djs-rpc
@gleaming sleet not that what to do after that
what are you wanting to do?
after opening this site
what should i do next
what do you want to achieve?
i want u to tell me the step to create rpc
why do you want to know RPC
as i want to add my custom rpc in my profile
have you done any coding before?
nope
i suggest you start with a basic javascript tutorial then
it's unlikely you'll find people here who'll write the code for you
how to learn that !!
google javascript tutorial
@gleaming sleet i have learn little bit not the discord.js
nice try 😉
@gleaming sleet so how should i learn discord.js
sry for ping
plenty of docs here:
?guide
The official discord.js guide, maintained by its core users https://discordjs.guide/
they're quite useful and will tell you how to set things up
i have used this
and just got upto basic cmds
great show me your code!
but not with the
ok, go check out this: https://discord.js.org/#/docs/rpc/master/general/welcome
@gleaming sleet using this i am not able to where to set this command
what do you mean ?
leave it
what you're trying to do will not require a command.. probably
can u help me with
embed in my bot
check out ?embed
like I say, we wont write your code for you
actually, I should qualify, some might if they're being super generous or you offer to pay a reasonable amount
however if you have a specific problem we'd be happy to help
@gleaming sleet
`y this error
on glitch
where have you defined RPC?
how to define rpc
import it from the npm package
@gleaming sleet after that same
prblm
show your code
it is saying not defined
i installed discord rpc package
yeah, you have to import it
can i talk to u
const ... = require(); for example (with an actual constant name and actual package)
later i need to sleep right now
i havn't slept last night
i have a similar problem at times, on those days I don't think straight. Good luck
does anyone know a good npm package for gamesdk?
?npm gamesdk
@gleaming sleet, Yukikaze couldn't find the requested information. Maybe look for something that actually exists the next time!
isn't discord.js RPC deprecated?
the basic functionality works
i dont know about reading / sending messages, havent got it to work
Someone for God's sake, who knows or has a folder with the basic commands to start the bot ready comes deprived for God's sake help
Tf stop Spaming @smoky scroll
okay help bor plis I'm from Brazil
what does your nationality have to do with anything?
@dusty sundial why would it be
oh is that discord's rpc which got deprecated?
what are you talking about
@dusty sundial this lib isn't deprecated
discord had an sdk that is now deprecated
this lib implements some of the game sdk. it currently doesn't have some of the more advanced features like networking
What is dsj rpc?
?rpc
https://npmjs.org/discord-rpc #djs-rpc
Rich presents ?
And would that do to help my bot?
bots cannot use rpc
Soo whats the point then?
this is rpc
For players?
*users
you can use the lib to make your own rpc
Oh ye right
Huh sounds use full
To fetch butter
Can anybody give me an example of rpc presence code?
th
I got error in the above example
at the client side
require is not defined
mainWindow = new BrowserWindow({
width: 340,
height: 380,
resizable: false,
titleBarStyle: 'hidden',
webPreferences: {
nodeIntegration: true
},
});
nodeIntegration: true must be set ^
it isnt in that example
maybe back then that option was not required to be set
now having problems with webFrame
It says that webFrame.setZoomLevelLimits is not a function
Even I tried in dev console, its not even defined
this is not rpc related
But it's an error in the example
How get the 512 size of a pic
i am having issues with that
how to compress the size of an image
open it in an image editor?
easy
photoshop
are easyiest
and the best
that's not rpc related
give batter quality
i want to update the largeImage live
I'm trying to recreate the spotify rich presence for youtube music
Where when you switch songs it updates the image to the thumbnail of the song cover image
Is it possible to do that?
Right now I just have to use a pre-uploaded key for the Youtube Music icon
mind that spotify is not really regular rpc in that context.
for example
first one is osu (literally those assets: https://canary.discordapp.com/channels/222078108977594368/379350641761320982/644820156664512512), second one is spotify
you can access former ones with https://cdn.discordapp.com/app-assets/367827983903490050/373344233077211136.png or https://cdn.discordapp.com/app-assets/367827983903490050/373370493127884800.png, which point directly to discord's asset serving, while for spotify, for the song from screen above, album icon url is https://i.scdn.co/image/ab67616d0000b27383d842830ec48ac9238f12dd
and while you can indeed replace spotify: with https://i.scdn.co/image/ and get full image link, it means that it doesn't use discord's assets, but external ones
so you can't really achieve this?
because as far as I'm aware you can't use external assets like spotify does
if you can't pass url as image, not really, no
if you can't pass url as image
wdym by this
litreally what i said
how do you set image from your assets
/filename.jpg or whatever
you pass local file?
yeah
it saves the current song thumbnail as a file in my local directory
so i just point it to that
can you pass a url to the largeImage field?
have you tried putting url instead?
Yes it didn't work
Just blank
that's your answer i guess
F
Hello! Is there any way to use new statuses for bot rpc?
i think i've heard that discord is working on it
Nevermind, found that bots cannot use them right now anyway
?cs
Can I set a custom status for my bot?
- No. (discord is looking into it ™) https://github.com/discordapp/discord-api-docs/issues/1160
Can I read other users custom status?
There can be multiple activities now, a feature which the library does not yet include.
For now you can read the status via the GuildMembers presence if there is no other activity (think games, spotify):
[v12] #master: member.presence.activity
[v11] #stable: member.presence.game
The emoji used in the status is not yet readable.
How can I add RPC to my bot? I copied the example code, but it doesn't work -- the RPC just doesn't show up. Here's my code:
'use strict';
const Discord = require('discord.js');
const DiscordRPC = require('discord-rpc');
const client = new Discord.Client();
client.login(token);
client.on('ready', () => {
const clientId = client.user.id;
DiscordRPC.register(clientId);
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const startTimestamp = new Date();
rpc.login({ clientId, clientSecret: token })
.then(() => console.log('logged in!'))
.catch(console.error);
async function setActivity() {
if (!rpc) return;
rpc.setActivity({
details: 'booped 1 times',
state: 'in slither party',
startTimestamp,
instance: false
});
}
rpc.on('ready', () => {
setActivity();
setInterval(() => {
setActivity();
}, 15e3);
});
});
bots cant have rpc
const DiscordRPC = require("discord-rpc");
const clientId = "i_removed_the_client_id_from_this_message";
DiscordRPC.register(clientId);
const rpc = new DiscordRPC.Client({
transport: "ipc"
});
rpc.login({
clientId
}).catch((e) => {
console.error("Error logging in:", e);
});
Error logging in: Error: RPC_CONNECTION_TIMEOUT
at Timeout._onTimeout (C:\Users\Name\Documents\GitHub\Project-Name\node_modules\discord-rpc\src\client.js:99:47)
at listOnTimeout (internal/timers.js:535:17)
at processTimers (internal/timers.js:479:7)
Running on Windows 10 64x. Discord Stable is open on the same machine. I'm using the same elevation as the Discord client. I've tried both admin and user elevations. Other things that use RPC such as PreMiD work perfectly fine. I've tried downgrading the module. I'm using discord-rpc@3.1.0.
What are all the values I can pass to RPC.setActivity();?
rpc.setActivity({
details: `booped ${boops} times`,
state: 'in slither party',
startTimestamp,
largeImageKey: 'snek_large',
largeImageText: 'tea is delicious',
smallImageKey: 'snek_small',
smallImageText: 'i am my own pillows',
instance: false,
});```
Anything else,?
idk theres some start time and end time stuff, refer to discord's documentation for a more precise answer
or discord-rpc source code
or discord-rpc's incomplete docs
how would I check if any of the values in an array are a substring of another string
?cs
Can I set a custom status for my bot?
- No. (discord is looking into it ™) https://github.com/discordapp/discord-api-docs/issues/1160
Can I read other users custom status?
There can be multiple activities now, a feature which the library does not yet include.
For now you can read the status via the GuildMembers presence if there is no other activity (think games, spotify):
[v12] #master: member.presence.activity
[v11] #stable: member.presence.game
The emoji used in the status is not yet readable.
What's discord js rpc
discord rich presence
A ok
What causes this to happend?
(node:10560) UnhandledPromiseRejectionWarning: Error: RPC_CONNECTION_TIMEOUT
can we see your code?
n o
?
If you expect us to help you with your code, when we don't know whats wrong (e.g. you didnt share code), then share some code, or at least an error with us. If you refuse to share your code, then theres nothing we can really do, and dont expect us to be able to help
If you expect us to help you with your code, when we don't know whats wrong (e.g. you didnt share code), then share some code, or at least an error with us. If you refuse to share your code, then theres nothing we can really do, and dont expect us to be able to help
?
?
?
stop please
I'm testing that command tho
there is no command, only necro posting to old "question"
OK
this channel isn't for canvas
Is there a channel for it?
no separate one, you would need to use #archive-other-js-questions
Thanks
What is rpc?
nvm
im an idiot
(rich presence)
Looks like noone need help w rpc :p
What is this exactly for? I'm still not sure after looking at example
create an application on discordapp.com and go into the rich presence section
RPCClient only has the 'ready' event? I couldn't find anything in the docs
also what is a transport from RPCClientOptions?
events: https://discordapp.com/developers/docs/topics/rpc#commands-and-events-rpc-events
you need to subsribe to events in order to receive them, https://discordapp.com/developers/docs/topics/rpc#subscribe.
transport is way which app takes to communicate with discord client, that's "somewhat explained" in last 3 paragraphs here: https://discordapp.com/developers/docs/topics/rpc#connecting
thx
Is that working?
@karmic jolt i can do canvas
What is rpc
read the channel topic?
It says rich presence in only one of the link afaik. But what does that do? Setting rich presence?
this is a rich presence
for users, not bots
Yea ik, that's why I used whether it is used to set the rich presence
i thought you asked how to set rich presence
I'm trying to understand how this module works. As far as I'm aware, Discord.js is meant to build a Discord bot, but this module is meant to let users set their Rich Presence for games/applications that don't have it built in already? Does this use the local Discord client, or is it technically a self-botting function?
do you even have to have the local desktop client for Discord open for this to post your game status?
yes this module is used to set rich presence
uses local client, no self botting, discord allows usage of rich presence
yes you need to have discord open
@frosty forge
thanks. Is there perhaps a guide to getting started with it? Is it possible for this module to manage multiple games, or do I need a separate script for each game I want to manage?
you can check channel description for examples and help
separate script (and discord application) for each game
I don't mean at the same time, but rather, if I was playing one game and quit and start another game, do I need to terminate the script and start a new one for the new game?
yes
but in a production environment each game would have their own script embedded into the source code which would be automatically terminated upon closing the game
yeah.... I don't have control of the source code of the game... It's mainly for things like commercial games that don't have a Rich Presence yet, but where an external program might be able to extract enough information to fabricate one and post it instead.
i see
it would be for personal use only, so I'm not worried about it being distributable.
in that case you would need to terminate the running script
would it be possible to do client.destroy() and then login with a new clientID?
yes
I'd like to see if I can make a passive Node.js script that runs at boot and list listens for the games I've decided to support and will automatically create the appropriate Rich Presence to match it.
sounds good
I wonder if it might be possible to call new RPC.Client() on different variables to establish parallel clients, instead of destroying and creating over and over?
const client2 = new RPC.Client({ transport: 'websocket' });```
totally possible
that might be useful since I have a multi-monitor setup and might actually end up having multiple games open at once.
discord can only display 1 rich presence at a time
yes, and I think it shows whichever is the most recently updated. I'm just anticipating what might happen if I try to open two games at once. I don't want the script to break because it doesn't know how to handle two games. If Discord can only show one at a time, that's fine, but I want to make sure my script doesn't go crazy if I decide to multitask...
ok
does this support other modes like "watching" or "listening to", or is it only "playing"? Might be fun to have it hook into Netflix or my music player or something.
only playing
is that a limitation of the module, or the API itself doesn't support it yet? I'm curious how apps like Spotify can display music.
api limitation
I guess Discord gave Spotify special treatment with a closed API or something.
yes
I'm guessing it's the same thing with the Game Launcher on Samsung devices. Currently the only way I'm aware of to show what you're playing on mobile.
im not familiar with that
if you look at my presence right now, you'll see it
i cant see it, i’ll now go to sleep
oh... well thanks for the help either way
youre welcome
@frosty forge
client.user.setActivity('whatever it's doing', { type: "<type of activity here>" })
There are 4 types of activity.
LISTENING
PLAYING
STREAMING
WATCHING
@winged notch we were talking about rpc, this channel is for rpc, what the hell are you doing
@unborn stream Sorry, my bad.
How to use rpc?
check channel desc for guides
Does anyone know how to make a custom rich presence for TruckesMP/Euro truck sim 2?
I don't think that's what this channel is for
Does Android support Rich Presence through the browser?
not a lib question
You could at least answer the question while you're here instead of responding with "not a lib question"
i dont know the answer
Ask in discord.gg/discord-api
hi, not sure if this is the good channel, but i was wondering why i can't see any webscoket connection with discord by using a man in the middle proxy like charles, fiddler or mitmproxy? I can see it when using the discord app but not with discordjs/discord.net and discordpy
A
Are the docs down or something, I can't access them
for rpc specifically?
looks fine
TypeError: Failed to fetch``` when I click the first link in this channel's desc
djs library works fine though
I think something's wrong with the serviceworker on my client
Only hardrefreshing shows the page for me
dirty da
Hello! Does anyone use discord-rich-presence here? If so, is the API outdated, or am I doing it wrong? I'm running it at the ready-to-show event of my electron app, but it isnt working
I have my proper ID in, and im just using the example on it for testing:
client.updatePresence({
state: "slithering",
details: "🐍",
startTimestamp: Date.now(),
endTimestamp: Date.now() + 1337,
largeImageKey: "snek_large",
smallImageKey: "snek_small",
instance: true
});
isn't it always setActivity
?docs rpcclient.updatepresence rpc
?docs rpcclient.setactivity rpc
i'm pretty sure that's what you want?
oh wait, you're using a completely different package. this isn't the server for it lmao
?npm discord-rpc
ya, ill change it to that package
this is the package we provide support for
ok
ill change it to that, 1 momento
also https://discord.js.org/#/docs/discord-rpc/master/class/RPCClient?scrollTo=setActivity keeps redirecting me to the main page
looks like a bug in the bot
ok
thanks
what is the instance arg?
@karmic wagon
An instance of a class is a description of a specific object in memory. The class describes the properties and methods that will be available for the object, built according to the description embedded in the class. ... That is, they say: (in a virtual environment) create an instance of a class or, in other words, instantiate a class.
Is it possible to run RPC remotely without a real discord instance open?
not really, mainly because your discord client runs RPC server your game or app connects to.
Is there any sort of stand alone RPC server?
why would it be a thing
discord has rpc because it uses the data to display it on your profile
it's like running a ftp server that has no files, accounts and internet access
How exactly does the RPC connect to discord?
usually would be localhost:6463, either websocket if from browser-like "place", or via ipc
I'm using ffmpeg to detect black frames and sequences
but i get random frames each run
is this rpc related?
no, it's not. it's not even js
Right so i've got a DRPC script set up that would switch the RPC every hour. Buut instead of doing that it continues to run the DRPC from the hour that it was ran on. Is there any way to self restart the script once it turns the next hour?
Something like this in batch
:beginning: //code here goto beginning
you could simply put code into a function and call the function periodically
I could give you a copy of the code if you'd like because i think that's what i currently have done
send a pic @full bison
damn that was 2 days ago lol
ill do soon
ey who wrote djs-rpc
can i send them a fixed version of their broken example lmao
i was looking into it for a smoll project im doing and decided to try out the example
it was broken so i fixed it
so you want your rpc to set like that
?
every hour a different thing
yeah
i was thinking it would look cool
first of all what does date.getHours() return?
and second
arguably more important
the current hour
no seconds included
don't really need them tbh
here look
where
const DiscordRPC = require('discord-rpc');
DiscordRPC.register(clientId);
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
rpc.setActivity({});
setActivity();
rpc.login({clientId}).catch(console.error);
try doing it like this
also isn't it always going to be the same hour? @full bison
well it does not update it with the correct hour no. But idk if it gives back the new hour
i could make a function that runs every minute and see what happens
okay
But i first gotta wait for a hour change
so first of all connect to discord-rpc properly
paste my code into there
const DiscordRPC = require('discord-rpc');
DiscordRPC.register(clientId);
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
this specifically
right and where it says clientId i should put exactly that?
yes
the thing that you get on the front page of your discord app
Yeah
hmm
whoop
wait
okay found the docs
so
just go like
it should be client. right?
that doesn't matter
rpc.on('ready', () => {
setActivity();
});
just add that to the bottom of the function
wait
@full bison are you reading the djs-rpc docs or the discord gameSDK docs?
I think the djs-rpc docs
also your interval is 60 seconds
yeah ik that
It still does this btw even with the thing at the end of the function
hold on im trying it for myself
@full bison what are you running this on?
what is the code?
can i see it?
ok we solved the issue
Code
const clientId ='656631192195694604'
//<theres my code of rpc>
rpc.login({clientId}).catch(console.error)
Error
{ code: 4000, message: 'Invalid Client ID' }
One hour ago its working but now its not working.
I Restarted my application its start give me error.
Anyone have solution ?
check if the clientid is okay ig?
i fixed okey.
now i have question
how to make clickable text like a spotify
99.9% that you can't.
Spotify 's rpc does not work in same ways you could do with regular rpc api

@carmine mica https://github.com/theqoobee/RPC/tree/master/example haha
the fuck
it's just a fixed version of your example for discordjs/RPC
i needed it a couple weeks ago and checked out the example it was br0ken so i unbr0ked it
nothing about that is "fixed"
it works now
it already works
it didn't
then you did something wrong
the snakes couldn't update and the booping did nothing
try the one from discordjs/rpc out for yourself
it 100% don't work
I wrote it
I know it works
try it
ik you wrote it
no
I have better things to do with my life
twas broken and now it fixed cause i was bored
okay
@carmine mica there
there just wanted to tell u
sorry for disturbing you
"I have better things to do with my life than to test the code i wrote"
- creator of djs rpc
@warped flint you installed the wrong version of electron
electron changed some defaults in later versions
k ill try it now
yeey gj @carmine mica it works now lol
nice
oh just a quick question, do you recommend npm or yarn
This might be random but anyone know why i'm getting this error when running my DRPC script on my rabperrypi?
pi@raspberrypi:~/Discord-Bots/DRPC $ node DRPC.js 21 Error: Could not connect at Socket.onerror (/home/pi/Discord-Bots/DRPC/node_modules/discord-rpc/src/transports/ipc.js:32:16) at Object.onceWrapper (events.js:315:30) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at emitErrorNT (internal/streams/destroy.js:64:8) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9) ^C
It runs fine on my pc
cuz
discord is not opened
open discord and start app
oh
if u try to make Discord Bot Presence with DJS-RPC
bot don't have rich presence
u can't
Right
So i'd have to run discord on my rasbperry pi. Does that have to be the app version?
uhm yes
frick
Using discord-rpc i always get
Error: OAuth2 Error: invalid_request: Missing "redirect_uri" in request. and get asked to authorize the app
const RPC = require("discord-rpc")
const clientId = '514513911712238095';
const scopes = ['rpc', 'rpc.api', 'messages.read'];
const client = new RPC.Client({ transport: "ipc" });
client.on("connected", () => {
console.log("Connected!")
})
client.on('ready', () => {
console.log('Logged in as', client.application.name);
console.log('Authed for user', client.user.username);
});
client.login({ clientId, scopes });```
i changed websocket to ipc as when it is on websocket it just throws an "undefined" error
put client secret somewhere into client.login()
@unborn stream what should i define it as?
enter it as a parameter or as a value of a parameter into the client’s login method
client.login({ clientId: [yourClientId] })
oh lol thought this was today or something
that's also not exactly correct
how can i use messages..read scope
how do i access it in the discord=rpc
Error: Not authenticated or invalid scope i keep getting this even before authorizing on the client
oh saw the search history
time to dip my fingers into the lib
sick it works
basically what i did is set my redirectUri to 127.0.0.1 and set a timeout so the client has time to authenticate and then perform the requested action
i might make a pr to emit the ready event after authentication succeeded
Message event is broken but discord sends it
fixie time
found the issue
what is rpc?
rich presence
in the example for rpc, i dont understand the ID. can anyone explain?
is this the ID of the user?
how would i even approach integrating rpc as a mod for a game
i have a lua engine to work with in this case
like what are the rpc fundamentals
how does the application interact with discord
is there an rpc server running on the discord client i have to connect to?
whats the point of the sdk then
lol
to have reaady to use library that you plug directly to your app and instantly can use it?
just like discord.js makes you totally not care about making direct requests to discord's api
using rpc can i set rich presence?
thats all it does
Oh
what else did you expect rpc to be used for
i did not know what it was
you got told it was rich presence...
what is rich presence
everyones sleeping :/
Rich Presence allows you to leverage the totally overhauled "Now Playing" section in a Discord user's profile to help people play your game together. Rich game data—including duration, score, current boss or map, and so much more—lives inside Discord. You can spectate a friend's game directly from their profile popout, or party up via beautiful chat embeds with real-time information about open party slots and the party's in-game status. No more exchanging usernames and friend codes, or wondering if there's room for you to join. Rich Presence is a living invitation to play together, or to watch your friends kick butt.
Taken from https://discordapp.com/developers/docs/rich-presence/how-to#so-what-is-it
I always thought it was remote procedure call
overall - yes
in terms of discord - it is your definition used to display more data on your profile from apps that support it
whole "definition" above from 12d ago even though it's chunky doesn't explain much. simple screenshot of spotify or vscode presence would do as well
It doesn’t but I thought I’d use the official "definition"
?docs rpc
lol
How do i rich presence to a channel from an online game
for example
there's a player list and i want to display it on specific channel