#archive-rpc-help

21942 messages · Page 20 of 22

nimble yarrow

what?

still escarp

nvm

brazen hearth

the client id is the application id or my id?

nimble yarrow
brazen hearth

okay

west ginkgo

is there a tut for adding buttons to rpc?

nvm figured it out

royal urchin

what does instance mean?

and alos how do u customize the name without changing the name in the dev portal

nimble yarrow
nimble yarrow
minor umbra

djs Adding buttons to your rich presence:
Inside your setActivity call, you can use:

buttons: [ { label: " ", url: " " }, { label: " ", url: " "} ]

You can have up to 2 buttons.
You will not be able to press these buttons on your own account, so dont freak out when something doesn't pop up when you click it.

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

dreamy valley

Can I use rpc on Android?

nimble yarrow
dreamy valley
pastel trench

They don't work for you. Try it with another device/account or ask a friend to test them

viscid shale

oh

ill ask a friend

ah it works

thx

pastel trench

Np

robust halo

how make my bot online 24/7 in vscode

nimble yarrow
gentle ginkgo
    at Timeout._onTimeout (C:\Users\camyw\Desktop\new-rp-bot-js\node_modules\discord-rpc\src\client.js:100:47)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7)

i get this in my console everytime i start my website up, here is my rpc code

    rpc.setActivity({
        details: `Roleplay Bot Dashboard`,
        startTimestamp,
        largeImageKey: 'bot',
        largeImageText: 'Roleplay Bot',
        buttons: [
            {
                label: 'Invite Link',
                url: '',
            },
            { label: 'Support Server', url: '' },
        ],
    });
}

rpc.on('ready', () => {
    setActivity();
    setInterval(() => {
        setActivity();
    }, 15e3);
});

rpc.login({ clientId }).catch(console.error);
nimble yarrow

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

boreal topaz

Okay well, I'm a tad bit confused now. The code is producing no errors, it logs everything it's supposed to, and yet the RPC doesn't show up. I've ensured all my settings are correct, and I am using the Desktop App on the same machine. Can anyone help?

https://pastebin.com/8RJ6qzXd

boreal topaz

^^^ Nevermind, I (somehow) found a way to get what I wanted to work.

snow plank

Yo, I am having some trouble with RPC in my project.
I have used this library before in the past, and have it working perfectly fine, and still works perfectly fine in my old project, but for some reason in my new project it doesn't even let it get imported without giving a fatal error.

My old project was with Electron, without any special boilerplate. It worked just fine

The new project is ALSO Electron, but this time using Electron-forge, so it uses webpack under the hood, which is where it's giving me the error (See screenshot).
It happens even if I just import it. Has anybody run into this before? Googling it didn't bring me much success

I've tried to install the exact same version as my last project, but I get the same error regardless.
I know about the "Websocket needs to be whitelisted by Discord" but I am not using the websocket transport, and I had it working no problem whatsoever in my prior project

Any help would be much appreciated. If you need the error in text format just @ me

smoky scroll

is an syntax eror in your code

error*

snow plank
viscid shale

How do I listen for voice channel events?

boreal topaz
snow plank
boreal topaz

huh

snow plank

It's really odd, I have only had this problem happen in this project, and it being webpack that complains about it

I found out this code here, 48, i added (error) after catch and that seems to have fixed it, somehow?

Perhaps it should be added to the official to fix the webpack error

Seems like webpack dislikes a catch the parameters

snow plank

If anyone is curious or needs this issue fixed themselves. It needs to be done here.
node_modules\discord-rpc\src\transports\websocket.js
Line 48, change

} catch {}

to this

} catch (e) {}

It fixed the problem for me, makes it work with webpack in Electron-forge generated code

Of course this will fuck up the package if needed to be downloaded later, so I suggest putting it outside of your node_modules and part of your main code., as downloading it from npm again will just give the old not working code into the project again

tawny tulip

how to change title

solar sentinel

Change your application name.

pastel trench
snow plank
nimble yarrow
dreamy verge

oh sorry

polar egret

im new to rpc, is there any tutorials or doccumentations about connecting rich presence from application to my account? tks!

solar sentinel

Make an application (same way you make a bot); name it how you want the rich presence to appear, then copy paste the example and fill it in with your applicationId + what you want it to say

polar egret
solar sentinel

Yes. I'd recommend looking at the rich presence visualizer in the application settings and playing with that.

solar sentinel
polar egret
wild copper

hi !
I try to get the application I use to make my RPC but rpc.application is null... why ?

river edge
nimble yarrow
solar sentinel
pastel trench

Actually I don't see what's the problem. Both work ok and no change is needed as Discord didn't add new features about RPC.

river edge
solar sentinel
glad shuttle

how to host My discord rpc 24/7

nimble yarrow
glad shuttle
nimble yarrow

Then there is no way.
The discord application needs to run 24/7 with the script

glad shuttle

🥶

ok

snow plank
glad shuttle

😳

how

snow plank

What kind of app is it?

pastel trench

RPC apps need to be hosted in the same machine as the Discord app and also require the app open and working

solar sentinel
glad shuttle how

Run a server/VM with a desktop OS and then you are literally just offloading who/what has to be running 24/7.

Raspberry Pis would be a prime example

rose bolt

if you loginto discord.py using a usertoken you can do it, you dont need to have discord app open. but im pretty sure tho that this is against TOS

karmic jolt
noble hawk

Any examples for browser rpc?

Not the browser client... but the RPC will start when you open the webpage?

nimble yarrow
noble hawk

Just the normal desktop client

But the rpc will start when the user opens the webpage and authorizes

quick imp

uhh is it normal that the buttons in my rpc dont work?

even tho they are linked

rotund girder
quick imp

ah right

ty

can somebody tell me why is the doc to discord-rpc in discord.js.org so wierd and without too much detail

vocal tide

How do you add buttons to an rpc?

nimble yarrow
vocal tide

thx

frosty pumice

any way to use this for browser??

nimble yarrow
frosty pumice
wispy glade

what is this place?

glad shuttle

read pins

rose bolt
strange shell

Hey I have this error

by doing that: const bot = new RPC.Client({ transport: "ipc" })

strange shell

thx

restive viper

how to use it?

nimble yarrow

There is an example in the channel topic.

pine mauve

does anyone know how to use discord rpc? i want to make something that can give me a rich presence, but my code isn't working currently. the code runs and "Done" is printed out, but there is no change in my profile

const RPC = require("discord-rpc");
const clientId = require('./config/keys').clientId;
const client = new RPC.Client({ transport: "ipc" });

const activity = {
    details: "I'm doing nothing.",
    state: 'Deep Thinking',
    startTimestamp: new Date()
}

client.on("ready", () => {
    client.setActivity(activity);
    console.log("Done.");
})

client.login({ clientId });
smoky scroll

tf is an rpc

pine mauve

rich presence client i think

supposed to do stuff with your user basically, it's like that one vscode extension that shows what file youre editing

basically shows games youre playing, but im just using it for fun

pastel trench

Uhm?

nimble yarrow

nice, search somewhere else

atomic sparrow

I don't understand how the security of RPC works, can someone just set my RPC whenever they like? The only thing I need to do to set my rpc is specify my bot ID.

smoky scroll

Unless they get access to your email/password or account token which is used to create a websocket connection to Discord, they can't get RPC on your presence.

RPC works locally. This means that the RPC client (in this case, discord.js/rpc) communicates with the Discord client (in this case, discord.com/app, desktop clients, mobile apps, etc). The Discord client then communicates to the Discord API saying "hey, this person want their presence to be XYZ, and here is my email/password or account token to prove that my end user is who they claim to be".

atomic sparrow
smoky scroll

I can see it, because Discord is communicating your RPC info to my client, and everyone else's

atomic sparrow

Huh but how does discord know Im the one sending the RPC? Does it check IP address or something?

smoky scroll
atomic sparrow

Ahhh, so if I run it on my server it won't work. Okay thanks

nimble yarrow
smoky scroll
cursive pebble

does RPC work if i am running linux

nimble yarrow
cursive pebble

oh weird

or does it have to be mine?

i also tried websocket for transport

and it just errors

nimble yarrow
cursive pebble

im directly running arch linux

no virtualization

nimble yarrow

do you have discord form the snap store?

cursive pebble

uh i forgot

lmao

lemme check

i dont belive so

nimble yarrow

well I dont see anything wrong

cursive pebble

nope

it isnt installed via snap

smoky scroll
tribal snow

<@&839912195994812420> ^

cold fox

I get the error
Could not connect

var rpc = require("discord-rpc")
const client = new rpc.Client({ transport: 'ipc' })
client.on('ready', () => {
client.request('SET_ACTIVITY', {
pid: process.pid,
activity : {
details : ".",
assets : {
large_image : "sawallhabotlogo",
large_text : "Test"
},
buttons : [{label : "Support Server" , url : "https://discord.com/"},{label : "Invite",url : "https://discord.com/"}]
}
})
})
client.login({ clientId : "MyID" }).catch(console.error); 

Does repl it the reason?

And if it. What mobile can do with rpc. I mean its possible to have rpc in mobile? Bcs my friend use same code and its work but he uses vscode

nimble yarrow
cold fox

Ok thx

nimble yarrow

@foggy tundra I hope you just got the wrong channel

foggy tundra
smoky scroll

how i can use rpc mobile?

pastel trench

It's not supported on mobile

smoky scroll

im trying to add buttons right now, they dont seem to show

dark granite
pine mauve

Does RPC work on mac

smoky scroll

yes

smoky scroll
pine mauve

👍

muted kiln

I'm getting a connection error, it doesn't wanna start

can anyone help

nimble yarrow
muted kiln I'm getting a connection error, it doesn't wanna start

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

muted kiln
thick grove

What is RPC

User-Bot?

nimble yarrow
dusk compass

Custom Status

smoky scroll
Error: connection closed
    at IPCTransport.<anonymous> (E:\node_modules\discord-rpc\src\client.js:111:16)
    at Object.onceWrapper (events.js:520:26)
    at IPCTransport.emit (events.js:400:28)
    at E:\node_modules\discord-rpc\src\transports\ipc.js:141:18
    at decode (E:\node_modules\discord-rpc\src\transports\ipc.js:92:5)
    at Socket.<anonymous> (E:\node_modules\discord-rpc\src\transports\ipc.js:120:7)
    at Socket.emit (events.js:400:28)
    at emitReadable_ (internal/streams/readable.js:550:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

what do i do

ive done everything

client.on('ready', () => {
                                client.request('SET_ACTIVITY', {
                                    pid: process.pid,
                                    activity: {
                                        details: "Just chilling",
                                        state: `DM me!.`,
                                        assets: {
                                            large_image: "large_image",
                                            large_text: "yooo",
                                            small_image: "valid",
                                            small_text: "this you?",
                                        },
                                        buttons: [{
                                            label: "My Favourite Song!",
                                            url: "https://www.youtube.com/watch?v=S9bCLPwzSC0"
                                        }]
                                    }
                                })
                            })

thats my code

is this wrong @lyric sable

smoky scroll

i fixed that

but now

Error: OAuth2 Authorization Error: Unknown Error
    at RPCClient._onRpcMessage (E:\node_modules\discord-rpc\src\client.js:178:19)
    at IPCTransport.emit (events.js:400:28)
    at E:\node_modules\discord-rpc\src\transports\ipc.js:138:18
    at decode (E:\node_modules\discord-rpc\src\transports\ipc.js:92:5)
    at Socket.<anonymous> (E:\node_modules\discord-rpc\src\transports\ipc.js:120:7)
    at Socket.emit (events.js:400:28)
    at emitReadable_ (internal/streams/readable.js:550:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  code: 5000,
  data: { code: 5000, message: 'OAuth2 Authorization Error: Unknown Error' }

fixed that

now it timeout

Error: RPC_CONNECTION_TIMEOUT
    at Timeout._onTimeout (E:\node_modules\discord-rpc\src\client.js:100:47)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)

bruh

just had to restart Discord

nimble yarrow

Bruh

smoky scroll

does messages.read rpc work correctly for anyone? I'm able to authenticate/authorize with the scope, but I get message events really really slowly if at all

either that or rpc.notifications.read is what I'm trying to get working

I haven't been able to get any events at all from notifications.read

pulsar crest

the rpc.api scope has been replaced by what?

zinc vortex

what is rpc

smoky scroll

pins

stands for rich presence client

smoky scroll

after some testing, seems like messages.read and rpc.notifications.read are just broken in @discordjs/rpc

the socket gets the events correctly and I can see them if I hack the lib to add debug logging, but they just never get dispatched

smoky scroll

o

shy helmBOT
lyric sable

how can we connect discord-rpc with vsc to work with? like i want to add custom images in rpc which i don't think is possible with the official one

spring dune
lyric sable
spring dune

RPC must be run on the same environment as the Client you wish the RPC to be displayed on.

So yes, everyone needs to download your application to have it.

Oh I've misunderstood the question, you're asking about the vsc discord rich-presence plugin

Dunno about customizing that as I use Jetbrains products LUL

nimble yarrow
smoky scroll

Hello,

I have a problem with my RPC, I don't see the image in my profile.
Can you help me please ?

Here is my code :

client.on("ready", () => {
client.request("SET_ACTIVITY", {
  pid: process.pid,
  activity : {
  details : "A MSP retro private server, like in 2010.",
  assets : {
  large_image : "msp_retro_pdp",
  },
  buttons : [{
    label : "🎮 Play" ,
    url : "link here"
  }, {
  label : "📢 Support server",
  url : "link here"
  }]
}});

And I have uploaded my assets :

smoky scroll

No image here :/

If someone has the solution please ping me!

Idk if it's the Discord cache the problem, but I think not

nimble yarrow

when did you add the pics

smoky scroll

5 minutes

nimble yarrow

they take time to show

smoky scroll

and I have deleted and re upload

and change the name

I don't understand why I don't see

nimble yarrow

they take time to show

smoky scroll

AHHHHH done it's work

it's just cloudflare maybe

thanks

opal marten
details: "For 1 week \n Developing Pixel Bot"
``` the \n doesnt work

how do I start from a new line

nimble yarrow
opal marten
nimble yarrow

you can only have state and details, each one line

smoky scroll

that’ll let you use multi line out of the box, however be ware of some weird formatting issues

sly topaz

Why do they use client.selectVoiceChannel('81384788862181376'); ?

smoky scroll

whats the ratelimtit for changing rpc status?

i wanna make a clock but idk the ratelimits 😂

karmic jolt

it updates every 15 seconds but discord handles rpc ratelimits for you anyway

smoky scroll

alr ty, so i can just make a loop to change it every 15 sec and it should work?

karmic jolt

sure

for you it will update instantly every time, but for others the 15 seconds apply

smoky scroll

ah alright

so like if i start or change it it needs to have 15 seconds before others can see it?

karmic jolt

only if the previous change was less than 15 seconds ago

else it will update instantly too

smoky scroll

ah okay

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

(async () => {
    setInterval(() => {

        let date_time = new Date();

        let hours = date_time.getHours();
        let minutes = date_time.getMinutes();
        let seconds = date_time.getSeconds();

        client.on('ready', async () => {
            await client.setActivity({
                buttons: [{ label: "RPC Time!", url: "..." }],
                details: `Current time: ${hours}:${minutes}:${seconds}`,
                largeImageKey: "clock",
                largeImageText: `Current time: ${hours}:${minutes}:${seconds}`
            }).catch(err => console.log(err));
    
            console.log("Discord Rich Presence has been enabled.");
        });
    }, 1500)
    await client.login({ clientId: "..." }).catch(console.error);
})();

gives me this error now: js PS C:\Users\Marni\Desktop\RPCTime> node --trace-warnings .\main.js (node:24172) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 ready listeners added to [RPCClient]. Use emitter.setMaxListeners() to increase limit at _addListener (node:events:465:17) at RPCClient.addListener (node:events:487:10) at Timeout._onTimeout (C:\Users\Marni\Desktop\RPCTime\main.js:62:16) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7)

pastel trench

Well, yeah. You should use the setInterval in the client.on, not the inverse lol

smoky scroll

jesus i'm so dumb 😂 thanks xD

tulip aspen

how to fix

nimble yarrow
tulip aspen

I need help

nimble yarrow

not sure since when javascript is go

tulip aspen

don't you dare give me the attitude

nimble yarrow
tulip aspen

??

minor umbra

kindly keep whatever this bait and attitude shtick is out of this place, thank you

wicked ravine

Hey guys, is there a cooldown regarding client logins when using RPC? I want to give my users the ability to (de)activate our softwares RPC, but once client.destroy() is used, the RPC doesn't show up when client.login() is called. Can someone tell me what I'm doing wrong?

karmic jolt

you should create new client instances every time

after calling .destroy() it's not meant to be used to login again

wicked ravine
wicked ravine
karmic jolt

new Client(...) creates a new instance

wicked ravine

Makes sense, thanks 🙂

limpid skiff

What's RPC? Sorry if this sounds stupid.

smoky scroll

Rich presence client, read pins for more info

cloud osprey

Btw is there a way to have it 24/7

I think its against tos?

lyric sable
cloud osprey

Ye lol

sand sapphire
solar sentinel

Have fun paying for the resources to host a desktop OS for just a discord status

lyric sable
sand sapphire

And i know that vsc isn't discord app XD

But you can run RPC inside vsc -_-

smoky scroll

At that point just emulate you're on a Discord client in a VPS with REST requests and communicate with websockets

carmine mica
unique forge

is there a package for discord rpc?

or how would i declare something like this const presence = new Presence({

nimble yarrow
safe granite

How to change the RPC activity type?

night oyster

how can i clear activity

client.clearActivity() not working

i want stop it or some like clear it but i cant find any method

elfin tree

Where is the full doc ?
Because I didn't find it ;-;

supple ibex

what's clientId?

is it my userid or what

elfin tree
smoky scroll

can someone help me no matter what i do i get this error, it used to work few days ago without any problems i didnt change anything since then and neither did i change anything in the discord app im using

pine mauve

I dropped a project for a month related to rich presence because it wasn’t working for me and then I just turned on showing activity status and it worked lmao

tight leaf

Hello guys!

Can I add this rpc in my bot's activity?

rotund girder

No, rich presence is only supported for normal users

tight leaf

Oo

opal marten

can I host the rpc outside of my comp?

opal marten

ha now way Im doing that

smoky scroll

how to add buttons in rpc status

nimble yarrow

<@&839912195994812420> thats... scam?

cinder spire
smoky scroll

hello

nimble yarrow
smoky scroll

can you help me

nimble yarrow
smoky scroll

okay

when i try to run my rpc file

it says

Error: Could not connect
at Socket.onerror (/data/data/com.termux/files/home/a/node_modules/discord-rpc/src/transports/ipc.js:32:16)

nimble yarrow

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

smoky scroll

alr ipc

hollow mural
snow dust

How can i make a button like the MEE6?

nimble yarrow
hollow mural

so I'm subbing to voice channel change events and seems the event fires twice for some reason. Can anyone else confirm this is intended or reproducible?

mvp code:

const RPC = require("discord-rpc");
const client = new RPC.Client({ transport: "ipc" });
const clientId = "redacted";
const accessToken = "redacted";

client.on("ready", () => {
  console.log("Authed for user", client.user.username);
  client.subscribe("VOICE_CHANNEL_SELECT");
});

client.on("VOICE_CHANNEL_SELECT", channel => {
  console.log(channel.channel_id);
});

// Log in to RPC with access token
client.login({
  clientId,
  scopes: ["rpc"],
  prompt: "none",
  accessToken
});
bronze tree

I'm using this code:

        const RPC = require('discord-rpc')
        const Activitys = {
            detail: "I'm testing!",
            assets: {
                large_image: "image_1",
                large_text: "My name is jeff"
            },
            buttons: [
                {
                    "label": "Check this!",
                    "url": "youtube.com"
                }
            ],
            timestamps: {start: Date.now()},
            instance: true
        }
        client.on("ready", ()=> {
            client.request("SET_ACTIVITY", {pid: process.pid, activity: Activitys})
            console.log("RichPresenceWorked!")
        })

It does nothing

pastel trench

Well, if you don't login...

bronze tree

its my ready.js

I have the login in a different channel

or do I need to add client.login({ clientId: "123456789"})

smoky scroll

If you have a Json with all of that information then at the top do:

const { token } = require('./config.json')

And at the bottom:

client.login(token)

If it works let me know.

nimble yarrow
nimble yarrow
dense summit

Does anyone know how to add "invite people" option?

lyric sable
spring dune

I wonder what tutorial people use when I see client.request('SET_ACTIVITY') when we have a completely fine method for it. client.setActivity()

brittle nexus

Rich Presence in Web version?

I heard it's possible with sdk

nimble yarrow

not with discord-rpc.

brittle nexus
nimble yarrow
broken compass
(node:25677) UnhandledPromiseRejectionWarning: Error: Could not connect
    at Socket.onerror (/usr/lib/ElectronApp/resources/app/node_modules/discord-rpc/src/transports/ipc.js:32:16)
    at Object.onceWrapper (events.js:422:26)
    at Socket.emit (events.js:315:20)
    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)

It's not working for me on Linux.

rose bobcat
nimble yarrow

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

broken compass
nimble yarrow

install it from your distro's package repository or directly from the Discord website.

broken compass

odd, what makes it not work with flatpak?

nimble yarrow

No idea

Most likely the same thing that makes it not work with snap store xD

karmic jolt

anyway, you could try if it works with the rpmfusion version instead

broken compass

there were reasons I didn't use the discord rpm

but I forget why

karmic jolt

ah

broken compass

meh I can try it again, that was mainly when I was still setting things up in my system

ah right, you need to launch it with --no-sandbox for some reason. but yeah the rpc does work now.

¯_(ツ)_/¯

opal marten
await client.setActivity({ 
            buttons: [{ label: "My Bot", url: "https://pixelpasta.github.io/Bot.html" }, { label: "Minecraft SMP", url: "invite" } ],
            details: "File: Time_Trial.js",
            state: "Workspace: Arcade Racing Pro",
            largeImageKey: "js",
           startTimestamp: 0,
            largeImageText: "I like Tacos"
        }).catch(err => console.log(err));
``` Ik startTimestamp is wrong but how do I fix it?
lyric sable

updating the activity detail/text part according to api rate limit may work?

solar sentinel

You need to provide an endTimestamp at some point in the future; play with the rich presence visualizer in the application settings on https://discord.dev

nova iron

Hi! Is there a way to make a "progress bar" like spotify has in rpc?

karmic jolt

no there's not

the closest you'd get to that would be a countdown

solar sentinel

The same goes for stuff like Twitters image embeds or Spotify's listen along embed

rose bolt
plush coyote

^ can anyone show an example of that please?

rose bolt

@plush coyote

plush coyote

thx

how do you implement this with discord.js?

nimble yarrow

you dont

rose bolt

lol yeah

nimble yarrow

this has nothing to do with djs

rose bolt
plush coyote
rose bolt

that lib tho is made by the djs team

rose bolt
plush coyote

thank you 😊

opal marten

how long does it take for assets to show up after upload

solid vortex

normally instant. But you may need to clear your browser cache by reloading with ctrl + F5

rose bolt
solid vortex

Oh I looked in the completely wrong discord and thought this was about something else 😅 I’m sorry for the inconvenience

topaz horizon

https://github.com/discordjs/rpc
do I need to apply for anything special to use this, or just get the scopes on my oauth2 url?
i thought you had to get special permission for this

nimble yarrow

see channel description

burnt jungle
nimble yarrow

a bit more than that, but yes

burnt jungle

I’ve been looking for something like that for ages

remote drift

does anyone know a portfolio maker

smoky scroll
simple hound

is it possible to show browser ram usage in rpc?

red wraith
fading hedge

you wouldnt even need to interact with the browser

get a list of system processes, and just find the process(es) of the browser and there is probably some sort of function in one of the builtin modules to get ram usage of a specific process

smoky scroll
Error: Could not connect
    at Socket.onerror (/root/RPC/node_modules/discord-rpc/src/transports/ipc.js:32:16)```

Can anyone help me?
nimble yarrow
smoky scroll ```js Error: Could not connect at Socket.onerror (/root/RPC/node_modules/dis...

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

nova iron
karmic jolt

you can't change the type via rpc

nova iron

uhm... is there a way to do it via js then?

karmic jolt

only for bot instances

viral narwhal

anyone who knows how to make a RPC for a app in windows?

wispy anchor

Is it evem possible to make a rpc with the uptime? Like:

Uptime
Last Restart since
00:00 elapsed```

Pls ping me btw

left fjord

bots cannot have rpc

sturdy gorge

how does RPC differ from "self-botting" ?

turbid socket

RPC is basically a transfer of data from your Discord client to wherever your origin is (your program, essentially), it can do a couple of things like connect to a voice channel, list guilds IIRC, etc. the most basic things (https://discord.com/developers/docs/topics/rpc#commands-and-events-rpc-commands). RPC in this context is popular for allowing you to set your activity legally. what's the difference then? account automation is when either use the API with your account token to do any API call or connect to the WebSocket server of Discord to function like a normal account in a Discord app (say, for example, desktop), because Discord supposedly is the one that logs you in, sends a message or most things you can do in the user interface

keen venture

what different between login with ({ transport: 'websocket' })
and login with ({ transport: 'ipc' }) ?

spring dune

websocket is whitelisted, you have to apply for that from Discord.
ipc is exposed so you can use that without applying ^^

warm widget

literally no similiarity in them

sturdy gorge

yuh just making sure yea

smoky scroll

rpc for android

pastel trench

Nop

willow lark

this my code https://sourceb.in/v4lQiug5q2
but the problem is im not able to get the button to work. the button appears, but when i click nothing happens

oh wait, is it like i cant click my own buttons ?

oh yes it is lol

pastel trench

Yep

slate lichen

I want to make my own Discord RPC client without any plugins

directly via API

i can't learn anything from docs

How do I?

willow lark

works on desktop client as well

its only that u cant click ur own button

so u can make an alt acc and click it with too

ahh isee

yea that works too

nimble yarrow
slate lichen

bruh

pastel trench

@raven ember can you please-

still lynx

uh is rpc against tos?

warm radish

no

bitter kettle

then i think it is

still lynx

?

bitter kettle

not sure

havent touched rpc

nimble yarrow
brittle nexus

how to use rpc without discord client?

just with node

nimble yarrow
pastel trench

Is discord-rpc supposed to work only when a nodejs process is available? I'm trying it in a React app, but it totally doesn't work and I just keep getting lots of errors...
Firstly, I received an error from webpack saying that it's not able to compile the 'timers' module, then, after removing it from the discord-rpc, it successfully compiled but I receive a lot of runtime errors, like process is not defined.
So, is this package supposed to not work with something like a webpage (I tried because I saw "browser example" in the README...)?

pastel trench

Well, now there is another problem thinKappa
I keep getting "Connection closed" if I use "websocket" as transport, as shown in the example, and something like "o.createConnection is not a function" if I use "ipc"

I've heard that to use "websocket" we should be whitelisted by Discord... So there's no way? 😂

nimble yarrow

The RPC needs to be hosted on a nodejs app

and yes, websocket is whitelisted

see pins

pastel trench

Ok, thanks for the reply!

brittle nexus
left fjord

Then you're out of luck. Whatever you write will have to connect to rpc server running in the discord app.

And since websocket is whitelisted, you can only use IPC, which means that said discord app has to run next to your rpc stuff

obsidian flax

when I try to login the client, it immediately crashes with this error: ```js
[dirname]\node_modules\discord-rpc\src\transports\ipc.js:32
reject(new Error('Could not connect'));
^

Error: Could not connect```

transport is set to IPC, and the client ID exists

nimble yarrow
obsidian flax when I try to login the client, it immediately crashes with this error: ```js [d...

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

obsidian flax
fair marlin

Change the Activity Type of the user rich presence(Playing to Listening)

pastel trench

It's not currently supported by Discord AFAIK

zinc sleet
umbral cargo

hi

empty geyser

How to read user's rich presence?

gilded cypress

@verbal timber

tiny talon

What transport should I choose?
What are the cons and pros?

nimble yarrow
tiny talon

What are the differences?

nimble yarrow

One you can use, one you cant

smoky python

is there any good tutorial on rpc?

solar sentinel

The provided code snippet in the npm package should cover what you need.

lime light

Hello, I want to use rpc to mute my self. But first is rpc deprecated in favour for the game-sdk ? And how do I mute myself?

winged sun

wht is rpc

smoky scroll

A rich presence client for discord

solar sentinel
smoky scroll

im saying this because if you dont find anything so you can use this xd

left fjord

that's not entirely useful, as that shortcut only works when your discord is in focus. For that to not be a problem, you'd have to create your own toggle mute keyboard shortcut.
but even then those are for manual use, where rpc allows to do that programmatically

naive plume

help reject(new Error('Could not connect'));

nimble yarrow
naive plume help `reject(new Error('Could not connect'));`

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

stone stirrup

What is this channel

fallow bay
nimble yarrow

does nobody read the channel description? whatthefuck

left fjord

Or any messages at all

wooden dove

what is RPCLoginOptions.accessToken actually used for

silk anchor

Can I use RPC On discord web ?

smoky scroll

Can you use RPC without having discord client open in the background? (Any way)

pastel trench

No

solar sentinel

Considering that it needs to transmit data via IPC locally, you likely have Discord running in the background.

urban basin

Hello i have a problem because, my button is not working. ```js
const RPC = require("discord-rpc");
const rpc = new RPC.Client({
transport: "ipc"
});
const Gamedig = require('gamedig')
let date = new Date();

rpc.setActivity({
details: any,
state: any,
largeImageKey: "any",
smallImageText: 'any',
smallImageKey: '"',
startTimestamp: date,
buttons: [{ label: 'Discord', url: 'https://discord.gg/MyServerDiscord' }],
largeImageText: "any"
});

As if I click on a button and nothing happens ..

nimble yarrow
urban basin

My friend clicked and it doesn't work

nimble yarrow

Then you probably banned your friend from your discord, I'm telling you, it works.

The button wouldn't even show up if its not working.

urban basin

Sure

Error: Failed all 1 attempts
    at QueryRunner.run (C:\Users\kuba3\Downloads\MTA-RPC\node_modules\gamedig\lib\QueryRunner.js:95:21)
    at async Gamedig.query (C:\Users\kuba3\Downloads\MTA-RPC\node_modules\gamedig\lib\index.js:11:16)
    at async Function.query (C:\Users\kuba3\Downloads\MTA-RPC\node_modules\gamedig\lib\index.js:19:16)
Attempt #1 - Port=22126 Retry=0:

What

nimble yarrow

not related to rpc

cold lichen
urban basin

Nvm my bad, is working

cold lichen

Okay.

somber ivy

is there anyway to automaticly get user's id for discord-rpc?

rose bolt

can the rpc use any other type for activities? rn its just 0. i want to be able to use type 3

karmic jolt

you can't change the type via rpc, no

rose bolt
karmic jolt

only through the bot gateway

rose bolt
cobalt stone

connection closed? anyone know why?

analog portal

why was discord rpc deprecated anyway, is there anyway to use game-sdk with javascript?

analog portal

How would you remove or reset someones RPC ?

nimble yarrow
analog portal

you can see others

if i made an app

with rpc

and it has an activity, others can see it. aslong as their in the beta tester thing in my discord dev application

analog portal

and its a rich presence client i think

pastel trench

It's a Remote Procedure Call.

analog portal

either way

is there any way to clear a rich presence/activity

from a user

pastel trench
chilly torrent

how to change button style?

honest palm

Why did I get this Error?

TypeError: Cannot read properties of null (reading 'write')```
nimble yarrow
analog portal
pallid silo

can we set rpc on bots too ?

nimble yarrow

no

honest palm
nimble yarrow code?

I have a new Code, with a new Error:
Error: connection closed

Code:

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

rpc.on("ready", () => {
    rpc.setActivity({
        details: "details",
        state: "state",
        largeImageKey: "testImg",
        smallImageKey: "testImg",
        largeImageText: "test",
        smallImageText: "test",
        startTimestamp: new Date(),
        buttons: [
            {
            'label': "test",
            'url': "test.de"
            }
        ]
    })
})

rpc.login({
    clientId: "926602498251325522"
})```
nimble yarrow
honest palm I have a new Code, with a new Error: ```Error: connection closed``` Code: ```js...

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

your id is wrong

honest palm

lol

Thanks, it works! 😄

rustic thistle

Is it possible to change the style of the button

nimble yarrow
rustic thistle

I have question

if i use the clientId of my main bot

will the RPC and discordjsv13 work

?

together?

nimble yarrow

that are two unrelated things

smoky scroll

L

rustic thistle

Thx

smoky scroll
elder python

Class constructor RPCClient cannot be invoked without 'new'
I get this error even though i use new

pastel trench

Can you show your code?

elder python
const RPC = require("discord-rpc")

const rpc = new RPC.Client({
    transport: "ipc"
})

rpc.on("ready", () => {
    rpc.setActivity({
        details: "details",
        state: "state",
        largeImageKey: "testImg",
        smallImageKey: "testImg",
        largeImageText: "test",
        smallImageText: "test",
        startTimestamp: new Date(),
        buttons: [
            {
            'label': "test",
            'url': "test.com"
            }
        ]
    })
})

rpc.login({
    clientId: "932513153554743316"
})
pastel trench

Is there the possibility that you didn't save the file lol

elder python

nope, i figured it might be something to do with cached files. So i shifted the code 1 line down to check if the error message corresponds

it did

so there must be something else at play

elder python

any idea why its messed up?

elder python

thats the entire error

pastel trench

Where... Are you using it

The code you provided above works fine for me

elder python

yes in a standard node environment it works fine, but im trying to use it in a electron app

ember bane
elder python
cerulean matrix

hello I have a question how to create a party with the discord-rpc lib ?

mystic yacht

hi guys

i tried to use rpc to set user text channel but

i've this error ```js
body: { redirect_uri: [ 'Not a well formed URL.' ] }

Error: 400
    at async RPCClient.authorize (D:\Developpement\NodeJS\Discord RPC\node_modules\discord-rpc\src\client.js:215:22)
    at async RPCClient.login (D:\Developpement\NodeJS\Discord RPC\node_modules\discord-rpc\src\client.js:143:21) {
  body: { redirect_uri: [ 'Not a well formed URL.' ] }
}

anyone can help me

my code

const RPC = require("discord-rpc")

const rpc = new RPC.Client({
    transport: "ipc"
})

rpc.on("ready", async () => {
    await rpc.selectTextChannel("sussybaka", 5000)
})

rpc.login({
    clientId: "sus",
    scopes: ["rpc"] // <-- need this 
})
pastel trench

You need to pass a redirect uri (one listed in your application redirect URIs) in the login method

Not sure if passing an empty string works the same

burnt cloud

Like this?

pastel trench

It's called redirectUrl and should be listed in the oauth2 section of your application page in the developer portal, like this:

burnt cloud

yup! Thank you

shell zephyr

I have this whenever I try to invite a channel/person to play

RPC Version: 4.0.1

burnt cloud
pastel trench It's called `redirectUrl` and should be listed in the oauth2 section of your app...
const rpcClient = new discordRPC.Client({ transport: "ipc" });
rpcClient.on("ready", async () => {
  await rpcClient.setActivity({
    buttons: [{ label: "Website", url: "https://moodybot.tk/" }],
    details: "Moody. The new way to manage",
    largeImageKey: "rpc_icon",
    largeImageText: "Beta Released!",
  });
  logger.info("RPC Status Ready!");
});
rpcClient.login({ clientId: "896042594210037810", scopes: ["rpc"], redirectUrl: "https://moodybot.tk/" })```

Could not connect

pastel trench

Do you have your discord app open?

Not in the browser

burnt cloud

Why would I need that to be open to have a rich presence on my bot?

pastel trench

It's... Not for your bot?

@burnt cloud

burnt cloud

I saw someone using it though??

Wait nvm

Welp thanks

limpid echo

Hello guys,

I was thinking of making a thing that displays the music that I'm currently playing on discord as an activity, I use Apple Music (iTunes app on windows). Is setting your own activity against the self bot rule in discord TOS? If no how could I even update my own user activity and update it every second. And would it be possible to replicate the progress bar seen for spotify users?

(Unrelated to discord, but is to my little project how could I fetch only the music being played in the Windows iTunes app)

nimble yarrow
limpid echo

Hello does anyone have good examples to get started with rpc bc i seems a bit dry on information

nimble yarrow
limpid echo
limpid echo
karmic jolt

it's the id of the application that you want the rpc to be for

limpid echo
karmic jolt

it does that automatically

it connects to the account that's currently logged in on that device

limpid echo

alright nice thx

tired thicket

If I use custom RPC did I will get banned from discord?

pastel trench

What? RPC was made by discord for discord... Not sure what you mean with "custom"

tired thicket
pastel trench

Uhm, I don't think it's against Discord TOS to put a server invite in the activity although I'm not really sure

tired thicket
tame mauve

How do I set rich presence on my bot with images, buttons etc...?

karmic jolt

you can't use rpc on a bot

it's for users only

tame mauve

Ok

shell zephyr
tribal silo

does rpc not have ts typings?

nvm

pastel trench

It does

still lynx

is this safe

nimble yarrow
still lynx
nimble yarrow

rpc isn't against tos

so

still lynx
nimble yarrow

idk, can you?

karmic jolt

yes you can

nimble yarrow
smoky scroll

bots can run rpc?

smoky scroll

why image not working?

nimble yarrow
nimble yarrow
dense summit

Is there any way to stop displaingy Rich Presence on the user with the discord-rpc

smoky scroll

Is there a guide or something for making a basic rich presence status?

dense summit
smoky scroll
dense summit

This sets for the users

smoky scroll
dense summit

who uses your app or other stuff

smoky scroll

I don't have an app

dense summit

discord-rpc isnt about bots

smoky scroll

e.g.

dense summit

bots*

that works wiht users only

dense summit
smoky scroll
dense summit

download discord-rpc: npm i discord-rpc

const client = new RPC.Client({ transport: "ipc" });
client.login({ clientId: "ID" });

const presence = {
   details: "Top text",
   state: "bottom Text",
   largeImageKey: "URL OR KEY",
   largeImageText: "large hover text",
   smallImageKey: "URL OR KEY",
   smallImageText: "small hover text",
   startTimestamp: Date.now()
}

client.setActivity(presence, process.pid);

then run the file and thats it node filename.js

to add buttons

buttons: [{ label: "Cool button", url: "https://example.com" }]

i might be wrong with the url thing tho

@smoky scroll

smoky scroll

Is this against TOS?

dense summit

go to the developers dashboard thing on discord
Create an application and get the client id (application id)

you can use URLs for images or upload images into the application and use the key

smoky scroll

how will it appear as my status tho

dense summit

itll appear on ur status

smoky scroll

hmm ok

dense summit

Playing [APPLICATION_NAME]

smoky scroll

And it's not against TOS?

dense summit

not at all

smoky scroll

Great

I see people using like BetterDiscord and shit and I get so mad

dense summit

anywat i gtg sleep

smoky scroll

Hmm ok

Gn

hasty vapor

Error

smoky scroll

a) "ipc"? b) why is this on a phone c) wtf

hasty vapor

Lmao

it's ipc in the code

thin tundra

also make sure you required discord-rpc

smoky scroll
smoky scroll
thin tundra

yes

smoky scroll
    at Object.<anonymous> (C:\Users\Patron\Downloads\rpc\index.js:3:16)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)        
    at node:internal/main/run_main_module:17:47

Node.js v17.4.0```
thin tundra

can i see your code

smoky scroll
thin tundra can i see your code
const DiscordRPC = require('discord-rpc')
const RPC = new DiscordRPC.Client({ transport: 'ipc' }); 
const client = new RPC.Client({ transport: "ipc" });
client.login({ clientId: "936472354467500052" });

const presence = {
   details: "♫ https://cloudy.gay",
   state: "bottom Text",
   largeImageKey: "froggie",
   largeImageText: "large hover text",
   smallImageKey: "froggie",
   smallImageText: "small hover text",
   startTimestamp: Date.now()
}

client.setActivity(presence, process.pid);``` this is `index.js`
thin tundra

you should not need to define client

smoky scroll
thin tundra

yea

when rpc is defined that is it

smoky scroll

wait

thin tundra

and where ever it says client replace tat with RPC

smoky scroll
const DiscordRPC = require('discord-rpc')
const client = new DiscordRPC.Client({ transport: 'ipc' }); 
client.login({ clientId: "936472354467500052" });

const presence = {
   details: "♫ https://cloudy.gay",
   state: "bottom Text",
   largeImageKey: "froggie",
   largeImageText: "large hover text",
   smallImageKey: "froggie",
   smallImageText: "small hover text",
   startTimestamp: Date.now()
}

client.setActivity(presence, process.pid);``` ->> ```    this.socket.write(encode(op, data));
                ^

TypeError: Cannot read properties of null (reading 'write')
    at IPCTransport.send (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\transports\ipc.js:155:17)
    at C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:159:22
    at new Promise (<anonymous>)
    at RPCClient.request (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:157:12)
    at RPCClient.setActivity (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:518:17)
    at Object.<anonymous> (C:\Users\Patron\Downloads\rpc\index.js:15:8)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)

Node.js v17.4.0```
thin tundra

is that your full index page

smoky scroll
thin tundra

have you looked at the recourses listed in the the channel topic

smoky scroll

e.g.

thin tundra

you need a app to do that

smoky scroll

Wait I do

thin tundra

yes

smoky scroll

Then what was @dense summit on?

thin tundra
smoky scroll

I added the client ID

thin tundra

you have to register

smoky scroll

Like apply

thin tundra
smoky scroll
thin tundra
DiscordRPC.register(clientId);

it does not go were you define RPC

on the github link it shows you how to properly make a RPC

just ignore all the stuff that is not rpc related

if it says app on it then that is a part of electron and is unnecessary

@smoky scroll if it works let me know i got to switch to mobile but i should still be able to help if you need any more help. 🙂

smoky scroll
thin tundra

Yes

Wait hold on

Let me check something rq

Your client login should be at the bottom like a discord bot

smoky scroll
   this.socket.write(encode(op, data));
                ^

TypeError: Cannot read properties of null (reading 'write')
    at IPCTransport.send (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\transports\ipc.js:155:17)
    at C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:159:22    at new Promise (<anonymous>)
    at RPCClient.request (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:157:12)
    at RPCClient.setActivity (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:518:17)
    at Object.<anonymous> (C:\Users\Patron\Downloads\rpc\index.js:16:8)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)   
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)

Node.js v17.4.0``` is the error from ```js
const DiscordRPC = require('discord-rpc')
const client = new DiscordRPC.Client({ transport: 'ipc' }); 
let clientId = "936472354467500052"
DiscordRPC.register(clientId);

const presence = {
   details: "♫ https://cloudy.gay",
   state: "bottom Text",
   largeImageKey: "froggie",
   largeImageText: "large hover text",
   smallImageKey: "froggie",
   smallImageText: "small hover text",
   startTimestamp: Date.now()
}

client.setActivity(presence, process.pid);
client.login({ clientId: "936472354467500052" });```
thin tundra

At the bottom where you login your clientId can be replaced with your variable of your client ID

smoky scroll
thin tundra At the bottom where you login your clientId can be replaced with your variable o...

I changed it to client.login(clientId) and now the error is ```C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\transports\ipc.js:155
this.socket.write(encode(op, data));
^

TypeError: Cannot read properties of null (reading 'write')
at IPCTransport.send (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\transports\ipc.js:155:17)
at C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:159:22 at new Promise (<anonymous>)
at RPCClient.request (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:157:12)
at RPCClient.setActivity (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:518:17)
at Object.<anonymous> (C:\Users\Patron\Downloads\rpc\index.js:16:8)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)

Node.js v17.4.0```

full code is ```js
const DiscordRPC = require('discord-rpc')
const client = new DiscordRPC.Client({ transport: 'ipc' });
let clientId = "936472354467500052"
DiscordRPC.register(clientId);

const presence = {
details: "♫ https://cloudy.gay",
state: "bottom Text",
largeImageKey: "froggie",
largeImageText: "large hover text",
smallImageKey: "froggie",
smallImageText: "small hover text",
startTimestamp: Date.now()
}

client.setActivity(presence, process.pid);
client.login(clientId);```

thin tundra

async function setActivity() {
if (!rpc ) {
return;
}

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,

});
}

rpc.on('ready', () => {
setActivity();

// activity can only be set every 15 seconds
setInterval(() => {
setActivity();
}, 15e3);
});

rpc.login({ clientId }).catch(console.error);

This the way of setting the activity

smoky scroll

ah

would that be the entire index.js file?

thin tundra

That would be in-between wear you define clown and we’re you login

Also change client to rpc

smoky scroll

mk

thin tundra

Just that was from the rpc example

It should work if not I will rewrite it so it does

smoky scroll

this does not work, no

fuck sorry that's mine

thin tundra

You did not put it in brackets

If you look in the GitHub I sent you it shows you how to do it

smoky scroll

Ah oke

smoky scroll

I did this now:

const DiscordRPC = require('discord-rpc')
const rpc = new DiscordRPC.Client({ transport: 'ipc' }); 
let clientId = "936472354467500052"
DiscordRPC.register(clientId);

async function setActivity() {
    if (!rpc ) {
      return;
    }
  
      rpc.setActivity({
      details: `booped some times`,
      state: 'in slither party',
      largeImageKey: 'froggie',
      largeImageText: 'tea is delicious',
      smallImageKey: 'froggie',
      smallImageText: 'i am my own pillows',
      instance: false,
    });
  }
  
  rpc.on('ready', () => {
    setActivity();
  
    // activity can only be set every 15 seconds
    setInterval(() => {
      setActivity();
    }, 15e3);
  });
  
  rpc.login({ clientId }).catch(console.error);```

and this doesn't show on my profile
thin tundra

Do you get a error

smoky scroll

I did node ., no message appears

thin tundra

Nothing should log In console

smoky scroll
smoky scroll
thin tundra

Are you singed into the discord app on your computer

smoky scroll
thin tundra

No it should be the regular one

Try to re run it

smoky scroll

ok

I re-ran it, does it show up?

thin tundra

Weird I don’t see it

smoky scroll

yeah...

this is the whole index code:

const DiscordRPC = require('discord-rpc')
const rpc = new DiscordRPC.Client({ transport: 'ipc' }); 
let clientId = "936472354467500052"
DiscordRPC.register(clientId);

async function setActivity() {
    if (!rpc ) {
      return;
    }
  
      rpc.setActivity({
      details: `booped some times`,
      state: 'in slither party',
      largeImageKey: 'froggie',
      largeImageText: 'tea is delicious',
      smallImageKey: 'froggie',
      smallImageText: 'i am my own pillows',
      instance: false,
    });
  }
  
  rpc.on('ready', () => {
    setActivity();
  
    // activity can only be set every 15 seconds
    setInterval(() => {
      setActivity();
    }, 15e3);
  });
  
  rpc.login({ clientId }).catch(console.error);```
thin tundra

Hold on I will get back on my computer and compare them

Cause I am missing something

smoky scroll

okay

thin tundra

dont thin this will fix it but remove the return in the if statement

if(!rpc){

} 
thin tundra

wait

smoky scroll

waiting

thin tundra

nv did not work


const DiscordRPC = require('discord-rpc');
const clientId = '';


// register  the RPC

const rpc = new DiscordRPC.Client({ transport: 'ipc' });
DiscordRPC.register(clientId);


const startTimestamp = new Date();

async function setActivity() {
  if (!rpc) {
    return;
  }


  rpc.setActivity({
    buttons: [{ label: RPCButtonName , url: RPCButtonLink }], 
    details: `${RPCDetails}`,
    state: `${RPCState}`,
    startTimestamp,
    largeImageKey: 'largelogo',
    largeImageText: 'Working on shit',
    smallImageKey: 'online',
    smallImageText: 'online',
    instance: false,
    
  });
}

rpc.on('ready', () => {
  setActivity();

  setInterval(() => {
    setActivity();
  }, 15e3);
});

rpc.login({ clientId }).catch(console.error);

just use this this is my complete code there should be no reason why it fails

smoky scroll

okay

I'll try, thanks

I''ll replace the keys and stuff

thin tundra

remove the value in detail and state

smoky scroll

how do I define RCButtonState

                       ^

ReferenceError: RPCButtonName is not defined
    at setActivity (C:\Users\Patron\Downloads\rpc\index.js:20:24)
    at RPCClient.<anonymous> (C:\Users\Patron\Downloads\rpc\index.js:34:3)        
    at RPCClient.emit (node:events:520:28)
    at RPCClient.login (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:139:12)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Node.js v17.4.0```
thin tundra

the buttons

its at the top of where i set the activity

smoky scroll

thanks!

thin tundra

oh

smoky scroll

did it work

thin tundra

wait those are just variables i used

smoky scroll
thin tundra

go in your settings and look in here make sure it is not disabled

cause that might be what is causing it to not appear on your discord account

smoky scroll

AHA

THANKS

Can I add a second button or no?

thin tundra

buttons: [ { label: " ", url: " " }, { label: " ", url: " "} ]

you do this and you can have 2 buttons

smoky scroll

ooh thanks

Oh, why is your discord bot going down?

thin tundra

cause i no longer have time to maintain it

smoky scroll

Ah

Why not just keep hosting it tho?

thin tundra

I dont want to host a dead project that i am no longer maintaining

smoky scroll

Ah okay

thin tundra

since there will never be updates to it and also my v13 bots suck cause i am not the best with 13 It use to be made with discord js and commando

smoky scroll

uhhh @thin tundra Error: RPC_CONNECTION_TIMEOUT at Timeout._onTimeout (C:\Users\Patron\Downloads\rpc\node_modules\discord-rpc\src\client.js:100:47) at listOnTimeout (node:internal/timers:559:17) at processTimers (node:internal/timers:502:7)

thin tundra
smoky scroll
thin tundra

We’re you restarting the index.js file a bunch

smoky scroll

yes

thin tundra

If so you were rate limited

smoky scroll

ohh

that makes sense

how long is the rate limit?

thin tundra

I am not 100% I waited 5 minutes and came back

It is probably less though

smoky scroll

mk

hasty vapor

Sumone pls help meh

left fjord

ignoring apparent lack of most basic js, that's not going to work at all. bots cannot have rpc, and that rpc will not work on repl or whatever that is anyway.

still lynx
still lynx
spring dune

You cannot.

elfin turret

i can access rpc from browser right ?

or it has to run in user os to work ?

urban basin

Hey generally I was not interested in this before, but why should i remove the token from the file (Rich presence)? After all, there is not much to hack there except changing the graphics or possibly the name.

nimble yarrow
nimble yarrow
urban basin
nimble yarrow

thats just the application id

you cant change anything with that, thats just used to access assets etc. from that application

candid tusk

Hey, do you know how can I implement the "ask to join button" and the "join button on the invite sent"?

I already put the secrets, and the party id, but I can't find the right event to listen when both buttons are pressed

smoky scroll

getting connection closed?

candid tusk

what?

smoky scroll

im getting the connection closed error

candid tusk

ah ok, idk

nimble yarrow
smoky scroll im getting the connection closed error

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

smoky scroll
nimble yarrow <:djs:851461487498493952> Things to consider when getting a connection closed/c...

I have the same problem, but none of the above helped me.

code:

const RPC = require("discord-rpc"),
    rpc = new RPC.Client({transport: "ipc"}),
    clientId = '846017522704580668';
    
RPC.register(clientId);

rpc.on("ready", () => {
    if (!rpc) {
        return;
    }
  
    rpc.setActivity({
        details: "details",
        state: "state",
        largeImageKey: "largeImageKey",
        smallImageKey: "smallImageKey",
        largeImageText: "largeImageText",
        smallImageText: "smallImageText",
        startTimestamp: new Date()
    })
})

rpc.login({clientId})
nimble yarrow
smoky scroll

Yes and yes

As soon as I wrote it, everything worked. After a while, it began to give this error.

Damn... This is all cus Discord was started as an administrator...

rough trellis

Hey i keep on getting this error

name\node_modules\discord-rpc\src\client.js:111
        reject(new Error('connection closed'));
               ^

Error: connection closed

any help ?

nimble yarrow
rough trellis Hey i keep on getting this error ``` name\node_modules\discord-rpc\src\client.js...

djs Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'.
• Is the ID you are trying to login with your user ID? If so, you should be using a Client ID from the Developer Portal (https://discord.com/developers/applications) instead.
• Is the ID a string? If not, JavaScript will truncate it's value causing the connection to fail.
• Are you using the Discord app? It won't be able to connect to the web version. Similarly, bots cannot use RPC.
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either.
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website.

rough trellis
rough trellis
nimble yarrow

show the code

rough trellis
rpc.login({
        clientId: Client.user.id,
        clientSecret: 'secret'
})
rpc.on('ready', () => {
    let counter = 0
    const status = [
        `Trusted Servers: ${Client.guilds.cache.size}`,
        `Verified: False`,
        `Seen Users: ${Client.users.cache.size}`
    ]
    const update = () => {
        rpc.setActivity({
            details: `Currently being developed`,
            state: `${status[counter]}`,
            largeImageKey: Client.user.displayAvatarURL({dynamic: true}),
            largeImageText: `Bot: ${Client.user.tag}`,
            smallImageKey: Client.users.cache.get('601364286731714591').displayAvatarURL({dynamic: true}),
            smallImageText: `Developer: ${Client.users.cache.get('601364286731714591').tag}`,
            buttons: [
                {
                    label: 'Invite Link', url: 'not showing it here'
                },
                {
                    label: 'Support', url: 'dont wanna get banned so not gonna show the link'
                }
            ]
        })
        if(++counter >= status.length){
            counter = 0
        }
        setTimeout(update, 1000 * 10)
    }
    update()
    console.log('RPC has loaded')
})
nimble yarrow

are you trying to set rpc on a bot? Thonk

rough trellis
nimble yarrow

you have to put your application id there, not the bot id

rough trellis

doesn't show the error but neither the rpc

nimble yarrow

where are you running the rpc code

rough trellis

the login is in the client.on ready event

but the rpc.on ready in a different file

nimble yarrow

and you are sure the ready event is being called

rough trellis

well if my bot loads up then yes

(i mean yes)

nimble yarrow

you said the rpc.on ready is in a different file, where do you actually call that in your main file

rough trellis

so my main is the command,slash cmd,events handler that goes through a folder that goes through another folder that goes to the file aka commands,slash cmds,events

but also in the main file is the Client.login

if you understand

if not then i can show the code

nimble yarrow

dont get it

you have to make sure the code in the file gets executed

rough trellis

it does get executed

nimble yarrow

if its not throwing an error, nor does it load, its not getting executed.

rough trellis

but then how does it send that the bot loaded

aight imma go figure this thing out then

nimble yarrow

I'm not speaking about your bots ready event

I'm speaking about the rpc's ready event

rough trellis

carp i'm dumb it was always using a new one but not the same one

yup that's the error it was always making a new one

still thanks for trying to help

:)

azure acorn

my turn i guess

i tried both ipc and ws neither worked

reinstalled discord and everything

nimble yarrow

so not sure what you expect

azure acorn

.......

wow

azure acorn

does anyone know how i can get rid of 'kzpresence' here?

that's what i named my discord application and idk how to remove it

i only have these properties

i guess i cant

spring dune

You can't get rid of it

azure acorn

yeah i figured

thx

candid tusk

Does anybody know how to implement the "Ask to join" feature? @here

solar sentinel

You'll still have the line, but no title visible.

azure acorn

yeah i'll just keep it

wouldn't like the empty space anyway

candid tusk
sage spade
const redirectUrl = "https://neklioz.notion.site/";
const client = new RPC.Client({ transport: 'ipc' });
const presence = {
    details: "Top text",
    state: "bottom Text",
    buttons: [{ label: "Example", url: "https://example.com" }]
}
client.on('ready', () => {
  client.setActivity(presence, process.pid);
});
client.login({ clientId, redirectUrl });

I'm not getting any error but setActivity doesn't work, redirectUrl is specified on developers page.

If I put scopes = ["rpc"] I get: body: { redirect_uri: [ 'Not a well formed URL.' ] }

Any idea?

candid tusk

@solar sentinel did you figure out for the "Ask to join" button?

white mirage

I dont use the RPC thing, but I use Discord.client with client.setPresence but my bot keeps losing its activities?

white mirage
nimble yarrow

no, its not related.

white mirage
nimble yarrow

maybe when I have time hehe

hasty vapor

Can someone help me?

nimble yarrow
hasty vapor

why is this channel made anyway lol

left fjord

what is this question lmao

this channel is for RPC specifically, not whatever you asked above

thin tundra
steep dawn

Can I've a good documentation on how to use rpc, the documentation has just one example and that doesn't work perfectly

steep dawn

How to use authenticate and authorize to get getGuilds perms?

candid tusk
tiny crest

I get this error for discord-rpc

nimble yarrow
tiny crest
nimble yarrow
crisp coral

Any idea of animated images?

empty minnow

Is clientId the application ID in the dev portal?

nimble yarrow

yes

empty minnow
cursive frost

im trying to make my own rich presence status but i keep this error:

nimble yarrow

@empty minnow

cursive frost

k

empty minnow
cursive frost
nimble yarrow

show code

cursive frost

pastebin or just send it here in a codeblock?

nimble yarrow

pastebin

cursive frost

aight

just a sec

nimble yarrow

what why are you defining the client, destroying it and then redefining it

that makes absolutely no sense

cursive frost

i was referencing other code

tbf it didn't make sense to me either

i just went with it anyways

nimble yarrow

why are you doing it like you do it there anyway

cursive frost

brain_loading

nimble yarrow

I suggest you look at the example from the channel description and build on that

(the rpc part, not the website part)

cursive frost

looking

empty minnow

Client doesn't log in. No messages returned to console so it's not readying.

nimble yarrow

why why why why why do you all use that code

that makes absolutely no sense

empty minnow

lol, that's besides the point, it's for something else. I need it to login.

nimble yarrow

then I suggest you start by calling the makeRPC method

cuz if you dont log in and dont get any errors, its not getting called

empty minnow

Lol dude

It's not in the screenshot, I called it.

nimble yarrow

did you, then debug it

place console.log()'s and see what part it reaches and what not

empty minnow

I already told you. It doesn't get login correctly. I've already determined that, I'll just solve this elsewhere.

nimble yarrow

No, you didn't, but sure, do what have to

cursive frost