#archive-rpc-help

21942 messages · Page 19 of 22

river edge

well, here is my code: ```ts
import * as drpc from "discord-rpc";
const client = new drpc.Client({ transport: "ipc" });
export async function rpc(details, date) {
drpc.register("redacted");
client.on("ready", async () => {
await client.setActivity({
buttons: [{
label: "Download 📥",
url: "https://github.com/redacted/releases/latest"
},
{
label: "Source code ⌨",
url: "https://github.com/redacted/"
}],
details: details,
state: Powered by Electron v${process.versions.electron}, NodeJS v${process.versions.node}, Chromium v${process.versions.chrome} & v8 v${process.versions.v8}.,
startTimestamp: date,
largeImageKey: "redacted",
largeImageText: "redacted",
});
});

client.login({ clientId: "redacted" }).catch((e) => {
    console.log(e);
});

}

export async function createRPC(details, date) {
await client.setActivity({
buttons: [{
label: "Download 📥",
url: "https://github.com/redacted/releases/latest"
},
{
label: "Source code ⌨",
url: "https://github.com/redacted/"
}],
details: details,
state: Powered by Electron v${process.versions.electron}, NodeJS v${process.versions.node}, Chromium v${process.versions.chrome} & v8 v${process.versions.v8}.,
startTimestamp: date,
largeImageKey: "redacted",
largeImageText: "redacted.",
});
}

quick prawn

does rpc wrok for bots? if not is there an equivalent

karmic jolt

No

quick prawn

is there a way to do something similar or na?

karmic jolt

No

glad bridge

is it possible to make a custom status for your bot?

i know its possible to get one like this

short sundial

Nope

glad bridge

like this

but can i get one of those ones with buttons and pics and stuff

short sundial

Bots cant have rpc

glad bridge

aww

river edge

I really need this

hearty topaz

@raw holly is this extension yours?

icrawl.discord-vscode

river edge
hearty topaz
nimble yarrow

eh, no. Report it on the proper github repo. This here has nothing to do with his own vs code extension.

rough magnet

Hey
i need help because i wanted to create a kind of "self-bot", i want to host it 24/7 on a vps with an rpc of a cute message does anyone know any project in that line?

turbid socket

RPC doesn't orientate self-bots, it's just a system that uses local IPC/*nix pipes to send client data to your running Discord app

And yeah sure, you could grab the one from the RPC docs' samples, run it on your dedicated server

To login, it's <RPCClient>#login, whereas setting the activity it's <RPCClient>#setActivity

As for self-bots, no, we don't support nor give functionality for that kind of action, it's against the ToS, general developer rules

rough magnet
turbid socket
turbid oliveBOT
rough magnet

A

turbid socket

Taken from the docs:

const clientId = '287406016902594560';
const scopes = ['rpc', 'rpc.api', 'messages.read'];

const client = new RPC.Client({ transport: 'websocket' });

client.on('ready', () => {
  console.log('Logged in as', client.application.name);
  console.log('Authed for user', client.user.username);

  client.selectVoiceChannel('81384788862181376');
});

// Log in to RPC with client id
client.login({ clientId, scopes });

Note you'll have to change the scopes, transport, IDs and functions to what you need

That's just a minimal sample

spring dune

Websocket is a whitelisted transport btw

Use ipc

worldly bobcat
turbid socket
turbid socket
turbid oliveBOT

Please speak English in chat. S'il vous plaît parlez anglais. Prosimy o używanie języka angielskiego. Por favor, hable inglés. Bitte sprecht Englisch. Si prega di parlare inglese. Vă rugăm să vorbiți în engleză. Lütfen İngilizce konuş. 請講英文。 英語を話してください。영어만 사용해 주세요. Παρακαλούμε να μιλάτε αγγλικά. يرجي التكلم فقط بالانجليزيه. Praat alsjeblieft Engels. Vänligen tala engelska. Vennligst skriv engelsk I chatten. Molimo da pričate engleski. Пожалуйста, говорите на английском в чате.
Thank you very much.

hasty magnet

Could anyone guide me to the updated documentation for this

solar sentinel

That said, stuff like subscriptions to channels for message.read scope aren't properly implemented in the library as of currently; you'll have to manually download/implement one of the PRs i.e. #76 or #125, that said you'd have to consult the oauth2 docs for that type of stuff anyway

hasty magnet
solar sentinel

Is there a way to resolve DM channel Ids using the RPC Client? Currently I'm relying on NOTIFICATIONS_CREATE, which contains the corresponding channelId.

vestal moth

You need the Discord App for having the Rpc?

And whats the difference between discord-rpc & discord-rich-presence? (npm packages)

solar sentinel

discord-rpc is discord.js's implementation of the RPC endpoints, which let you programmatically interact with the Discord app, i.e. change active channels or join a voice channel

discord-rich-presence is a wrapper on top of discord-rpc that only does the setActivity() functionality of the rpc package, it cannot do the extra bits, but as such is simpler to use

rich presence is stuff like

hasty magnet

how do we add the latter two interactive buttons

the github and paypal thing

quiet hazel

<Client>.setActivity({ buttons: [{label: "Github", url: "https://..."}, {label: "Paypal", url: "https://..."}], ... })

hasty magnet

Thankyou @quiet hazel 🙌

quiet hazel

Np

smoky scroll

what's the character limit for this?

the 3rd line

solar sentinel

Guess and check or use the rich presence visualizer in application settings,

median apex

Hi is there any way that i can implement in which my bot will be able to change the users rich presence like maybe with oauth2 or some thing. Pls mention my name if you can help

valid bough
restive flame

hi where can i find all the options for the setActivity function in rpc

solar sentinel
cobalt sphinx

Where cna i see ohw rich presence works?

spring dune
cobalt sphinx

thanks

Why it doesn't show image?

scarlet willow

what is RPCClientOptions

spring dune

From src, I only found transport

scarlet willow
spring dune

Which unless you're whitelisted by Discord, is rpc

scarlet willow

okay

solar sentinel
drowsy cedar

how can i make the spectate and join buttons appear

turbid socket

Use the Discord GameSDK, or create your own buttons with the name(s) you want

lofty peak

Why does it always say that it couldn’t connect when everything is set up correct?

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

topaz surge

how do i add buttons to the rich presence

short sundial

?rpc-buttons

turbid oliveBOT

If you want to add buttons to your rich presence, Inside your setActivity call, you can use buttons: [ { label: " ", url: " " }, { label: " ", url: " "} ], you can have a maximum of 2 buttons
You wil not be able to press these buttons on your own account, so dont freak out when something doesnt pop up when you click it

karmic jolt

Don't use the private client.request method, there is setActivity() for that

gusty hollow

when i try to install the package, i get this error, any idea why?

pastel trench

You need visual studio c++ workload

gusty hollow

yup works now

thx

valid lagoon
Error: Could not connect
    at Socket.onerror (/home/container/node_modules/discord-rpc/src/transports/ipc.js:32:16)
    at Object.onceWrapper (node:events:483:26)
    at Socket.emit (node:events:376:20)
    at emitErrorNT (node:internal/streams/destroy:188:8)
    at emitErrorCloseNT (node:internal/streams/destroy:153:3)
    at processTicksAndRejections (node:internal/process/task_queues:80:21)
turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

craggy boughBOT
short sundial

is the gh feed supposed to be in here?

craggy boughBOT
misty furnace

Is it possible to set the RPC icon on the fly?
There is a cpp project where I would like to set the image from a buffer

nimble yarrow
craggy boughBOT
static epoch

i have seen people that have this buttons on their status, is this rpc? and if so, how can i do that?

turbid oliveBOT
static epoch

ok, imma try

static epoch

ok so i get this error when i do that

node : The term 'node' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ node .
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (node:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

but i have node installed

any1?

if someone knows how i can fix that, ping me pls

pastel trench

Reinstall it and check if it's correctly installed

static epoch

ok

olive linden
const RPC = require("discord-rpc");
const rpc = new RPC.Client({
    transport: "ipc"
})

rpc.on("ready", () => {
    rpc.setActivity({
        details: "Playing Visual Studio Code",
        state: "rank.js",
        largeImageKey: "vscode",
        largeImageText: "WorkSpace: commands",
    })

    console.log("RPC active");
})

rpc.login({
    clientId: "id"
})``` 
`Error: RPC_CONNECTION_TIMEOUT`

H5_DuckThink

What can be the reasons for that

topaz surge
topaz surge
static epoch

yea ik, i sorted it out

thanks either way :D

topaz surge
olive linden

I think I just need the id for that????

topaz surge
topaz surge

it can be found at OAuth2

olive linden

Oh

I'll try that

uncut moon

many people is saying that they r making bots my any custom application app is it this

dc.js

crude girder

possible to switch rpc between stable and ptb?

potent moon

hi i have a problem when someone joins the bot crash because:

Uncaught TypeError: Cannot read property 'send' of undefined

however I don't know how to fix the problem

const Discord = require('discord.js');
const client = new Discord.Client();
const { Client, MessageEmbed, Intents } = require('discord.js');

client.on('ready', () => {
    console.log('En marche boss!');
});

client.on('guildMemberAdd', member => {
    const embed = new Discord.MessageEmbed()
        .setColor('#eadc1f')
        .setDescription(`${member} vien de rejoindre le serveur. Esperont qu'il soit un atout pour se serveur discord`);
    member.guild.channels.cache.get(845841714136743956).send(embed)
});

client.login('token');

@fallen hemlock could you help me please

placid sundial
dry basalt

So I've got an issue where my RPC button won't actually work it will just appear there and on mouse click does nothing

nimble yarrow

It works.

dry basalt

Oh ok thanks for letting me know

smoky scroll

yo im trying code an rpc but it says missing package

what packages do i need to download to code an rpc

nimble yarrow
craggy boughBOT
craggy boughBOT
craggy boughBOT
stiff locust

Will rpc work if I host it in repl and use discord app in PC?

short sundial

No

craggy boughBOT
tall moth
smoky scroll

?rpc

turbid oliveBOT
craggy boughBOT
topaz surge
topaz surge
nimble yarrow
turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

nimble yarrow
topaz surge
craggy boughBOT
tall moth
craggy boughBOT
tired magnet
nimble yarrow
topaz surge
tired magnet

wdym

topaz surge
tired magnet

no, for me it just looked like he used a bot command to help him lol

lusty cipher

heya I wanted to know if the buttons in discord rpc support emojis

final saffron

They do

river edge
lusty cipher

what about custom thonk

smoky scroll
tall moth

I wrote the same code and the same error happend idk why

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

smoky scroll

here imma send an ss

nimble yarrow

thats not the same error then

smoky scroll
nimble yarrow

and the second error is... well... a missing package or an error in your path.

smoky scroll

but are the packages needed to code an rpc, discord.js, init, discord-rpc and dotenv ?

nimble yarrow

only discord-rpc

everything else is only needed if... well... you need it

smoky scroll

i mean i put my application id in a dotenv

nimble yarrow

Well, then you need the package.
But I don't see how this is RPC Support related.

smoky scroll

k thanks ill come back if i see any issues and btw just asking , the rpc package is just : npm i discord-rpc right ?

nimble yarrow

yes

smoky scroll

It lauches but i dont get any error, but it does not show on my status

what do u mean exactly ?

Who?

check dms

i added u

spring dune

This thing:

smoky scroll

i turned it on now it works thanks !

runic sparrow

what is rpc?

and how do i set it up

waxen gazelle

rpc, remote procedural calls, is being used here to connect to a locally running Discord client from another application @runic sparrow

vestal crescent

there is no way to change the application name like bots can right?

smoky scroll

client.on('ready', () => {.....

craggy boughBOT
ripe merlin

can i use discord rpc for my unity game so it displays the rich presence on discord in every device where game is running ??

spring dune

RPC works when run on the same environment where you have Discord

So... Yes? idk if phones work properly

sacred ore
ripe merlin

okay, thank you

zinc pewter

is it posible to host rpc? because I tried to, but got this error: (node:332) UnhandledPromiseRejectionWarning: Error: Could not connect at Socket.onerror (/home/runner/RobloxPresence/node_modules/discord-rpc/src/transports/ipc.js:32:16) at Object.onceWrapper (events.js:421:26) at Socket.emit (events.js:314:20) at Socket.EventEmitter.emit (domain.js:483:12) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:84:21) (node:332) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:332) [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.

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

zinc pewter

ah I see, it isn't running on same device as the discord app

I prob need a vps then

or a computer to host it at home

tribal pecan

Wasn't RPC going to be deprecated in favor of the game sdk?

nimble yarrow

whut, no, that would be stupid

tribal pecan
nimble yarrow

Yeah, no, pretty sure thats not the same.
They just have a new SDK now.

tribal pecan

Man and there I went writing a full C# application for rich presence purposes using the game sdk

😢

nimble yarrow

Also, deprecated doesn't mean that it doesn't work anymore.

Deprecated basically just means "stop it, we updated stuff, use the new stuff"

tribal pecan

With the active updates to discord i would assume it would stop working fairly soon after being deprecated

But yeah that's true

nimble yarrow

JarJarYes

tribal pecan

I guess I'll make a js rpc application next PaimonDepression

unless they add buttons to the game sdk rpc real quick

Thanks for the info either way!

smoky scroll

is it allowed to make a giveaway notifier by messages.read of oauth2 (just for personal use not for others)

tribal pecan

that sounds like selfbotting territory

icy drift

umm, the RPC is not working for me, i tried on all 3 builds, it says err on socket.on

autumn wasp

a discord bot can set rich presence in users without running the code in theirs devices?

pastel trench

No

autumn wasp

ok thanks

prime frigate

I'm trying to load RPC v4.0.1 docs on my browser but it's saying that it had failed to fetch docs data files

is it ok if I use the docs for Master instead?

tribal pecan

I'm trying to use the discordjs RPC package, but I keep getting connection closed when trying to connect. Since a help command for this exists I'll break down all the questions.

• What transport are you using? If it's 'websocket', change that to 'ipc'
I selected 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
Yes, moreso I can use the ID fine when using it through a C# application using the game sdk for rich presence setting.
• Are you using the Discord app? It won't be able to connect to the web version
Yes.
• Is your code running on the same machine as the Discord app?
Yes.
• Are you trying to run it from WSL? If so, it won't be able to connect either
No.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website
What's a snap store? (Using Discord Canary directly from the official website)

nimble yarrow
tribal pecan

The variable has to be named clientId? That's kind of weird, but alright

nimble yarrow

Yes, either use client.login({ clientId: clientID }) or change your variable to clientId

tribal pecan

Alright, that did it. Thanks!

sudden needle

how do i fix this?

anyone?

pastel trench

Rpc is not for bot#

sudden needle
sour furnace

Can i make CLICK buttons in my bot status actually??

pastel trench
sour furnace

oh god

pastel trench

What do you need to fix

If it's not possible you can't, stop

sudden needle
sudden needle
pastel trench

?!

nimble yarrow
turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

sudden needle
nimble yarrow

Read it.

sudden needle
nimble yarrow

Thats your problem, not mine.

sudden needle
halcyon hill

When I do console.log(client), I get all the RPCClient info including user, but console.log(client.user) gives null

halcyon hill

damn nobody on??

reef jay

are you sure user isn't inside another object

halcyon hill
reef jay

just debug

halcyon hill

but yea @reef jay i did Object.keys(client) and it clearly shows user

reef jay

hm

try client.user.avatar

halcyon hill

@reef jay nope

reef jay

idk then

halcyon hill

and console.log(Object.keys(client)[7]) does produce user

reef jay

Weird

halcyon hill

oddly client.clientid doesnt work either :(

halcyon hill

UPDATE: worked in putting it in the ready event

lost shore

Hi sorry, could anyone help me ive checked every step and i always get connection closed

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

lost shore
nimble yarrow ?cc

hi sorry for the ping i found the error forgot to put in the client id but it isn't showing up on my status

nimble yarrow

• Is your code running on the same machine as the Discord app?

lost shore
nimble yarrow

Are you using the web app or the program?

lost shore

program

nimble yarrow

can you show the code?

lost shore

sure

nimble yarrow

Hm, I don't see an issue there...

lost shore

Would running on power cord affect it?

nimble yarrow

I have no idea what powercord is

lost shore
nimble yarrow

correct

lost shore

If anyone has any ideas y it isn't working pls help

inland apex

If you click on your user in chat, then you can see it

Or the members list on the right

slate perch
const DiscordRPC = require('discord-rpc'); // Requiring the discord-rpc package.
const client = new DiscordRPC.Client({ transport: 'ipc' }); // Creating a client variable with is our rpc client.
require('dotenv').config(); // Requiring the content of our .env file.

(async () => {
    client.on('ready', async () => { // Calling the ready event.
        await client.setActivity({ // Setting the Rich Presence Activity based on what is passed in here.
            buttons: [{ label: "Dylon", url: "dylon.dev" }]
            
          
        }).catch(err => console.log(err));

        console.log("Discord Rich Presence has been enabled.");
    });

    await client.login({ clientId: process.env.applicationID }).catch(console.error); // Logging into our application.
})();```
So this my my code but i get could not connect
turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

slate perch
nimble yarrow

Yes, correct.

gentle sorrel

how do i get started with this rpc
i couldn't find any tutorials or guides except the "browser example" which idk what it does and how to use it

gentle sorrel
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
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 
```i can't seem to install it?
zinc sleet
nimble yarrow
zinc sleet

Im using my event handler

Oh wait rpc has events?

nimble yarrow

Not your bot's ready event, the rpc client's ready event.

Bot's cant have RPC btw

zinc sleet

Yeah sorry i didint know what you mean

smoky scroll

Is it agains't tos to set your own custom atatus with buttons and that using rpc?

With that code

turbid socket

No? That isn't against terms of service, how exactly would it be so? RPC only interfaces with your local Discord app that has a dedicated HTTP/WS URL depending on the situation. That is completely accepted - in fact, Discord has a docs for it. Therein, SET_ACTIVITY is the command, it changes your status, that is allowed since it doesn't have anything to do with modifying the client, since the "thing" is natural. You may read more at https://discord.dev/topics/rpc.

smoky scroll

how do i apply rpc?

fathom lion

ugh... discord docs don't make it clear what scopes you can use with rpc and what transport you should use to get correct access to those scopes

docs make it seems like websocket and ipc are equivalent

fathom lion

and something internally in discord-rpc seems to be failing to catch the error thrown by net.js

merry crown

code:

const client = new DiscordRPC.Client({ transport: 'ipc' }); // Creating a client variable with is our rpc client.
require('dotenv').config(); // Requiring the content of our .env file.

(async () => {
    client.on('ready', async () => { // Calling the ready event.
        await client.setActivity({ // Setting the Rich Presence Activity based on what is passed in here.
            buttons: [{ label: "Button", url: "https://www.youtube.com/" }],
            details: "Description",
            largeImageKey: "newi",
            largeImageText: "This text is shown when hovering over the largeImageKey in Discord."
        }).catch(err => console.log(err));

        console.log("Discord Rich Presence has been enabled.");
    });

    await client.login({ clientId: process.env.applicationID }).catch(console.error); // Logging into our application.
})();```

It just doesnt work
balmy grail

Same. I get the following error: js Error: Could not connect at Socket.onerror (C:\Users\DBE\Projects\Discord RPC\node_modules\discord-rpc\src\transports\ipc.js:32:16) at Object.onceWrapper (node:events:485:26) at Socket.emit (node:events:378:20) at emitErrorNT (node:internal/streams/destroy:188:8) at emitErrorCloseNT (node:internal/streams/destroy:153:3) at processTicksAndRejections (node:internal/process/task_queues:81:21)

onyx mica

?cnc

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

merry crown
merry crown

Is it possible to add files with rpc in a host service?

solar sentinel
smoky falcon

Is it possible to apply rpc on bot?

nimble yarrow
opaque parcel

help, i am trying to add an invite embed to my RPC:

const Discord = require('discord.js');
const config = require('./config.json');
const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION"] });
const clientId = '846011257889751081';
const scopes = ['rpc', 'rpc.api', 'messages.read'];
const RPC = require('discord-rpc');
const browser = typeof window !== 'undefined';
const rpc = new RPC.Client({ transport: browser ? "websocket" : "ipc"});

client.on('ready', () => {
    console.log("Bot ready");

    const deafultRPC = {
        details: "The best space shooter",
        startTimestamp: 0,
        largeImageKey: "icon",
        largeImageText: "VOID ZONE",

        buttons: [
            { label: "Get VOID ZONE NOW", url: `APP_WEBSITE` },
        ],
    }

    await rpc.setActivity(deafultRPC).catch(err => console.log(err));
});

rpc.login({ clientId: clientId }).catch(console.error);
client.login(config.Token);
``` so that i can invite users to my app ?
merry crown
solar sentinel You cannot send messages via RPC, which would include sending file attachments.

I mean to host this thing

const client = new DiscordRPC.Client({ transport: 'ipc'}); 

(async () => {
    client.on('ready', async () => { // Calling the ready event.
        await client.setActivity({ // Setting the Rich Presence Activity based on what is passed in here.
            buttons: [{ label: "Join Shop Here", url: " }],
            details: "Ultimate †Rapid's Products",
            largeImageKey: "rpc_icon",
            largeImageText: "†Rapid Shop",
            smallImageKey: 'l',
            smallImageText: 'κλαψε',
            
        }).catch(err => console.log(err));

        console.log("Discord Rich Presence has been enabled.");
    });

    await client.login({ clientId: '860246627092922418' }).catch(console.error); // Logging into our application.
})();```
In a hosting service
karmic jolt

No, it needs to run on the PC where you have Discord running

rare kelp

Is RPC supported on linux?

twin tangle

Is RPC supported on bots ?

nimble yarrow
twin tangle

K thanks

fathom lion

Trying to work around discord sending DMs when using the profile "Ask to Join" button, but that results in 'secrets cannot currently be sent with buttons'
Is there a known ETA when they can be used with buttons? the currently makes it sound like it's a temporary limitation

I would like custom buttons to appear on the profile but still have a joinSecret so sending invites to channel also works

fathom lion

Now that I think about it, I would actually prefer if custom buttons were the only thing that appears on the profile

smoky scroll
smoky scroll

I'm trying to do a custom rich presence but it doesn't seem to work for me. This is my code

const { Client } = require('discord-rpc');

const client = new Client({ transport: 'ipc' });

client.on('ready', () => {
    client.setActivity({
        details: 'I am Redfer',
        smallImageKey: 'redfer',
        smallImageText: 'test',
        buttons: [
            { label: 'Test', url: 'link' }
        ]
    }).catch((e) => console.log);
})

client.login({ clientId: 'clientID' })

I don't get any errors either

is it just not visable to me or something?

manged to get it to work now

for some reason it has low priority or something

nimble yarrow

@smoky scroll i suggest you remove the invite

smoky scroll

oh yea i should

my bad

removed

solar sentinel
smoky scroll

i already figured it out heh .... but yea that;s what i did

floral bear

what are the RPCClientOptions
I see only the RPCClient
in docs

or is example in github is all options?
wat bout endTimestamp ? or any others

fathom lion
/**
   * @typedef {RPCLoginOptions}
   * @param {string} clientId Client ID
   * @param {string} [clientSecret] Client secret
   * @param {string} [accessToken] Access token
   * @param {string} [rpcToken] RPC token
   * @param {string} [tokenEndpoint] Token endpoint
   * @param {string[]} [scopes] Scopes to authorize with
   */

These seem to be the options. Not that you would ever need anything other than clientId

and maybe scopes depending on what you want to do with the user's discord

pastel trench

Mmh when's the secret needed?

karmic jolt

For almost everything except rich presence

pastel trench

Nice thx

Oh sorry and what's the rpcToken?

solar sentinel
pastel trench

Ohh ye. Thank you very much!

smoky scroll

Whenever i start my rpc program on my pc it runs fine, but on my virtual server it says cant connect

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

nimble yarrow

• Is your code running on the same machine as the Discord app?

jade jewel

how can i control my rpc from a different machine?

nimble yarrow

You can't

jade jewel

aight thought so

river edge
smoky scroll

Does anybody know how I can add buttons to my RPC? Thanks in advance.

turbid oliveBOT

If you want to add buttons to your rich presence, Inside your setActivity call, you can use buttons: [ { label: " ", url: " " }, { label: " ", url: " "} ], you can have a maximum of 2 buttons
You wil not be able to press these buttons on your own account, so dont freak out when something doesnt pop up when you click it

smoky scroll

Got it, thanks poggythumbsup

Is 2 the limit of buttons I can have?

Was thinking of 3 but have only seen 2 so far on RPC's

smoky scroll

oh

pastel trench

Wasn't it discord-rpc Thonk

nimble yarrow

yes

smoky scroll

nono

im trying to install the wrapper

karmic jolt

You need git installed for that

because the discord-rpc dependency uses the github url for whatever reason

nimble yarrow

oh wow

smoky scroll

oh

thanks

proven gate

Some knows how can I, make my own rpc the top in the priority scale of another games

?

solar sentinel

This is unlikely to change considering hobbyist/individual RPC clients are a rather hacky aspect of Discord, and RPC is largely deprecated in favor of the Games SDK. Our use-case is more of a side-effect of their RPC implementation- this is the same reason why a number of the features are whitelist only.

fathom lion

Discord's documentation around rpc is very weird. I think they used to say outright that you should use gamesdk, but now the docs say rpc is in private beta. Also there's rich presence documentation that's even more behind

potent heath

how can I make my own rpc

pastel trench

Mmh, what?

When i run it, this is displayed on discord, but, after that, the error appears

fathom lion

Show your code

pastel trench

I'm not actually on my pc. But It's like this:

const clientId = '...';
const clientSecret = '...';
const scopes = ['rpc'];
const client = new RPC.Client({ transport: 'ipc' });
client.on('ready', () => {
  console.log('Logged in as', client.application.name);
  console.log('Authed for user', client.user.username);
});
client.login({ clientId, scopes, clientSecret });

I'm now guessing it's because I need to specify the redirect url

bleak wave

I had a question, why is the documentation about Discord-RPC is not as detailed as Discord.js
What I mean is like the properties of Args is not even specified

So it is getting a bit hard to know the possible params

pastel trench

Mmh when i connect it always ask me to authorize my app... Is there a way to "save" this? Is it based on the access token? Should I get it and then save to always use it?

Also the button doesn't work lol. idk if the problem is of my discord app, but when i click on it nothing appears

fathom lion

The button does not work for yourself, you need an alt account running on a different release (canary/ptb)

pastel trench

Ah lol. It does work on my phone

thanks

Now i'm struggling with endTimestamp. Let's assume I want to set it in one hour, what should I use

Nvm solved, thx 🙂

main tapir

anyone know about yt music rpc (i dont have permission to install apps like premid)

fathom lion
tardy heart

Hi. Is there a way to set the name of the application from the code?

pastel trench

Mmh i don't think so

atomic sparrow

Hii, how would you remove the activity? I know how to turn on the activity, or replace it, but I don't know how I would remove it.

gentle sorrel

wdym?

if you don't want a specific item, say the button, you can just not include it

if that's what you're asking

atomic sparrow

but if I disconnect, I would have to reconnect when I want my acitvity again. I want to be able to say ''toggle rpc'' and then it will turn the rpc on, or off.

pastel trench

Uhm

You can disconnect and reconnect fastly ig

Ok I'm blind

atomic sparrow

ye that is an option, but that's not what I want to do.

atomic sparrow

Ty very much

pastel trench

Np

atomic sparrow

Well now I know why I couldn't find anything about RPC in the docs.

Should I report that or something? Small bug

pastel trench

Probably it's a problem with your browser mmh

However use the link in the channel description

nimble yarrow
atomic sparrow

When you have that problem, you can just change back to Main, then to RPC again.

atomic sparrow

Ye I did, I just didn't know if I should have reported it

What I don't understand is, can someone just use a clientId and try and start their rcp?

Or am I supposed to use a different application for my rcp so no1 finds out which ID that application has. Now I am using one of my bots, which is stupid if I'm correct.

karmic jolt

You don't need to keep the application id secret, no

The id only really matters if you need to use assets

nimble yarrow

Isn't the app id the id of the bot anyway?

karmic jolt

For 99% of bots yes

But for really old ones they're different

open cove

how can i do like this or can i do

solar sentinel

Make a multi million dollar application and then get in contact with Discord- those are proprietary to Spotify's RPC. Similar to how Twitter gets special embeds on Discord.

leaden lake

i will

smoky scroll

proven gate

the name of image, respet cap letters

fossil pilot

?ban 763275643914944513 userbot changing cs

turbid oliveBOT

You sure you want me to ban this [no gender specified]?

fossil pilot

y

turbid oliveBOT

Successfully banned Tokyo#1000

copper moss

:news:

:news:

zinc oxide

can i use rpc with a token?

nimble yarrow
zinc oxide
nimble yarrow
zinc oxide

oh

nimble yarrow

And again, it requires an app id.

zinc oxide

yes i know

trail latch

why does rpc need a redirect uri?

nimble yarrow
pastel trench
trail latch
pastel trench

Yeah I had this problem too lol. If you don't need any other scope outside just setting the activity you can avoid specifying scopes so that it doesn't require a redirect uri. If you need scopes, so add the redirect Uri you're using in your Dev Portal. You can also directly use an access token so that it doesn't need to do an API call to get the access token

runic sparrow
const RPC = require('discord-rpc');
const rpc = new RPC.Client({
	transport: 'ipc'
});

async function login() {
	await rpc
		.login({
			clientId: process.env.clientId,
			clientSecret: process.env.clientSecret
		})
		.catch(console.log);
}
rpc.on('ready', async () => {
	await rpc.setActivity({
		state: 'Coding a bot',
		details: 'a',
		largeImageKey: 'djs'
	});
	console.log("logged in")
});

login()

??

turbid socket

?cc

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

runic sparrow
  1. im on mobile
  2. repl is my only option as a coding platform ig
fathom lion

Discord RPC only works if you are running discord and your app on the same device (as stated in the 4th bullet point)

It's your app using IPC (usually Windows' named pipes) to send data to discord. This does not work if your app is running on cloud somewhere

pastel trench
spring dune

RPC has to be running on the same local environment as your Discord Client.

tame apex

is it possible to use RPC on a web browser? an example might be to update a user's presence while playing a browser game

near falcon

what are the valid scopes?

nimble yarrow
tame apex

Ok, thank you.

zinc sleet

Hey , so i have the invite to party thing , ( the ss below ) , and i want to know how the join button works , like can i let the user open a link when he click the join button ?

solar sentinel

That is designed to work in conjunction with a game.. and actually invite a person

solar sentinel

realize I got interrupted before making my actual point: you likely want to be using buttons instead (like what you would see on my profile right now)

?tag rpcbuttons

turbid oliveBOT

When you beg me so much I just can't not help you~
Check ?help tag for more information.

solar sentinel

?rpc-buttons

turbid oliveBOT

If you want to add buttons to your rich presence, Inside your setActivity call, you can use buttons: [ { label: " ", url: " " }, { label: " ", url: " "} ], you can have a maximum of 2 buttons
You wil not be able to press these buttons on your own account, so dont freak out when something doesnt pop up when you click it

zinc sleet

ik how to make them if i wanted i would of put them if i wanted

the link is kinda of a game

So i want to use join

solar sentinel

I dont believe that is possible without being whitelisted by Discord. (As you can only utilize RPC on the local client for unwhitelisted indiviuals)

indigo raven

what is an rpc clien

client

turbid socket
golden marlin

Can rpc be used on mobile

nimble yarrow

no

golden marlin

Even in termux or linux running on proot?

nimble yarrow

no

golden marlin

Oke

void kernel
odd compass

like this

just add > at start

smoky scroll

When I use discord rpc, following the example almost exactly, I get this error:ReferenceError: RTCPeerConnection is not definedWhy is that?

It shows as coming from one of the modules

Are there other modules I need to install? All I did was npm i discord-rpc

I'm trying to make a rich presence for my game

Nevermind, I just used a wrapper and it worked fine

nimble yarrow

?cnc

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

nimble yarrow

Yes?

Then stop programming.

lost shore

i get a error when using rpc?js (node:17656) UnhandledPromiseRejectionWarning: Error: RPC_CONNECTION_TIMEOUT at Timeout._onTimeout (C:\Users\Nav\node_modules\discord-rpc\src\client.js:100:47) at listOnTimeout (internal/timers.js:557:17) at processTimers (internal/timers.js:500:7) (Use `node --trace-warnings ...` to show where the warning was created) (node:17656) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:17656) [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.

marble flame

how spotify get its images, i dont think they added all images

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

brazen heron

is discord-rpc a part of the djs?

nimble yarrow
brazen heron
nimble yarrow

No, it's still a different package.

brazen heron

but it is a part of it?

karmic jolt

They're separate

brazen heron

but why are docs of rpc are given in the djs docs

karmic jolt

Because they belong to the same organization

But are still separate packages

brazen heron

oh

solar sentinel
sturdy apex

Any information surrounding this error with discord-rpc would be appreciated greatly!

This is the code:

    // Discord presence
    discordPresence() {
        const discRpc = require('discord-rpc');
        const rpc = new discRpc.Client({
            transport: 'ipc'
        });
        rpc.on('ready', () => {
            rpc.setActivity({
                details: this.version,
                state: 'Information',
                startTimestamp: Date.now() - 500000,
                smallImageKey: 'Information',
                smallImageText: 'Information',
                largeImageKey: 'Information',
                largeImageText: 'Information',
                instance: true
            });
        });
        rpc.login({
            clientId: CLIENT_ID,
        });
    };
solar sentinel

?cc

turbid oliveBOT

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

sturdy apex

All of those are correct.

I'm using 'ipc' with an instance of Discord running on the same machine as the program.

This error just arose 2 days ago but the presence was showing up prior with no issues.

solar sentinel

Your code is functional for me; most likely you are providing an invalid clientId.

Thats most commonly due to people using a number instead of a string.

lost shore

?help

turbid oliveBOT
lost shore
solar sentinel
lost shore

I think I know why now

Thank you

sturdy apex

Yeah and I have it as a string not an integer.

solar sentinel

Very unlikely, but are you using the applicationId, or the clientId (clientId is found in the OAuth2 tab)

On very old applications, they can be different, but it should be the same value for 99% of people

The only other possibility I see is that you are simply not calling the function; your function header syntax seems a bit wonky

sturdy apex

everything checks up

could it be something with my discord?

I uninstalled and reinstalled seemed to solve the poblem.

@solar sentinel

teal thorn

idk

glass shale

@raw holly heya i cant find a support channel but this dude prolly using a bot to dm everyone in here id: 864666519086170132

oh you're on dnd

@raven ember ^^

fossil pilot
ebon sage

Uh, now what does this mean

node_modules/discord-rpc/src/client.js:178
        const e = new Error(message.data.message);
                  ^

Error: child "pid" fails because ["pid" must be a number]
    at RPCClient._onRpcMessage (/node_modules/discord-rpc/src/client.js:178:19)
    at IPCTransport.emit (node:events:394:28)
    at node_modules/discord-rpc/src/transports/ipc.js:138:18
    at decode (node_modules/discord-rpc/src/transports/ipc.js:92:5)
    at Socket.<anonymous> (node_modules/discord-rpc/src/transports/ipc.js:120:7)
    at Socket.emit (node:events:394:28)
    at emitReadable_ (node:internal/streams/readable:573:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 4000,
  data: {
    code: 4000,
    message: 'child "pid" fails because ["pid" must be a number]'
  }
}

oh i was accidentally sending something ot clearactivity

sand sapphire

Is there any way to have rpc on phone?

nimble yarrow
sand sapphire

Sed

static vortex

Doesn't Samsung have their own weird rpc

nimble yarrow
smoky scroll
const RPC = require("discord-rpc"); 
const client = new RPC.Client({transport: "ipc"}); 

const activity = { 
    details: "Music Bot", 
    assets: { 
        large_image: "large", 
        large_text: "Working", 
    },
    buttons: [ 
        { 
        "label": "Website (Coming Soon)", 
        "url": "" 
        },
        { 
        "label": "Discord", 
        "url": "" 
        },
    ],
    timestamps: {start: Date.now()}, 
    instance: true,
} 

client.on("ready", () => { 
    client.request("SET_ACTIVITY", {pid: process.pid, activity: activity}); 
    console.log("Done."); 
}) 

client.login({clientId: "739529865019129926"});
``` Are you allowed to do this?

Or is it agains't ToS

nimble yarrow

why would it be against tos

smoky scroll

Cuz you could have buttons etc for your own profile

nimble yarrow

If they wouldn't allow it, they wouldn't make it possible...

smoky scroll

True

nimble yarrow

and certainly djs wouldn't make it possible.

smoky scroll

Yea

Makes sense

solar sentinel

something something, message loggers arent allowed but RPC enables it

But yeah, that is completely within bounds- the only iffy part would be if you try to refresh your status faster than the rate limit (~15 seconds)

swift osprey

i got a problem i cant install discord-rpc any ideas

swift osprey
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t https://github.com/djs/discord-rpc.git
npm ERR! 
npm ERR! remote: Invalid username or password.
npm ERR! fatal: Authentication failed for 'https://github.com/djs/discord-rpc.git/'
npm ERR! 
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/john/.npm/_logs/2021-08-01T11_39_03_617Z-debug.log

@nimble yarrow

on win10

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://github.com/djs/discord-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\John\AppData\Roaming\npm-cache\_logs\2021-08-01T11_45_09_739Z-debug.log

nimble yarrow

nkoHmm

swift osprey
nimble yarrow

yes, thats the wrong link

but why

swift osprey
nimble yarrow

No, I can install it without problems.

swift osprey

tf

nimble yarrow

RPC

sick venture

Can I somehow run rpc not from my pc (to SET_ACTIVITY)?

turbid socket

RPC needs a desktop with a running Discord client to work...

sick venture

are there any non-TOS-breaking alternatives?

solar sentinel

but in that you are strictly relying on the fact that it'd be rebooted less often than your primary desktop

sick venture
solar sentinel

Yes.

twin tangle

Can use rpc For bot ?

alpine spoke

no

neon spruce

Guys, the join log is not working when I join in Voice Channel

someone know why?

solar sentinel

SELECT_VOICE_CHANNEL is an RPC command

You want to listen to VOICE_CHANNEL_SELECT

client.subscribe('VOICE_CHANNEL_SELECT', (channelData) => {
  console.log(channelData)
})
solar sentinel
neon spruce

Hi, @solar sentinel , thanks for the answer, but still not working :/

sand sapphire

Wait wat, you can now have game status on phone

nimble yarrow
sand sapphire

Oh

I have Xiaomi kek

neon spruce

The console.log('join2') pops up

timid sky

UnhandledPromiseRejectionWarning: Error: RPC_CONNECTION_TIMEOUT

const RPC = require("discord-rpc");
const clientId = "client id here";
const client = new RPC.Client({ transport: "ipc" });
client.once("ready", (client) => {
  startTimestamp = new Date();
});
client.login({ clientId });
client.setActivity({
  details: "test",
  state: "test2",
  startTimestamp,
  instance: false,
});
```any help?

wait do i need client secret?

or public key?

timid sky
nimble yarrow

you should only need the app id

timid sky

the client id?

nimble yarrow

the app id

application id

timid sky

o yeah

nimble yarrow

but move the .setActivity call inside the ready event

timid sky

oh yeah

lmao

still doesn't work

nimble yarrow

• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

timid sky

it's ipc, i'm logging in with client.login({clientId: " id i got from developer page "});, yes i'm using discord ptb (does ptb still work?), yes same machine, no i use ubuntu not on windows, no from official site

nimble yarrow

RPC Timeout

timid sky

uh

timid sky

sorry was busy with irl stuff

lemme try

yep it works

was just my code ig

torn robin

@nimble yarrow I'm getting a similar issue. Here's my code:

import { Client } from 'discord-rpc'

const clientId = '872862032226054215'
const scopes = ['rpc', 'rpc.api', 'messages.read']

const client = new Client({ transport: 'ipc' })

client.on('ready', () => {
  console.log(client.user.username)
})

await client
  .login({
    clientId,
    scopes,
  })
  .catch(console.error)

Prints the following error:

    at RPCClient._onRpcMessage (/Users/brad/github/bradhilton/trading-bot/node_modules/discord-rpc/src/client.js:178:19)
    at IPCTransport.emit (events.js:314:20)
    at IPCTransport.EventEmitter.emit (domain.js:486:12)
    at /Users/brad/github/bradhilton/trading-bot/node_modules/discord-rpc/src/transports/ipc.js:138:18
    at decode (/Users/brad/github/bradhilton/trading-bot/node_modules/discord-rpc/src/transports/ipc.js:92:5)
    at Socket.<anonymous> (/Users/brad/github/bradhilton/trading-bot/node_modules/discord-rpc/src/transports/ipc.js:120:7)
    at Socket.emit (events.js:314:20)
    at Socket.EventEmitter.emit (domain.js:486:12)
    at emitReadable_ (_stream_readable.js:567:12)
    at processTicksAndRejections (internal/process/task_queues.js:79:21) {
  code: 5000,
  data: { code: 5000, message: 'OAuth2 Authorization Error: Unknown Error' }
}

Nevermind, I figured it out @nimble yarrow

nimble yarrow

pingBOYE

torn robin

Once you've connected the RPC client, is there a way to get more than the last 50 messages in a channel?

solar sentinel

No, what is your usecase?

torn robin

I was hoping to read more than 50, but that's okay

Also I'm trying to subscribe to a channel

But I'm getting an error

solar sentinel

Im a bit curious how you are even getting 50 historical messages via RPC

torn robin

Error: Invalid channel id: undefined

You can get up to 200 if the user scrolls back @solar sentinel

It's kind of neat/inconsistent lol

Anyways, I'm trying this:

  await client.selectTextChannel('823158486593699850')
  await client.subscribe('MESSAGE_CREATE', data => console.log(data))

I think the subscribe method needs to take the channel id

solar sentinel
await client.subscribe('MESSAGE_CREATE', { channel_id: '823158486593699850' }, (msg) => {
  console.log(msg)
})
torn robin

Doh, there is an overload

Sorry my bad

solar sentinel

that said Im not sure if current build properly handles that event

there have been PRs since I messed with it, so perhaps it does, but I had to manually merge stuff and have been using my own fork for stuff
(EDIT it does, talked in DMs and my fork fix his issues https://github.com/alanbixby/discordjs-rpc)

torn robin

Yeah the message isn't being returned

But the error went away

fallen kayak

what's discord.js rpc extension?

sudden needle

How do i get this thing?

right noww i have this

dusty warren

Yo need to add .setTimestamp() i think

sudden needle
dusty warren

const timestamp = new Date();

And then include

only

sudden needle
sudden needle
sudden needle
dusty warren

and then, for example down of state, timestamp

ez

sudden needle
sudden needle

can you show it to me?

dusty warren

bruuuuh

nimble yarrow

Delete that invite

Both of you

sudden needle

ok

sudden needle
sudden needle
dusty warren
const rpc = require('discord-rpc');
const Discord = require('discord.js-light');
const timestamp = new Date();
const { token } = require('./token.json'); //import the token of the bot from token.json or whatever you have saved it in, the different between {} and () is that, {} is the same as token.token, if you get what i mean

const bot = new Discord.Client();
const client = new rpc.Client({transport: 'ipc'});
const timestamp = new Date();
bot.on('ready', () => {
    client.login({clientId: bot.user.id});
    rpc.register(bot.user.id)
    client.on('ready', () => {
        console.log('RPC something');
        client.request('SET_ACTIVITY', {
            pid: 9999,
            activity: {
                 timestamp,
                details: 'Visual Studio Code', /*first text from the top of the rpc*/
                state: `Wussup`, /*this is the description, the 2nd text from top*/
                assets: {
                    large_image: "js", /*the name of big image (it should be same as you have saved in the dev portal*/
                    large_text: `this me :) not really, its wumpus`, /*this is what will be shown when you hover your cursor over it*/
                   //small image is optional, not really important, you can have it if you want and not have it if you don't
                    small_image: "xD", /*the name of the small image (it should be same as you have saved in the dev portal*/
                    small_text: `${bot.guilds.cache.size} servers` /*the text you want to be shown when one hovers cursor over the small image*/

                },
                //buttons are also optional
                buttons: [
                    {
                        label: "Invite Night Shade", /*what you want to be shown on the 1st button's text*/
                        url: "https://discord.com/oauth2/authorize?client_id=854352911706750997&permissions=8&scope=bot%20applications.commands" /*the link or anything where it redirects*/
                    },
                    //you can also only just have 1 button 
                    {
                        label: "Join my server", /*text for 2nd button*/
                        url: "" /*the link or stuff*/
                    }
                ]
            }
        });
    });
});

bot.login(token); 
sudden needle

@dusty warren

dusty warren
dusty warren

i dont know

it works for me

sudden needle

:/

winter mulch

Can I use rpc for my bot?

nimble yarrow

No

winter mulch

okay

surreal pecan
nimble yarrow

Ask discord?

Its just not possible

woven olive

yo what's the difference betting including or omitting scopes?

smoky scroll

Why dont the links work?

buttons : [{ label : "useless button 1", url: "https://somerand.om/website"}, { label : "useless button 2", url: "https://somerand.om/website"}]```
They appear, but the links wont load
pastel trench

They don't for you. Should work if other users click on it

smoky scroll

oh okay.

vale marsh

please can i know what rpc do ?

rotund girder

rich presence for users

karmic jolt

rpc can do more than just rich presence

but that's the most used part of it

solar sentinel

If you want to actually leverage rpc, i.e. change channel focus, listen to voice events, etc, then use discord-rpc

dusty meadow

can we do "Ask to join" with discord-rpc?

solar sentinel

Yes, however your implementation with be fairly neutered given a number of features are whitelist only

dusty meadow

i am trying to do with electron

solar sentinel
dusty meadow

ok ty

vernal bobcat

is it possible to combine discord rpc and the discord js code in 1 file

solar sentinel
solar sentinel

I presume you used the Add it! button for that? If so that's not related to discord-rpc.

You cannot. And not related to the channel topic.

vernal bobcat

is there a button styles? and emojis?

nimble yarrow
zealous sail

ACTIVITY_JOIN_REQUEST won't fire for me for some reason, what am i doing wrong?

const discordRpc = new RPC.Client({ transport: 'ipc' });
discordRpc.login({ clientId }).then(() => {
    win.webContents.send('discord-rpc-ready');

    discordRpc.subscribe('ACTIVITY_JOIN', ({ secret }) => {
        win.webContents.send('discord-rpc-join', secret);
    });
    discordRpc.subscribe('ACTIVITY_SPECTATE', ({ secret }) => {
        win.webContents.send('discord-rpc-spectate', secret);
    });
    discordRpc.subscribe('ACTIVITY_JOIN_REQUEST', user => {
        console.log(user);
        win.webContents.send('discord-rpc-joinRequest', user);
    });
});
cursive dawn

do I need dc installed for rpc?

turbid socket

Yes, otherwise it can't communicate with it and send the data

After all, it communicates with the locally running client, on a localhost, which is only produced by the app itself

lucid moat
smoky scroll

I know that now

D Tombrett already told me

oak bluff
slate perch

RPC is not defined:

const Discord = require("discord.js")
const clientId = 'none';
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('none');
});

client.login({ clientId, scopes });
solar sentinel

Read your code. You are importing discord.js instead of discord-rpc.

slate perch

oh lol

solar sentinel

Likewise, you should be using the transport ipc instead of websocket.
Nor are you defining your clientId.

slate perch

didnt know it had a separate module

TypeError: Cannot read property 'Client' of undefined

const { RPC } = require("discord-rpc")
const clientId = '866475632979476510';
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('874763181933858857');
});

client.login({ clientId, scopes });
solar sentinel

RPC is not a property of the export; dont use a deconstructor on the import

slate perch

code is changed brackets removed

solar sentinel

What is your goal?

slate perch

just display rpc in my profile

solar sentinel

The error is because you are requesting messages.read which requires the OAuth2 parameters

slate perch

ok

clever maple

The buttons wont show up for my

let clientID = "my client id"; // Your clientID from your application - https://discord.com/developers/applications

let statusMsg = [
    {
        details: "Graphic Designer", // The top line of the presence
        state: "Looking For Long Term Clients", // The bottom line of the presence

        // Set either to "" to disable - Will be displayed on image hover
        largeImageHover: "Graphic Designer", // Text on hover for large image
        smallImageHover: "", // Text on hover for small image

        buttons : [
            { label : "Some Of My Work", url: "https://cxgraphics.myportfolio.com" },
            { label : "Join My Discord Shop", url: "discord invite link" }]
        
        }
]

let statusSettings = {
    random: false, // Pick random status messages - Disabling this will cause it to go through the statuses in order
    static: true, // Static status - Will only display the first statusMsg
    delay: 5000, // Milliseconds - Must be above 5000 (Anything below will cause errors!)
}

let timeSettings = {
    enabled: false,
    countdown: { // Displays "00:00:00 Left"
        enabled: false,
        time: 1595003884, // In unix timestamp https://www.epochconverter.com/
    },
    elapsed: { // Displays "00:00 Elapsed"
        enabled: true,

    }
}

let images = { // Your images that you uploaded to your application - "" to disable an image
    large: 'c_logo',
    small: 'c_logo'
}

let logging = {
    ram: true,
    duration: {
        enabled: true,
        format: ' D[d], H[h], m[m], s[s]'
    },
    details: true,
    state: true,
    images: true
}

// Do not change
let instance = true;

// Do not edit/touch this!
module.exports = {
    clientID,
    statusMsg,
    statusSettings,
    timeSettings,
    images,
    logging,
    instance
}```

It all shows but the buttons

That is a different one. I am working on one I can add to my online host so it is online all times instead of when I have my pc on

Idk how it is still on my profile cause I turned it off XD

dusty warren

How do i start a rpc automatic when an aplication starts? For example i want to make a rpc for some programs. I want to start the rpc when the program starts

nimble yarrow
golden marlin

What are the possible fields for the COMPETING type

smoky scroll

Hello. How can I send an invite to my activity like spotify/fortnite?

warped pine
const rpc = require("discord-rpc");
const client = new rpc.Client({
  transport: "ipc",
});
client.on("ready", () => {
  client.request("SET_ACTIVITY", {
    pid: process.pid,
    activity: {
      details: "Support My Bot !",
      assets: {
        large_image: "poluslogo",
        large_text: "Polus Bot",
      },
      buttons: [{
          label: "Invite",
          url: "https://discord.com/oauth2/authorize?client_id=868234843937447958&permissions=868234843937447958&scope=bot",
        },
        {
          label: "Vote",
          url: "https://top.gg/bot/868234843937447958/vote",
        },
      ],
    },
  });
});
client.login({
  clientId: "xxxxxxxxxxxx", // put the client id from the dev portal here
  clientSecret: "xxxxxxxxxxxxxxxxxxxxx", // put the client secret from the dev portal here
});

this is my code for rpc

it works when I host it locally

but doesn't work when I host my bot on a VPS

plz help

pastel trench

It needs to be executed on the same machine as the Discord app

smoky scroll
turbid socket

no

nimble yarrow
smoky scroll
nimble yarrow

No, only pc afaik

smoky scroll
dusty meadow
const client = require('discord-rich-presence')('871730144836976650');

how do i get userid of the person from here?
client.user.id doesnt work

karmic jolt

yeah that package doesn't expose it

you need to use discord-rpc

smoky scroll

what is the instance property in the activity object? i dont really understand what this does

"whether or not the activity is an instanced game session"

whats an "instanced game session"?

maybe its when the rpc is coming from a game?

but then what difference does it make having it true or false

i'll assume it just activates the usage of being able to join parties/lobbies for games

hexed sapphire

I cannot upload any image to the discord assets, any way to still show images then?

hexed sapphire

yeah, I did not know that you have to wait some minutes until they appear correctly

pseudo linden

does anyone know why i get this error?

Error: RPC_CONNECTION_TIMEOUT
    at Timeout._onTimeout (C:\Users\Costin\Desktop\Discord RPC\node_modules\discord-rpc\src\client.js:107:47)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
nimble yarrow
pseudo linden ``` Error: RPC_CONNECTION_TIMEOUT at Timeout._onTimeout (C:\Users\Costin\Des...

• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

pseudo linden

it works now suddenly

dusty warren

and how can i add rpc to an aplication and run it without node

automatic?

lyric sable
dusty warren

Users not have node and they have rpc

nimble yarrow
dusty warren

pepeCoffee

nimble yarrow
nimble yarrow

I'm talking about the package this channel is about dude

dusty warren

ok sorry, thanks

proven gate

rpc is down?

nimble yarrow
ebon sage

???

ebon sage

fuck this shit im writing my own ipc library

smoky scroll

hmm

smoky scroll
dusty meadow
quasi epoch

Where are you supposed to put the timestamp? timestamp: {start: new Date()}
Under the activity code block or the client.request code block

solar sentinel

Within the activity object.

quasi epoch
karmic jolt

it's startTimestamp and endTimestamp

winter mulch

can I use rich presence for myself only,like I am currently doing?

winter mulch

thanks

nimble yarrow

<@&839912195994812420> scammy scam scam 775003323954102292

pseudo linden

how can i change the account my rpc is on?

nimble yarrow
west bane
grand prawn

hello, need some help with rich presents, the pictures have not shown up

@ me responded

nvm

trim timber

can I host rpc with heroku for example ?

pastel trench

No

sour tangle
      const timeout = setTimeout(() => reject(new Error('RPC_CONNECTION_TIMEOUT')), 10e3);
                                              ^
Error: RPC_CONNECTION_TIMEOUT
    at Timeout._onTimeout (D:\Languages\TS\RPC\node_modules\discord-rpc\src\client.js:100:47)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)
smoky scroll

it is possible to change the "PLAYING" activity type to "LISTENING" or "WATCHING"?

solar sentinel

That said, I've been unable to see it work, and it appears unwhitelisted RPC only supports activity type 0 (Playing) and 3 (Watching), although its entirely possible its like buttons where it appears to not work locally but works for others. YMMV

smoky scroll

ok

ty

karmic jolt

rpc doesn't support changing the type, no

you'll just get an api error

ebon sage

if it appears on the wrong account, close all your discord clients, then open the one you want it to appear on first

bronze cloak

guys is it possible set someone s rpc activity with a bot ?

i mean member write &setactivity and bot sets activity

bronze cloak
nimble yarrow

That does not include bots.

bronze cloak

ok tnx

oh another question

bronze cloak
nimble yarrow

You can only set the RPC of a user where it's installed.

And browser isn't supported.

bronze cloak

aha ok

rose bolt

i am getting this error:
UnhandledPromiseRejectionWarning: Error: connection closed

i am using new RPC.Client({ transport: 'ipc' }); not websocket but it still isn't working???

nvm i was using wrong scopes

but now i get this

Error: OAuth2 Error: invalid_request: Missing "redirect_uri" in request.

pastel trench

you need to specify a valid redirect uri if you provided scopes

rose bolt

but could you show me an example?

pastel trench

Mmh ig like .login({ clientId, clientSecret, redirect_uri: "https://www.my-website.com" })

rose bolt

even with redirect uri specidfied it wont work

pastel trench

Btw, are you sure you need scopes?

Or only rpc?

rose bolt

i want to read my messages from this

pastel trench

so you need the secret too

rose bolt

oh really?

pastel trench

Iirc yes

rose bolt

where can i find the secret?

tired linden

2 questions:
What is the fastest you can update the rich presence?
How do you disable the rich presence when you close the game for example

tired linden
nimble yarrow
  1. client.destroy() and/or client.clearActivity()
tired linden

ok

tired linden

Also how do you run the rich presence with having to go to the terminal and type npm init or whatever

nimble yarrow
tired linden

so

cuz this is a mod for a game basically and i would like to start it when you launch the game and turn it off when u close the game

nimble yarrow

game made with what?

tired linden

idk it's cookie clicker on steam x)

it just released yesterday

is there a easy way to figure it out

I see lots of dll files in there

so i don't think it's java script

solar sentinel

If you are wanting to do rich presence for a public game; discord-rpc is likely not the right route for you.

tired linden

ah

solar sentinel

Public RPC is in both a closed private beta and deprecated in favor of the GameSDK- that said, GameSDK is also behind an application (currently closed)

Meaning if you were to use RPC; you'd have to manually add people to the Discord application, and be limited to 50 people.

tired linden

i saw that but i never really understood gameSDK

is there a tutorial on gameSDK?

tired linden

but is there sdk for js?

thanks for links btw

solar sentinel
tired linden

so there is but not official ?

dreamy valley

Any help me

My code

pastel trench

RPC doesn't work on mobile

faint shard

what isrpc

ialso like coding

i want to know too

pls tell

pls pls

i dont undrstandit on google

dreamy valley
nimble yarrow

it can do more than that, but thats what everyone uses it for

faint shard

rich?

meaning you will get a nitro whetheru paid or not?

?

ohhhhhhhhhhh

sorry i understnd it now

thank you

open dune

oh you get it now ok

sick venture
rigid wedge

how can i get someones rich presence's buttons url?, i know how to get the buttons label with presence.activities[1].button

nimble yarrow
sick venture
nimble yarrow

I have no idea.. maybe it does work with browser?
never saw anyone be able to do it in browser yet sus

pastel trench

It's not possible with browser. Discord can't run its localhost using browser

No idea why is it called browser though

clear cipher

must the discord application be opened in order for rpc to work?

pastel trench

Yes

brittle forge

what should i do so that the timestamp works? (c#)

pastel trench

Ehm, is this related to this library?

brittle forge

yes

its rpc

nimble yarrow

@brittle forge this here is about the discord-rpc library for node.js

you are on the completely wrong discord

brittle forge

how i make a timestamp on 0

topaz surge
nimble yarrow
pastel trench
smoky scroll

how i can use rpc?

acoustic grove

v12 or v13?

pastel trench

It's a totally different library

rotund iron

hello, maybe i find my solution here, i have a rich presence, i modified it recently, but ... i can pnly see rich presence on my device xhere the rich presence are launched (my pc) but on my phone, on my other pc, or on the other user ... nothing, i have no errors but do you know if there is a limit on rich presence ?

solar sentinel

Are you expecting one RPC session to work for multiple clients? If so that wont work.

acoustic grove

I think he means that he launched his app on this pc but with other devices and phones they cannot see his rpc

analog portal

aha

this is my code: ```js
const RPC = require("discord-rpc");
const rpc = new RPC.Client({
transport: "ipc"
})

rpc.on("ready", () => {
rpc.setActivity({
details: "Watching Naruto",
state: "Anime Party",
largeImageKey: "nataruto",
startTimestamp: "1",
endTimestamp: "2",
largeImageText: "Naruto",
partyId: "ae488379-351d-4a4f-ad32-2b9b01c91657",
partySize: "1",
partyMax: "1",
joinSecret: "MTI4NzM0OjFpMmhuZToxMjMxMjM",
})

console.log("RPC active");

})

rpc.login({
clientId: "885647582645325864"
}) ```

and this is my error: ```js
PS C:\Users\Fr0g_\Desktop\folder()> node index.js
RPC active
C:\Users\Fr0g_\Desktop\folder()\node_modules\discord-rpc\src\client.js:178
const e = new Error(message.data.message);
^

Error: child "activity" fails because [child "timestamps" fails because [child "start" fails because ["start" must be a number]]]
at RPCClient.onRpcMessage (C:\Users\Fr0g\Desktop\folder()\node_modules\discord-rpc\src\client.js:178:19)
at IPCTransport.emit (node:events:394:28)
at C:\Users\Fr0g_\Desktop\folder()\node_modules\discord-rpc\src\transports\ipc.js:138:18
at decode (C:\Users\Fr0g_\Desktop\folder()\node_modules\discord-rpc\src\transports\ipc.js:92:5)
at Socket.<anonymous> (C:\Users\Fr0g_\Desktop\folder()\node_modules\discord-rpc\src\transports\ipc.js:120:7)
at Socket.emit (node:events:394:28)
at emitReadable_ (node:internal/streams/readable:573:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 4000,
data: {
code: 4000,
message: 'child "activity" fails because [child "timestamps" fails because [child "start" fails because ["start" must be a number]]]'
}
}
PS C:\Users\Fr0g_\Desktop\folder()> ```

sob

cri

nimble yarrow

it's a timestamp overall

analog portal
analog portal

is there a way to upload pictures using the api?

brazen hearth
still escarp

Hi

why i get that error "Could not connect"?

nimble yarrow
still escarp why i get that error "Could not connect"?

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

In short:

  • No Repl.it
  • No RPC for bots
  • RPC has to be run on the same machine the discord app runs on
  • ID to log in is the application id, nothing else
still escarp
nimble yarrow

it only works with the discord application, not the web version

still escarp

so i have to download The application on the laptop ?

nimble yarrow

yes

still escarp
nimble yarrow

• Is your code running on the same machine as the Discord app?
that means that the node.js process has to be on the same device as the discord application

so repl.it for example won't work

WSL is Windows Subsystem for Linux afaik

If you don't know what that means, it's most likely not relevant for you.

still escarp

about the node

its 16

nimble yarrow

okay?

still escarp

is this effects on any thing ?