#archive-rpc-help

21942 messages · Page 14 of 22

sterile arch

Hmm

Why this section is ded

humble dew
const client = require('discord-rich-presence')('YOUR-CLIENT-ID-HERE');

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

    client.updatePresence({
        state: 'discription',
        details: 'discription',
        startTimestamp: new Date(),
        largeImageKey: 'YOUR-IMATE-LARGE-HERE,
        smallImageKey: 'YOUR-IMAGE-SMALL-HERE',
    });

    console.log("we are connected!");
});
fallen coyote

it was going ahead and looking at the wrong path when finding the ipc

humble dew

oh

fallen coyote

yep

smoky scroll

Hello, how can I get the RPC large image/small image on connect ? (using client id + secret id)

(you can ping me)

rich night

Hello how can i jump lines in the rpc state or make a slider because my text is not complete in the rpc ?

left fjord

You can't

atomic patrol

I can't login

rich night

hi was is the websocket transport and what's de difference with the rpc ?

craggy boughBOT
craggy boughBOT
smoky scroll

Why is this extension used?

I mean what it does.?

left fjord

this is rich presence

smoky scroll

@left fjord i know but where can i use this extension?

left fjord

that specific one is an extension in vscode

smoky scroll

Can't this extension be used in bots😂?

left fjord

no

bots cannot have rich presence

smoky scroll

Ohk so this extension is made for making software and adding rpc to it.

right?

left fjord

yes

smoky scroll

Ohk

I'll have to learn how to make softwares with js.

bnf_confused_henley

smoky scroll

I mean is there any library?

??

unborn stream

electron

smoky scroll

@unborn stream can we make games for Discord in electron.js?

unborn stream

what are games for discord

clear cipher

boop the snek is the best game,cant imagine a better one tbh

jovial nacelle
uneven totem

is it normal that i can just log onto my rpc using the client id?

fast pecan

is there any way to change state and details without affecting time

discord rpc

dead channel?

river edge

What is that lib? What is it for?

tiny lance

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

    client.updatePresence({
        state: 'discription',
        details: 'discription',
        startTimestamp: new Date(),
        largeImageKey: 'YOUR-IMATE-LARGE-HERE,
        smallImageKey: 'YOUR-IMAGE-SMALL-HERE',
    });

    console.log("we are connected!");
});```

what does this do?

smoky scroll
const RPC = require('discord-rpc')

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

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

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

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

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

Connection closed Error.

bnf_wutt

left fjord

Use ipc instead of websocket

spring token

anyone knows why it fails to install?

wait hold on, ill send logs

smoky scroll
npm WARN Could not resolve dependency:
npm WARN peer register-scheme@"github:devsnek/node-register-scheme" from discord-rpc@3.1.4    
npm WARN node_modules/discord-rpc
``` Any ways to fix this? I get that errors when I do `npm i discord-rpc`
carmine mica

@smoky scroll that's not an error

that's a warning

smoky scroll

oh

lemme

show the err

npm ERR! code 1
npm ERR! command failed
npm ERR! command git ls-remote ssh://git@github.com/devsnek/node-register-scheme.git
npm ERR! 'git' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
smoky scroll

@smoky scroll iirc it is because you don't have git installed so better just install it

aye I just installed git

and it worked

thank you!

smoky scroll

why is this error coming? ```internal/modules/cjs/loader.js:883
throw err;
^

Error: Cannot find module 'C:\Users\parthiv\Desktop\WhisBot'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}```

shell hatch

please stop posting your error in every channel

smoky scroll

ok

smoky scroll

does discord rpc adds rich presence to bots or users

?

strong grail

Bots cant use rich presence

Only nornal discord users

Discord API doesnt allow rich presence for bots

smoky scroll

ok

Also I used the example code ```js
const RPC = require('discord-rpc');
const clientId = '779007882573774868';
const scopes = ['rpc', 'rpc.api', 'messages.read'];

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

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

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

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

Websockets just causes connection closed

smoky scroll

how do i use discord rpc

nimble yarrow
iron mirage

hey.. can i use rpc on my discord bot?

faint igloo

What is rpc?

left fjord
left fjord

discord doesn't really display more than 24 hours

after that it just starts from 0

flint storm

can I use rpc on my discord bot

smoky scroll

I used this code, I get no errors
and its still not working

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

rpc.on("ready", () => {
    rpc.setActivity({
        details: "Join xensis!",
        state: "discord.gg/**********",
        startTimestamp: new Date(),
        largeImageKey: "teo_mask",
        largeImageText: "I said join xensis, not hover over my picture...",
    });
    console.log("Rich presence has started")
});

rpc.login({ clientId: "768192429148471336" });
left fjord
flint storm

H

spring dune

for some reason I keep seeing my IDE instead of my RPC

very sad

i.ex.

Any ideas how I'd solve this?

(Yes, I am using WebStorm, JavaScript and discord-rpc lib)

ok I turned it off and that fixed it but would love to test without having to close IDE lmao

spring dune

Also a quick question, how does one add the Join/Ask to join buttons?

Like how do you tell RPC that you have a lobby.

spring dune

I am not aware what the metadata is what <RPC>.createLobby(type, capacity, metadata); wants

Where could I find this?

smoky scroll

Hello, does this module require Python ? because when i install it i have a python error lol

left fjord

Probably requires python 2.7 to build some dependencies

Nothing unusual

smoky scroll
spring dune

Ya know it'd be easier to help if you'd say what the error is

primal ingot
node:8603) UnhandledPromiseRejectionWarning: Error: Could not connect9:47 PM

at Socket.onerror (/rbd/pnpm-volume/31b211f4-3324-486e-8d8d-9126c83eac48/node_modules/.registry.npmjs.org/discord-rpc/3.1.4/node_modules/discord-rpc/src/transports/ipc.js:32:16)

Error any one?

@spring dune ^^ sorry for ping

spring dune

Why tag me I'm a beginner in RPC lmao
Also that is literal "Could not connect"

primal ingot

Can i show you my code?

spring dune

Sure

Just post here kek

primal ingot
​const RPC = require('discord-rpc');
const rpc = new RPC.Client({
	transport: 'ipc'
});

rpc.on('ready', ready => {
  rpc.setActivity({
    details: "Making video",
    state: "Testing",
    startTimestamp: new Date(),
    largeImageKey: "786624259954835457",
    largeImageText: "hello world"
 /* smallImageKey: "short",
   smallImageText: "hi",
    */
  });
  console.log("rich presence is now active");
});

rpc.login({
  clientId: "786624259954835457"
});

This not working showing me that error😔

Ten#0010 ^

urban stone

How to do discord-rpc ? pls

shell hatch

Check the links in the channel topic

hazy vine

pollEmbed(msg, title, options, timeout, emojiList, forceEndPollEmoji);

i didnt understand how can i use that command

left fjord

and what that has to do with rpc

hazy vine

which channel i have to use?

shell hatch

that is not rpc, and that also doesn't look like djs

primal ingot
node:8603) UnhandledPromiseRejectionWarning: Error: Could not connect9:47 PM

at Socket.onerror (/rbd/pnpm-volume/31b211f4-3324-486e-8d8d-9126c83eac48/node_modules/.registry.npmjs.org/discord-rpc/3.1.4/node_modules/discord-rpc/src/transports/ipc.js:32:16)

Error any one?

spring dune

@primal ingot check your clientId

primal ingot
spring dune

Is the id copied from the video tutorial you saw, or your own client id?

Also does the application have an image with the same name as the client id, as you've defined it as such?

primal ingot

Yahh its my bot client id

I mean application client id

bright roost

yes saw it bruh, thx

primal ingot

Go there

tawdry briar

Hi guys! Just a quick question, what should the clientId be ? Thanks! ❤️

left fjord

App id

tame apex

what is my fault

soft kayak

When I'm using Discord-rpc - When I close it, it close. But if I set it up on my Raspberry PI. Will it so still display for me?

left fjord

no

rpc app has to run on same pc discord does

soft kayak

Sick. Thanks.

tame apex
spring dune

Can anyone explain connectToLobby a bit more for me?

I keep getting: Error: Lobby service is unavailable.

I'm using ipc as my transport

carmine mica

@spring dune you most likely do not have permission to use it

spring dune

It requires permission?

@carmine mica

carmine mica

yes

rich night

Hi what can we do with the party id and ask to join in node js ?

night frigate

what is the rich performance code

primal ingot

Thats rich presence not rich preformance

clear cipher

how do i make the time show 19:30 minutes left? instead of showing 19:30 elapsed

rich night

elapsed it's because you set a endtimestamp less important that the startTimestamp @clear cipher

rich night

Hi what can we do with the party id and ask to join in node js ?

clear cipher
left fjord

Pass when it ends

With a separate property

clear cipher

could u show me a example

clear cipher

and instead of making it show PLAYING A GAME could i change it to something else? just like when a user uses spotify it says Listening to spotify and not playing spotify.Could i maybe change it to something like watching youtube or something like that

unkempt meadow

where can I find the docs of the args?

is it possible to change the rpc background color?

left fjord

No

unkempt meadow

the error I get: Error: OAuth2 Error: invalid_request: Missing "redirect_uri" in request.
here's my code: https://srcb.in/rxWlBsQRVz
idk how to set the redirect uri

I actually did it but I get a Bad request error

rich night

@unkempt meadow what does your party id ?

unkempt meadow

what?

rich night

line 15

unkempt meadow

it's a random id

rich night

is it usefull ?

unkempt meadow

idk actually not in my case

rich night

ok

i think go on your developpers portal in the oauth of your app

unkempt meadow

still getting this error:

frank verge

what's this

karmic jolt
clear cipher

Oh


let endTimestamp = new Date()

rpc.setActivity({
    details: `booped ${boops} times`,
    state: 'in slither party',
    endTimestamp,
    largeImageKey: 'snek_large',
    largeImageText: 'tea is delicious',
    smallImageKey: 'snek_small',
    smallImageText: 'i am my own pillows',
    instance: false,
  });

Like that?

clear cipher
          let d = new Date();
          const endTimestamp = new Date(d.getFullYear(),d.getMonth(),d.getDay(),d.getHours(),d.getMinutes() + 20,d.getSeconds(),d.getMilliseconds());

          rpc.setActivity({
            details: `Watching ${anime}`,
            state: `On episode ${ep}`,
            endTimestamp,
            largeImageKey: large_img,
            largeImageText: anime,
            smallImageKey: 'animedao',
            smallImageText: 'On https://animedao.to',
            instance: false,
          }).catch(e => console.log("\x1b[33m%s\x1b[0m",e))

it says 00:00 left

karmic jolt

the date constructor doesn't take multiple arguments, just use Date.now() + 20 * 60 * 1000 if you want it to end in 20 minutes

fathom lion

can you have two scripts connect to regular and canary instance at the same time?

mighty pendant

I'm trying to use the RPC package with React using the websocket method but i'm getting this error in the console. How can i fix this?

My code:

    const rpc = new Client({
        transport: "websocket"
    });

    rpc.on("ready", () => {
        rpc.setActivity({
            details: "Test",
            state: "test",
            startTimestamp: new Date()
        });
        console.log("Rich presence now active.");
    })

    rpc.login({
        clientId: "789853560376000523"
    }).catch(err => console.log(err))

I tried using IPC but that doesn't work in browsers.

fathom lion

ugh, the ipc backend would support setting your ipc client id, but the rpc.login just doesn't...

clear cipher

is it possible to make the time 12:00 / 20:00? I just realised that is the same as endTimestamp but I still wanna know if its possible

@mighty pendant i think for the login,theres no clientId option,in the example,its a string

let clientId = "789853560376000523"
    rpc.login({ clientId }).catch(err => console.log(err))
mighty pendant

How is this any different though? 🤔

clear cipher

ur giving a string to a option that does not exist,what do u think?

mighty pendant

but how is

let clientId = "789853560376000523"
rpc.login({ clientId })

any different from

rpc.login({clientId: "789853560376000523"})

Yours is just using the shorthand

you could write your snippet as

let clientId = "789853560376000523"
rpc.login({ clientId: clientId })
faint igloo

._.XD

gritty peak

I have never understood rpc.

Does it check if discord is on the pc and runs it through that?

left fjord

it doens't "check"

it simply connects to it

gritty peak

oh

Does it work with mobile too?

like if I make an nodejs app here on my phone

left fjord

no

mobile app does not have rpc server

gritty peak

oh right

left fjord

there was an experiment with game detection, that was running as a separate service, but it was long ago

gritty peak

ah

quaint sapphire

I was looking at the RPC documentation and it say RPC is in a private beta. I've used Discord.js-RPC before though

Am I missing something?

clear cipher

could I change the type of the status? Like can i change PLAYING to WATCHING?

clear cipher

can i change my application name? I mean not manually but by code

gritty peak

How could I make so my RPC tells how long it's been on?

clear cipher
gritty peak

Thank you!

fathom lion

Completely noob javascript question, how do I get access to unsubscribe in here (from rpc client.js):

  /**
   * Subscribe to an event
   * @param {string} event Name of event e.g. `MESSAGE_CREATE`
   * @param {Object} [args] Args for event e.g. `{ channel_id: '1234' }`
   * @param {Function} callback Callback when an event for the subscription is triggered
   * @returns {Promise<Object>}
   */
  subscribe(event, args, callback) {
    if (!callback && typeof args === 'function') {
      callback = args;
      args = undefined;
    }
    return this.request(RPCCommands.SUBSCRIBE, args, event).then(() => {
      const subid = subKey(event, args);
      this._subscriptions.set(subid, callback);
      return {
        unsubscribe: () => this.request(RPCCommands.UNSUBSCRIBE, args, event)
          .then(() => this._subscriptions.delete(subid)),
      };
    });
  }

Is await rpc.subscribe() sufficient?

carmine mica

const { unsubscribe } = await client.subscribe(...)

fathom lion

I have this and it seems to work:

let activityJoinRequestUnsubscriber = null;

// other code here

        if (!lobbyIsPrivate) {
            activityJoinRequestUnsubscriber = await rpc.subscribe('ACTIVITY_JOIN_REQUEST', (args) => {
                rpc.sendJoinInvite(args['user']['id']).catch(console.log)
            })
        } else if (activityJoinRequestUnsubscriber !== null) {
            activityJoinRequestUnsubscriber.unsubscribe()
            activityJoinRequestUnsubscriber = null
        }

I should check that unsubscriber is null before setting it again

but also, this entire thing I wanted to do doesn't work anyway so I'll just remove this roundabout way of sending the invite

I thought discord wouldn't send those invite to join messages when someone asks to join when you are subscribed to ACTIVITY_JOIN_REQUEST but it does

supple imp

hey, I've searched for a long time but still didn't find anything...
everytime I try to run example, I'm getting body: { redirect_uri: [ 'Not a well formed URL.' ] }

doesn't matter what redirect url I type (on that site where you create apps), it throws this error... (using ipc ofc)

dense sage

how would i add buttons like this?

karmic jolt

buttons aren't documented on discord's side, hence there's no support for it in discord-rpc

dense sage

damn

neat sequoia

^^ this guy has the same question as me xD

craggy boughBOT
rich night

what is this ? .setCertifiedDevices(devices)
Tell discord which devices are certified

and this ? .captureShortcut(callback)
Capture a shortcut using the client The callback takes (key, stop) where stop is a function that will stop capturing. This stop function must be called before disconnecting or else the user will have to restart their client.

rich night

thx

shell stirrup

what are transport options in constructor options

nvm got it

how do I add buttons like this

the user said they used discord-rpc

left fjord
rich night

with discord

rich night

how can we interact with the invite code in discordjs-rpc ?

karmic jolt

you can still add buttons, but discord-rpc won't support them in setActivity

rich night

how can i add them @karmic jolt ?

karmic jolt

look at the internal structure of the setActivity() method and use that to make a request to the websocket

rich night

but with transport ipc is it ok ?

karmic jolt

sure

rich night

ok in the node modules files

thx

and question do you know if we can make someone open a browser when clicks join party ?

karmic jolt

as in a custom button with that label or the rpc party function

rich night

can you voc i don't really understand

export interface Presence {
    state?: string;
    details?: string;
    startTimestamp?: number | Date;
    endTimestamp?: number | Date;
    largeImageKey?: string;
    largeImageText?: string;
    smallImageKey?: string;
    smallImageText?: string;
    instance?: boolean;
    partySize?: number;
    partyMax?: number;
    matchSecret?: string;
    spectateSecret?: string;
    joinSecret?: string;
}

``` Here is the presence in node_modules i don't see any button
karmic jolt

because, as i said, discord-rpc doesn't support them

you're looking at the types, not the source

rich night

i don't really understand what is the source ?

rich night

yes i am there but where can i add the button

karmic jolt

add an array like buttons: [{ label: 'hi', url: 'https://example.com' }] to the activity object at the bottom

rich night

and discord will add a button ?

karmic jolt

try it

rich night

ok

it works but it don't redirects

karmic jolt

thats normal, you cant click your own buttons

rich night

i will try with href redirect or other words

ah ok

try to click on mine ?

does it redirect to google ?

karmic jolt

yes

rich night

thx

how did you know that ?

and why they don't documentate it ?

karmic jolt

there's a pr open for that

rich night

an issue on github ?

karmic jolt
rich night

ok thx

i follow you on github @karmic jolt

karmic jolt

cool

rich night

Hey i have a question what can we do with client secret party id etc with discord js rpc ? Can we redirect to a link ?

craggy boughBOT
supple crescent

Is there an example floating around using .subscribe() for voice state changes? I can't seem to grab anything, despite being auth'd. ie, client.user is available.

supple crescent

Looked back a bit through chat history, seems there have been some other issues with 4006 error codes. Seems like I can get user info but can't subscribe to any events, or get guilds, channels, etc, despite having scopes for rpc, rpc.api, guilds, etc.

Would love some guidance if possible.

const clientId = '';
const clientSecret = ''
const scopes = ['rpc', 'rpc.notifications.read', 'guilds'];

DiscordRPC.register(clientId);
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
rpc.on('ready', () => {
    console.log('Authed for user', rpc.user.username);
    rpc.getGuilds(1000)
    .then(c => {
        console.log(c[0].name);
    })
    .catch(error => {
        console.log(error);
    })
    rpc.subscribe("VOICE_STATE_UPDATE", (s) => {
        console.log(s);
    }).catch(error => {
        console.log(error);
    })
});

rpc.login({ clientId: clientId, clientSecret: clientSecret, clienscopes: scopes }).catch(console.error);
loud gulch

hi how to add buttons to rich presence

?

hi

@where everyone

iam using easy rp

waxen gazelle

if you're using some program you'll need to ask the people who made it

verbal portal

can i subscribe to any events like client.subscribe("*")

fathom lion

this sounds like an horrible idea

you want to have different callbacks for every event

not a giant callback with at best a switch statement in it

dry grove

?help

turbid oliveBOT
turbid oliveBOT

[A]utomating the API in that way /is/ abuse. Automatically doing "X" every N is generally not a good idea. Where X could be posting a message, changing someone's nickname, renaming a role, changing a channel topic, etc...
Generally bots should only react to user actions...
Although, for very large N we generally don't care. But for small N, we do care. Think rainbow bots, etc....

~Jake@​Discordapp 21/01/2018
source (Discord API): https://discordapp.com/channels/81384788765712384/381887113391505410/404566425454247938

Against popular belief "does not work" is not sufficient information to provide to receive help.
What's the expected (wanted) behaviour, what's the actual (unwanted) behaviour? Do you get any errors? What's your relevant code that might be causing the issue?

left fjord
fathom lion

How should I reconnect to discord when the user restarts theirs?

fathom lion

Even better question, how can I connect to discord if the user didn't start my app with discord open

fathom lion
function clearDiscord() {
    rpc._connectPromise = undefined;
    // noinspection JSAccessibilityCheck
    rpc._subscriptions = new Map();
    rpc.removeAllListeners('connected')
    // noinspection JSAccessibilityCheck
    rpc.transport.removeAllListeners('close')
}

This is what I found that works

This used to be a thing for exactly no time at all as it was reverted the next commit:

maiden hearth

How to check the position at which we joined the server

smoky scroll

How the client know whom to give rpc?

carmine mica

@fathom lion you should create a new client instance for each connection

fathom lion

And create new listeners after it has connected?

So the examples are pretty out of date, every example makes the client/connection a const

carmine mica

the examples don't handle reconnecting lol

bright moon

where is the event list for the rpc?

Also i couldn't find a full RPCLoginOptions

fathom lion

the event list is on official docs?

bright moon

oh yeah that was my bad

what about RPCLoginOptions ?

bright moon

i just found a little information about scopes on RPCLoginOptions
i saw guilds.join on discord scopes list, and i just thought it means we can make our client join a discord server?
like isn't that against discord TOS?

sacred ore

That is not what that means no

bright moon

so what that means?

not just that, if we can move a user a to a voice channel from another one, it makes the client a kind of bot tho

and again discord TOS problem....

sacred ore

guilds.join is only for redirect links being able to join users to a guild

bright moon

ok, i got about hte guilds.join,
about the move and stuff:
if we are using a kind of bot on our client to do the move and other things, isn't that makes it some kind of illegal?
(with discord-rpc lib)

sacred ore

No it's not , discord voice has some difference rules , and it's allowed to move users

bright moon

oh ok didn't know about that

so about the login options

let's say i have a linux os

i have my discord logged in with my chrome or browser

how can i make the index.js that has discord-rpc to connect to the client logged in the browser?

and set data to it?

or even can we like, be logged out of the discord account from that os, and set rpc from another device?

sacred ore

Well now that last part seems kinda against the TOS of discord , but the first part should work just like a regular discord client

bright moon

but if the last one is illegal, it means spotify is doing an illegal job tho, because i have spotify with other device running and the spotify account is linked to this discord account, and i will get the rpc still....

sacred ore

No , because spotify ITSELF is doing that

You are using a 3rd party RPC client that is unaffiliated with discord, trying to login a client that might not be expecting the action

Do you see the issue with that

bright moon

no i didn't want to login to my account

i just wanted to give the 3rd party app(like my website) to set the rpc for me

without having any access to the client, like is that even possible?

so you just mean the Spotify is kind whitelisted to set this kind of data to our client, but not us?

sacred ore

I kinda misread what you were saying

But also, yes kinda , because spotify is a connection to your account

bright moon

but wasn't there a connection for 3rd party apps too?

like our owns?

sacred ore

No I mean like, spotify is a CONNECTION, like one that you manaully add to your account on purpose for the sole fact of receiving that rpc

bright moon

ok so that makes it legal

sacred ore

No it doesn't

bright moon

for the spotify

i meant

sacred ore

No

bright moon

i mean for the spotify company(or organization or whatever)

but isn't there anyway to make a connection for our 3rd party app (example a website)?

sacred ore

No i-

This kind of connection is what I mean ^

They have implicit access to do that because you connected them

bright moon
sacred ore

Well yea , rpc should do that

bright moon

sadly discord doesn't looks like have it for us tho

ok so about be logged in a browser

having a browser open an launching the index.js will do the work? (i use ipc as the connection tho)

left fjord

Not sure if the website runs rpc server

bright moon
smoky scroll

Hey
I've noticed the ability of having custom buttons in rich presence, the only library that mentions these is djs-rpc.
My current code is

'use strict'; //whatever this is

const RPC = require('discord-rpc');

const clientId = '794670590555324418';

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

client.on('ready', async () => {
  console.log("Ready")
  await client.setActivity({
    details: `Ali's Network`,
    state: 'Hello',
    largeImageKey: 'alibot',
    largeImageText: 'Client by Ali\'s Network',
    buttons: [
      {label: 'Test', url: 'https://snek.dev/'},
      {label: 'Work', url: 'https://thkc.space/'}
    ]
  });
});

client.login({ clientId });

I'm currently running this but the buttons don't appear and I don't get any errors

smoky scroll
smoky scroll

Hey guys how do I use discord rpc to update my own status upon opening an app (e.g. Zoom Meetings) on their PC

covert wedge

I'm trying to use discord-rpc to enable rich presence for my discord profile but when I run the node program i get this error:

Error: connection closed
    at IPCTransport.<anonymous> (C:\Users\Daniel\Documents\discord-presence\node_modules\discord-rpc\src\client.js:118:16)

I'm using Canary 73889 (844e5af)
Host 1.0.16
Windows 10 64-Bit (10.0.19041)

shrewd raft

can you access the client's images from the client id

whole sail

Can we make a rich presence for the bot ?

fathom lion

no, those endpoints are only available to users

whole sail

Oh ok

smoky scroll
smoky scroll Hey I've noticed the ability of having custom buttons in rich presence, the only...

Maybe
try something like this ? ```js
activity : {
details: rpc.details ? rpc.details : undefined,
state: rpc.state ? rpc.state : undefined,
assets: {
large_text: rpc.assets.largeImageText ? rpc.assets.largeImageText : undefined,
large_image: rpc.assets.largeImageKey ? rpc.assets.largeImageKey : undefined,
small_text: rpc.assets.smallImageText ? rpc.assets.smallImageText : undefined,
small_image: rpc.assets.smallImageKey ? rpc.assets.smallImageKey : undefined
},
buttons: [{
label: rpc.buttons.primary.buttonLabelText,
url: rpc.buttons.primary.buttonRedirectUrl
},
...

Looks a little weird since I'm using a config.json 
😓  sorry if this dosent help I'm not the most advanced person
smoky scroll

It says could not connect:

const RPC = require('discord-rpc');

const clientId = '763367310273806366';

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

client.on('ready', async () => {
  console.log("Ready")


client.login({ clientId }).catch(console.error);```

will i have to run it on computer or i can run it on any online repl?

smoky scroll

??

turbid oliveBOT

Try out the code before asking if it works.

smoky scroll

Its not letting me install discord-rpc, any tips?

solid ocean

install git.

smoky scroll

@solid ocean do you have a link to that?

solid ocean

no I don't. Google "how to install git on <your os>"

smoky scroll

@solid ocean that did not fix the installing error..

does anyone know a fix?

shell hatch

the fix is installing git, make sure its added to path

craggy boughBOT
whole sail

What is this error : RPC_CONNECTION_TIMEOUT

sacred ore
whole sail

AHHH ok

slow pine

@sacred ore how do you make this? 😳

couldn't find anything for the buttons

sacred ore

its buttons: [ { label: ' ', url: ' ' }, { label: ' ', url: ' ' } ]

slow pine

thanks 😳

smoky scroll

@sacred ore is there a way I can get the code for the buttons thing in the rpc?

sacred ore

uh no

smoky scroll

oop okay

thorny trout
const RPC = require('discord-rpc')


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

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

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

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

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

I get this error

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

TypeError: RPC.Client is not a constructor

velvet vine
thorny trout

im just using code example in the docs

idk anything about scopes

velvet vine

Well, that might be a problem then, you should make sure the discord-rpc is installed correctly.

Also, use 'ipc' for transport instead of 'websocket' or you'll also have problems with that in a bit.

Also, if you're just using RPC for just the RPC, then 'messages.read' isn't really necessary for your scopes either.

thorny trout
 rpc.setActivity({
    details : details,
    state : state,
     largeImageKey : 'agent',
     largeImageText: 'Pooog',
     smallImageKey : 'agent',
     smallImageText : 'teest',
     startTimestamp  : new Date(),


     })

is there more stuff i can add apart from these ?

smoky scroll

Hello, Discord RPC allow only whitelisted urls for buttons? I tried some variants and nothing worked.

karmic jolt

you need to install the master branch for buttons

smoky scroll

I have already installed, but when I am clicking the buttons, no redirecting

karmic jolt

you can't click your own buttons

smoky scroll

wow, didnt know

signal locust
karmic jolt

npm i discordjs/rpc

smoky scroll
signal locust

Oooo thanks!

craggy boughBOT
slender drum
shell hatch

Please stop crossposting in every channel, especially since your problem has nothing to do with djs rpc or commando

terse shadow

Is it supposed to log Error: connection closed when i run the example?

shell zephyr

Error: connection closed with a valid token

zinc wharf

token?

shell zephyr

it's a client id

and it is a real one

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


rpc.login(myclientid);

myclientid is my actual id

(node:12704) UnhandledPromiseRejectionWarning: Error: connection closed

karmic jolt

is it your user or your application id?

shell zephyr

app id

@karmic jolt

sry ping

zinc wharf

Its showing connection closed for me too Thonk

karmic jolt

are you running that on the same pc where you have the discord program open?

shell zephyr

yeah

karmic jolt

then not sure what else could be causing that

shell zephyr

It's for a game client

const DiscordRPC = require('discord-rpc');
const { app, BrowserWindow } = require('electron');
const rpc = new DiscordRPC.Client({transport: 'ipc'});
let win;

async function createWindow() {
    win = new BrowserWindow({ width: 1920, height: 1080, icon: __dirname + '/icon.ico' });
    win.setMenu(null);
    win.loadURL("https://krunker.io", {userAgent: "Chrome"});
    win.setTitle('[РАША] Clan-Only Client');

    win.on('page-title-updated', (evt) => {
        evt.preventDefault();
    });

    /*rpc.setActivity({
        largeImageKey: "thumbnail",
        largeImageText: "[РАША] Clan-Only Client",
        state: "Test",
        details: "Discord RPC",
        partySize: 0,
        partyMax: 1

    });*/
}


rpc.on('ready', () => {
    app.whenReady().then(createWindow);
});


rpc.login(clientid);

electron

karmic jolt

oh nevermind, i see

the login parameter should be .login({ clientId: clientid })

shell zephyr

thanks!

works for me

karmic jolt

catThumbsUp

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

rpc.on('ready', () => {
    rpc.setActivity({
        // Stuff HERE
    });

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

rpc.login({
    clientId: "ID HERE"
})

Error

(node:6436) UnhandledPromiseRejectionWarning: Error: connection closed 
short wing

you need to pass both the clientId and client secret to rpc.login

zinc wharf

but it worked yesterday

and whats the key to pass client secret?

short wing

hmm did you update discord-rpc?

zinc wharf

nope

short wing

many versions ago it didn't need the client secret

karmic jolt

still doesnt

zinc wharf

i'll try passing that, whats the key? Thonk

clientSecret : ""

?

short wing

yeah

clientSecret

karmic jolt

client secret is only needed for specific rpc methods, rich presence doesnt belong into that category

short wing

oh sorry then it worked for me so i thought we needed that

zinc wharf

nope, connections closed

loud gulch

I want rpc source code

shell hatch

just go to their github

rose bolt

I get the error
UnhandledPromiseRejectionWarning: Error: connection closed
While trying to use discord-rpc

devsnakes's wrapper works fine tho

same issue while running npm run example

on the source code

using macOS 11

@potent quailone?

fuck....

sorry for the ping....

waxen gazelle

@rose bolt do you have transport set to ipc?

rose bolt

no websocket...

tried it on ipc

didnt work

same error

sacred ore

So you have this?

waxen gazelle

websocket is private and you cant use it

you must use ipc

rose bolt

i tried both....

rose bolt

didnt work

sacred ore

Are you using the right client is

Id

rose bolt

yes

sorry had some weird internet issue....

i tried again with ipc

now shows UnhandledPromiseRejectionWarning: Error: OAuth2 Authorization Error: Unknown Error

smoky scroll

Why can't I add time with the button?

I get this error when I add

karmic jolt
smoky scroll

@karmic jolt

0 result

karmic jolt

exactly

smoky scroll

😦

karmic jolt

look at the activity object on the discord docs site, there's a property which lets you set timestamps

smoky scroll

I have been searching for 2 days, no result
Is there a way to add both button and time?

karmic jolt

you can also install the master branch npm i discordjs/rpc which supports buttons on the setActivity() method

hardy arrow

Discord rpc will work without even using the app right?

sacred ore

Yes

The only reason the app is In the example is to show that it can be updated from external variables from other applications like games you make etc

left fjord

huh

how can rpc work without discord app

hardy arrow

my rpc isnt showing
code:

const RPC = require('discord-rpc');
const cl = require('cli-logs');

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

rpc.on('ready', () => {
    rpc.setActivity({
        details: 'Developing a bot',
        startTimestamp: new Date()
    });

    cl.connect('RPC is now active')
});

rpc.login({
    clientId: 'my client id'
});

nvm

sacred ore
left fjord

"app" is ambiguous

so "i think they meant discord app"

shrugCat

sacred ore

Welp we'll see 🙈

craggy boughBOT
unkempt meadow
sacred ore

It's not

unkempt meadow

bruh

sacred ore

Lol

unkempt meadow

how tf then

sacred ore

Well the api tells you what it wants , so when you mess up it says sumn like "buttons: [Object[0]]" expected an object" etc etc, so I just kept working my way thru until I got it right

unkempt meadow

yeah ik but I would never know this by just lookin at the docs

left fjord

there is this

left fjord
sacred ore

It's not actually merged tho, hence why not documented and I had to bullshit my way thru finding it

Glad advaith is always ontop of things tho

left fjord

it's right there

smoky scroll

plz give me djs diccord invite link

@left fjord

left fjord

@smoky scroll

smoky scroll

TNX

smoky scroll

I want it to be in 2 things but I get errors like this

Isn't that feature available or am I just not able to do it?

wise breach

im using

buttons: [{ label: 'test', url: 'some url' }]

for buttons but its not working

wise breach

if this is not the way I should do it , how can I ?

left fjord

?dnw

turbid oliveBOT

Against popular belief "does not work" is not sufficient information to provide to receive help.
What's the expected (wanted) behaviour, what's the actual (unwanted) behaviour? Do you get any errors? What's your relevant code that might be causing the issue?

dawn ginkgo
var rpc = require("discord-rpc")
const client = new rpc.Client({ transport: 'ipc' })
client.on('ready', () => {
client.request('SET_ACTIVITY', {
pid: process.pid,
activity : {
details : "text here!",
assets : {
large_image : "image-name",
large_text : "my Status" // THIS WILL SHOW AS "Playing <Status>" from the outisde
},

instance : false,
buttons : [{label : "test1" , url : "https://github.com/discord/discord-rpc"},{label : "test2",url : "https://github.com/discord/discord-rpc"}]
}
})
})

client.login({ clientId : "client-ID-HERE" }).catch(console.error);
dawn ginkgo

you can see js buttons : [{label : "test1" , url : "https://github.com/discord/discord-rpc"},{label : "test2",url : "https://github.com/discord/discord-rpc"}]

wise breach

i used this , nothing got changed

by using client.setActivity({

when i use client.request , it asks me for a pid

what's pid ?

dawn ginkgo

idk

check your DM i send all the src

shell zephyr

How do I make rpc work if discord is closed and then opened again????

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

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

That sounds like unnecessary amount of requests

dawn ginkgo
primal ingot

Is rpc even possible in android? PikaThink

karmic jolt

no

primal ingot

Why?

karmic jolt

because the mobile app does not have an rpc server

primal ingot

Ohh ohk

primal ingot
karmic jolt

browser doesn't work on any device

it needs to be the desktop app

primal ingot

Ohk ty

terse shadow

Is it possible to set a custom activity for RPC? Like streaming, listening, or even a custom one if possible?

left fjord

Not really

terse shadow

thanks!

glad sundial

When I upload an image to the rpc section of my application, it deletes it automatically when I refresh the page. Why is this?

left fjord

did you save?

shell zephyr

this is why:

left fjord

what

shell zephyr

someone help 😦

shell zephyr

does anyone know how to add the 'join' button?

pls help

dnfsdkfbndsjkfsdb ffdjkgfdnbgkdfjgbdfhjgfbdgjhfdgbdrft

mystic flint

stop spamming

shell zephyr
unkempt meadow

anyone knows if is it possible to insert links here?

carmine mica

it isn't

fathom lion
fathom lion
fathom lion
shell zephyr

@fathom lion tysm but idk where to find the joinGame() method

and how do i check for a broken connection?

fathom lion

I think the rpc client emits 'disconnected' that is a good start. Also if the connection fails, an error is thrown

joinGame is probably in discord docs, that's what it was called before

rpc.subscribe('ACTIVITY_JOIN', ...

fathom lion
shell zephyr

thanks

smoky scroll

what is the problem

left fjord

you tell us

smoky scroll

I get this error when doing button discord rpc

shell zephyr
carmine mica

on error make new client

shell zephyr

hmmm im kinda bad at this cuz my rpc doesn't work:

  1. when discord is started after my app
  2. on app restart
shell zephyr

cuz im stuck on rpc

carmine mica

decide what you consider to be an error that implies reconnecting is needed

and when that happens

create a new client

shell zephyr

and login?

carmine mica

ya

shell zephyr

so onError() {
rpc = new DiscordRPC.Client({transport: 'ipc'});
rpc.login();
}

cool, thanks

shell zephyr

every time i try

why?

and invites don't work

wth

so what is transmitted matchSecret or joinSecret?

@carmine mica now my status is stuck as well

///////////////////////////////////
//          Discord RPC          //
///////////////////////////////////

// RPC Login Code.
const DiscordRPC = require('discord-rpc');
const { time } = require('console');
const { electron, chrome } = require('process');
const { webContents } = require('electron');
DiscordRPC.register('797056762649247745');
let rpc = new DiscordRPC.Client({transport: 'ipc'});

function initRPC() {
    rpc = new DiscordRPC.Client({transport: 'ipc'});
    rpc.login( {clientId: '797056762649247745'} );
    rpc.addListener('ACTIVITY_JOIN', (args) => {
        args = args.split('.');
        let gameID = args[0];

        window.location(`https://krunker.io/?game=${gameID}`);
    });
    rpc.addListener('ACTIVITY_JOIN_REQUEST', (args) => {
        rpc.sendJoinInvite(args['user']['id']);
    });
}

initRPC();

// RPC Status Code.

let gameData = null;
setInterval(() => {
    let data = fetch(`https://matchmaker.krunker.io/game-info?game=${new URLSearchParams(location.search).get('game')}`)
    .then(r => r.json())
    .then(rData => {
        gameData = rData;
    }) .catch(err => {});
},1000);

var setActivity = setInterval(() => {
    if(!rpc) {
        return;
    }
    // Get all variables here.
    {...}
    // Set activity
    rpc.setActivity({
        largeImageKey: "thumbnail",
        largeImageText: `Kills: ${kills} | Deaths: ${deaths} | Score: ${score}`,
        smallImageKey: classNameEdit,
        smallImageText: "Playing as " + className,
        details: gameData[4].i,
        state: gameType,
        partySize: gameData[2],
        partyMax: gameData[3],
        startTimestamp: t1,
        endTimestamp: t2,
        instance: true,
        joinSecret: new URLSearchParams(location.search).get('game')
    }) .catch(err => {
        initRPC();
    });
}, 100);
fathom lion

add js to your codeblock like this:
```js
code here
```

let rpc = new DiscordRPC.Client({transport: 'ipc'}); this get overwritten

if(!rpc) { isn't this always true? not sure how Client casts to bool

.catch(err => {
        initRPC();
    })

pretty sure you don't want to init another client when you fail to set activity, activity can fail on reasons other than the client missing

fathom lion
shell zephyr

tysm @fathom lion once again

shell zephyr
shell zephyr
fathom lion

rpc.on('disconnected' or look what the event is called

shell zephyr

vs code shows me:

or do I sub to the event

fathom lion

idk what else to say other than you don't have any reason to always trust your IDE...

bright moon

client.request('SET_ACTIVITY', {});
as the inputs for the request, for the imageText should i add it on the assets or the main activity ?
and what should i call that? like largeImageText or what?

fathom lion

rpc.setActivity is already a function that does everything activity related, isn't it?

No need make a raw request yourself

bright moon
fathom lion

Then just copy paste the code from source/github (which might even already have button support)?

bright moon

well the only code i got is without imageText

fathom lion
bright moon

wait u mean djs-rpc is updated?

fathom lion

Probably not released, but buttons are working on master

bright moon

i installed djs-rpc from npm, should i install the master from github or it will work on the last npm too?

cuz last publish on npm is 4 month ago

fathom lion

If you manually call the request same way it is done on master then it should work

(but idk how npm works or how you package your app or anything so ymmv)

bright moon

im asking about largeImageText where should i call that? on the assets or the main activity ?

or even largeImageText is a true thing to call?

fathom lion

Large image text is just a string. It's the tooltip that appear when you hover over the large image

So wdym you want to call that

bright moon

look

we are sending a request with data right?

for having largeImage on our rpc we call that like this in assets on activity :

{
        pid: process.pid,
        activity: {
            assets: {
                large_image: 'pfp4'
            },
            details: 'tt',
            state: 'tt',
            buttons: [
                { label: 'label', url: 'url' }
            ]
        }
    }

you see we call it large_image in here for the sending raw request

so for the largeImageText what should we call it? and were should we call it?

i know raw events are different and i couldn't find anything on discord docs

fathom lion

An you couldn't look at the source code or read the discord documentation? You need to name that key "large_text"

bright moon
fathom lion

I'm on mobile but this is what djs does

bright moon
idle lichen

@fathom lion Can you tell which mobile application you are making code from?

Can I activate my bot from the application you made a code for?

fathom lion

the image is a screenshot of github, wdym "making code from" ???

smoky scroll

so im getting an error when setting up a discord-rpc module

all my packages are corrct

can anybody tell me whats wrong by looking at the error because i dont want to give out my client ids

fallen ginkgo

is anyone familiar with the code for discord rich presence?

im kinda new to js and i was just wondering what are the limitations

smoky scroll

Is it possible to make the join button take you to a link with a url parameter?

fallen ginkgo

yes!

smoky scroll
left fjord

it's literally above

fallen ginkgo
smoky scroll

Is it possible for the game join button?
Not the custom ones

left fjord

not really

proud loom

what are you trying to do? are you a game developer?

smoky scroll
sacred ore

ya no

join secrets are produced by the discord sdk, you cant really do that with a link

smoky scroll

Hey so, i've been trying to setup the RPC client, which causes an error, this is the code:

let rpc = (new (require('discord-rpc')).Client({
    transport: 'ipc'
}));

rpc.on('ready', async () => rpc.request('SET_ACTIVITY', {
    pid: process.pid,
    activity: {
        state: 'Invite the bot and join us!',
        details: 'Entertainment',
        assets: {
            large_text: 'VXC'
        },
        buttons: [{
            label: 'Invite',
            url: '<Some URL>'
        }]
    }
}));

rpc.login({
    clientId: '<Client ID>',
    clientSecret: '<Client secret>'
});```
And this is the error:
```js
Error: Could not connect```
Am i missing something?
sacred ore

dont use rpc.request, and also you dont need clientSecret

smoky scroll

Should i use <RPCClient>#setActivity() instead?

sacred ore

yes

smoky scroll

K lemme try

Still getting the same error

sacred ore

show current code

smoky scroll
let rpc = (new (require('discord-rpc')).Client({
    transport: 'ipc'
}));

rpc.on('ready', async () => rpc.setActivity({
    state: 'Invite the bot and join us!',
    details: 'Entertainment',
    largeImageText: 'VXC',
    buttons: [{
        label: 'Invite',
        url: '<Some URL>'
    }]
}));

rpc.login({
    clientId: bot.user.id
});```
sacred ore

put the whole set activity inside brackets

rpc.on('ready', async () => {
rpc.setActivity({
//stuff here
})
})```
smoky scroll

I don't think that would change anything tho, just arrow function syntax

sacred ore

it shouldnt

but ya know

some things are stupid

smoky scroll
let rpc = (new (require('discord-rpc')).Client({
    transport: 'ipc'
}));

rpc.on('ready', async () => {
    return rpc.setActivity({
        state: 'Invite the bot and join us!',
        details: 'Entertainment',
        largeImageText: 'VXC',
        buttons: [{
            label: 'Invite',
            url: '<Some URL>'
        }]
    });
});

rpc.login({
    clientId: bot.user.id
});``` Same thing
sacred ore

hm odd

i dont know if its needed or not, but do you have rich presence assets added to the bot?

smoky scroll

I do, at least one

sacred ore

how come its not listed in the setActivity

smoky scroll

Huh?

sacred ore

largeImageKey

smoky scroll

I don't think the issue is even related to that method

It's from <RPCClient>#login()

sacred ore

well i have no fuckin idea cuz thats what i have

smoky scroll

Odd

sacred ore

rpc.login({ clientId }).catch(e => { console.log(e) });

smoky scroll

Lemme see

Seems like it's coming from here

sacred ore

ik im looking at it rn

its coming from line 35

and i cant figure out why

actually no

wtf

terse shadow
Error: connection closed
    at IPCTransport.<anonymous> (project path\node_modules\←[4mdiscord-rpc←[24m\src\client.js:118:16)
←[90m    at Object.onceWrapper (node:events:483:26)←[39m
←[90m    at IPCTransport.emit (node:events:376:20)←[39m
    at project path\node_modules\←[4mdiscord-rpc←[24m\src\transports\ipc.js:141:18
    at decode (project path\node_modules\←[4mdiscord-rpc←[24m\src\transports\ipc.js:92:5)
    at Socket.<anonymous> (project path\node_modules\←[4mdiscord-rpc←[24m\src\transports\ipc.js:120:7)
←[90m    at Socket.emit (node:events:376:20)←[39m
←[90m    at emitReadable_ (node:internal/streams/readable:565:12)←[39m
←[90m    at processTicksAndRejections (node:internal/process/task_queues:79:21)←[39m

Process finished with exit code 1```
why can't I log in?
sacred ore

show the code

terse shadow
const RPC = require('discord-rpc');
const rpc = new RPC.Client({transport: 'ipc'});
rpc.on('ready', async () => {
    await rpc.setActivity({
        startTimestamp: new Date(),
        buttons : [
            {
                label : "test",
                url : "https://youtu.be/dQw4w9WgXcQ"
            }
        ]
    });
    console.log("RPC set");
});

rpc.login({clientId: "95879008242761739"});```

but my IDE is messing up the params, such as

and

sacred ore

are you sure you have the right discord-rpc?

smoky scroll

Wait, the reason might be because I'm trying to open an RPCClient in the same place where I'm hosting my bot? @sacred ore

sacred ore
terse shadow

I installed from discordjs/rpc, isn't that stable?

smoky scroll

Hmm strange

karmic jolt

that could very well be the reason

it needs to run on the same pc where discord is open

smoky scroll

Wait what

sacred ore

ah yea i forgot it needs to connect to the client on the computer

karmic jolt

you cannot host ipc connections on a vps or similar

smoky scroll

Damn, lemme see

sacred ore

yea rpc only works if its able to find a running discord process.

terse shadow

is it possible to run Discord on a VPS then? lol

sacred ore

uh i mean, sure?

it would take some work

ive done it before tho.

but youre probably just better off hosting it on the pc instead of wasting resources on discord running

smoky scroll

Wait, does it seriously have to be done on a PC? Not possible with mobile using for example Termux?

sacred ore

yea it doesnt work using the mobile app either im p sure

smoky scroll

Damn, at least we tried thinkingLol

sacred ore

its why i like hosting my bot on my pc

cuz i can just include it in the bot file

smoky scroll

You're not using a VPS for your bot?

sacred ore

hell no

smoky scroll

Welp, i'll try again when i get a PC soon KEKW

sacred ore

alright 🤣

shell zephyr

// RPC Login Code.
const DiscordRPC = require('discord-rpc');
const { time } = require('console');
const { electron, chrome } = require('process');
const { webContents } = require('electron');
DiscordRPC.register('797056762649247745');
let rpc = new DiscordRPC.Client({transport: 'ipc'});

function initRPC() {
    let rpc = new DiscordRPC.Client({transport: 'ipc'});
    rpc.login( {clientId: '797056762649247745'} ) .then(() => {
        rpc.subscribe('ACTIVITY_JOIN', (args) => {
            args = args.split('.');
            let gameID = args[0];
    
            window.location(`https://krunker.io/?game=${gameID}`);
        });
        rpc.subscribe('ACTIVITY_JOIN_REQUEST', (args) => {
            rpc.sendJoinInvite(args['user']['id']);
        });
    }) .catch(err => {});
}

initRPC();

// RPC Status Code.

let gameData = null;
setInterval(() => {
    let data = fetch(`https://matchmaker.krunker.io/game-info?game=${new URLSearchParams(location.search).get('game')}`)
    .then(r => r.json())
    .then(rData => {
        gameData = rData;
    }) .catch(err => {});
},1000);

setInterval(() => {
    {...}
    rpc.setActivity({
        largeImageKey: "thumbnail",
        largeImageText: `Kills: ${kills} | Deaths: ${deaths} | Score: ${score}`,
        smallImageKey: classNameEdit,
        smallImageText: "Playing as " + className,
        details: gameData[4].i,
        state: gameType,
        partySize: gameData[2],
        partyMax: gameData[3],
        startTimestamp: t1,
        endTimestamp: t2,
        instance: true,
        joinSecret: new URLSearchParams(location.search).get('game')
    }) .catch(err => {
        initRPC();
    });
}, 100);
``` This is what I have so far, still not working 😦

Just spams me with RPC_TIMEOUT

rocky mesa

?code

turbid oliveBOT

Codeblocks:
```js
const Discord = require("discord.js");
// further code
```
becomes

const Discord = require("discord.js"); 
// further code

Inline Codeblocks:
`console.log('inline!');` becomes console.log('inline!');

slow pine

UnhandledPromiseRejectionWarning: Error: Could not connect

waxen gazelle

are you using websocket or ipc transport

smoky scroll

Hi, What is is Discord-Rpc?

fathom lion

rpc is what allows other applications to talk to discord

it is mostly used for rich presence

smoky scroll

Ah, I see tnx

lapis flicker

This

The "Playing a game"

o

wait

i didnt scroll down lmfao

hidden drum

I want to use discord-rpc for status however it errors ```js
UnhandledPromiseRejectionWarning: Error: child "activity" fails because [child "assets" fails because [child "small_image" fails because ["small_image" is not allowed to be empty]]]

Because I dont want a small image
hidden drum
halcyon hill

@hidden drum question: can you click on the buttons in my presence to see if they work? They're not working for me

idk if its just me tho

lapis flicker

I dont know how to do discordrpc with disocrd.js

Only java

halcyon hill

yay!

these new buttons are fun :)

hidden drum

can you tell me the code of it? I want to remove small image and yours doesnt have one so I can copy that part?

@halcyon hill

halcyon hill

@hidden drum

import RPC from 'discord-rpc'

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

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

    client.request('SET_ACTIVITY', {
        pid: process.pid,
        activity: {
            assets: {
                large_image: 'lnb'
            },
            details: 'The best multipurpose Discord bot!',
            buttons: [
                { label: 'Check out the bot!', url: 'https://top.gg/bot/646156214237003777' },
                { label: 'More about me!', url: 'https://t1c.dev/' }
            ]
        }
      })

    console.log('started!')
})

client.login({clientId: '799340370059591741'})
hidden drum

Ok

Thanks

halcyon hill

np!

slow pine

when i do websocket i get this error```
(node:24194) UnhandledPromiseRejectionWarning: Error: connection closed

waxen gazelle
waxen gazelle
slow pine ipc

hm, can you try closing it, fully quitting discord, reopening discord, and running it again?

slow pine

so reload? PsySweat

waxen gazelle

oh

you cant do it with browser

slow pine

rip 😐

waxen gazelle

you need a running desktop client

slow pine

i have the app tho 😳

waxen gazelle

then run it?

slow pine

ok

do i close the browser

ayy pog it worked

when i press the button it doesn't do anything 😳

storm apex

you cant click your own buttons

slow pine

oh does it work for you?

storm apex

yes, they work

slow pine

k good 😳

fathom lion

You probably want to log in with test user in canary to test stuff like this

If you need two users to both have a presence you can modify rpc source code to connect to ID 1 client

slow pine

nvm

void creek

will it be considered as API Abuse if i use discord.js and discord-rpc to make something which can change the text in your RPC using bot commands? like

!setuppertext this is pog
fathom lion

idk how that would work tho, isn't oauth whitelisted, or is it only whitelisted on browser?

Like, if a user needs to download an app to set their custom status, that app could have UI to do that, not everything needs to be a command

versed crater

Ok

void creek

like only for me

and open source on github if people wanna set it up for themselves

karmic jolt

sure, you could do that

void creek

ty

idle cliff

In client.js, _onRpcMessage(message) https://github.com/discordjs/RPC/blob/master/src/client.js#L194

      const subid = subKey(message.evt, message.args);
      if (!this._subscriptions.has(subid)) {
        return;
      }
      this._subscriptions.get(subid)(message.data);```

Isn't it a mistake ? Rpc events seems to send back args in "data" field, therefore "args" field is always undefined and RPC subscription doesn't work
craggy boughBOT
pliant walrus

im trying to use rpc and i have this code:

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


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

  rpc.setActivity({
    details: 'Konatz bot,',
    state: 'is the best bot.',
    largeImageKey: 'snek_small',
    largeImageText: 'BOII',
    buttons: [{ label: 'Invite Me!', url: 'https://discord.com/oauth2/authorize?client_id=787531329587118100&permissions=8&scope=bot'}, { label: 'Join my test server!', url: '<INVITE>'}],
    instance: false,
  });
}

rpc.on('ready', () => {
  setActivity();
  client.log('success', 'RPC', 'CONNECTED!')

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

rpc.login({ clientId }).catch(e => { console.log('error', 'RPC_ERR', e) });

but i keep getting this error:

error RPC_ERR Error: connection closed
    at IPCTransport.<anonymous> (/Users/admin/Desktop/konatz bot/node_modules/discord-rpc/src/client.js:118:16)
    at Object.onceWrapper (events.js:422:26)
    at IPCTransport.emit (events.js:315:20)
    at /Users/admin/Desktop/konatz bot/node_modules/discord-rpc/src/transports/ipc.js:137:18
    at decode (/Users/admin/Desktop/konatz bot/node_modules/discord-rpc/src/transports/ipc.js:92:5)
    at Socket.<anonymous> (/Users/admin/Desktop/konatz bot/node_modules/discord-rpc/src/transports/ipc.js:120:7)
    at Socket.emit (events.js:315:20)
    at emitReadable_ (_stream_readable.js:569:12)
    at processTicksAndRejections (internal/process/task_queues.js:79:21)
bright moon
pliant walrus
karmic jolt

you're supposed to pass the id of an application, not your user id

pliant walrus

?

karmic jolt

clientId is currently your user id

it should be an application id though

pliant walrus
karmic jolt

sure

bright moon

you can see client id on your discord application page

karmic jolt

you can also create a new application for rpc

pliant walrus

oh it worked

but

my buttons arent working now

karmic jolt

did you install it from npm or github?

pliant walrus

discord-rpc?

karmic jolt

yes

pliant walrus

i did this in terminal

npm i discord-rpc

karmic jolt

ah, the npm version doesnt support buttons yet

pliant walrus

oof

how do i do the github one

karmic jolt

you need to do npm i discordjs/rpc, requires git to be installed

pliant walrus

do i do npm i git to ghet git?

karmic jolt
pliant walrus

do i also need git-gui?

karmic jolt

don't think so

pliant walrus

k

i ran the brew install git

and it says updating homebrew

now its downloading

karmic jolt

that should be fine

pliant walrus

k

done

ill run npm i discordjs/rpc

@karmic jolt thx so much it works now

smoky scroll
var RPC = require('discord-rpc')
const client = new RPC.Client({ transport: 'ipc' })
client.on('ready', () => {
    client.request('SET_ACTIVITY', {
        pid: process.pid,
        activity: {
            assets: {
            },
            buttons: [
                { label: 'GangRP Discord Server', url: 'https://discord.gg/nuUygHnns2' }
            ]
        }
      })
    console.log('Started')
})
client.login({clientId: '799807572752072724'}).catch(console.error)```
buttont don't to somthing
vestal moss
sacred ore

you cannot click on your own rpc buttons

idky why

smoky scroll

in your rpc i can

@sacred ore

sacred ore

ik

but

you arent able to click ur own buttons

it wont open anything

have no idea why discord would do that but whatever

smoky scroll

@sacred ore

 buttons: [{ label: 'Invite Plexi', url: 'URL'}, { label: 'Join Discord', url: 'INVITE'}],

this is what i have

it still dosent work tho

sacred ore

lemme see full code

Does it log an error

smoky scroll

nope

hold on

sacred ore

btw, urls cant be more than 32 chars

that might be an error

discord oauth invites are always more than that

smoky scroll

its a bit messy rn but it works

const DiscordRPC = require('discord-rpc')
const clientId = 'INSERT CLIENT ID HERE';
const rpc = new DiscordRPC.Client({ transport: 'ipc' });
const client = new DiscordRPC.Client({ transport: 'ipc' });

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

  rpc.setActivity({
    details: 'Support Small',
    state: 'Bot Developers!',
    largeImageKey: 'plexi',
    largeImageText: 'Plexi | Discord Bot',
    buttons: [{ label: 'Invite Plexi', url: 'INVITE URL'}, { label: 'Join Discord', url: 'ALSO URL'}],
    instance: false,
  });
}

rpc.on('ready', () => {
  setActivity();
console.log("working!")
  setInterval(() => {
    setActivity();
  }, 15e3);
});

rpc.login({ clientId }).catch(e => { console.log('error', 'RPC_ERR', e) });```
sacred ore

why is there two clients?

no ur issue

just weird

smoky scroll

idk i took this from someone

sacred ore

also, how long is the bot invite

smoky scroll

imma change it, but

sacred ore
smoky scroll
sacred ore

hm weird

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


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

  rpc.setActivity({
    details: 'I am a fairly new bot,',
    state: 'but ill do.',
    largeImageKey: 'snek_small',
    largeImageText: 'BOII',
    buttons: [{ label: 'Invite Me!', url: 'https://synyster.page.link/Eit5'}, { label: 'Join my server!', url: 'http://gg.synyster.org'}],
    instance: false,
  });
}

rpc.on('ready', () => {
  setActivity();
  client.log('success', 'RPC', 'CONNECTED!')

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

rpc.login({ clientId }).catch(e => { client.log('error', 'RPC_ERR', e) });```

this is the code u stole

smoky scroll

kek yeah

sacred ore

which in turn is basically just the example with tweaks

smoky scroll

it might be because of my internet connection rn

sacred ore

no

smoky scroll

im currently on a 50kbps connection

karmic jolt

did you install discord-rpc from npm or github

smoky scroll
sacred ore

u sure?

smoky scroll

yes lmfao

sacred ore

rpc master should have buttons so idk

karmic jolt

can you npm ls discord-rpc then, should also give the commit hash

smoky scroll

i thought i installed the github version

sacred ore

but u didnt

smoky scroll

i guess not, lets try again

kek

sacred ore

discordjs/RPC#cbdd31f98b20de0222a793ae0b14018f8119cfb2 heres my commit hash btw

this one is confirmed working so

smoky scroll
hardy arrow

Does the main branch support buttons?

left fjord

probably

sleek quiver

Personally i like to use the discord-rich-presence module for ease

sacred ore

even tho ur talking the discord-rpc chat

left fjord

what

you know that discord-rich-presence is a simple wrapper for discord-rpc, made by same person?

sacred ore

ohs hit really, wow im dumb

wait, why would it need a wrapper already

left fjord

as opposed to

sacred ore

so its just qol

got it

smoky scroll

where can i start learning rpc

sacred ore

what exactly u need to know

iron yew

would rpc only work on browser or can it even work on the desktop?

sacred ore

other way around, only works on desktop

iron yew

i use desktop but i keep getting an err of Could not connect

sacred ore

show code

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

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

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

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

just the one from the example really, just tryna mess with it

sacred ore

remove scopes

iron yew

even const scopes = ['rpc', 'rpc.api', 'messages.read']; ?

sacred ore

yes

remove it from both login and the const

and also

iron yew

client id is the one from the application right?

sacred ore

use ipc instead of websocket

and yes

iron yew

do i need to do anything specific there?

just make an application i need the clientid correct?

sacred ore

the clients application id

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

iron yew

did that

sacred ore

alright

and do you have the clients id in there

iron yew

(node:3556) UnhandledPromiseRejectionWarning: Error: Could not connect

sacred ore

show current code

iron yew
const RPC = require("discord-rpc");

const clientId = ';

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

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

});

client.login({ clientId  });
sacred ore

full code, including the client id

iron yew
const RPC = require("discord-rpc");

const clientId = '736309841378672641';

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

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

});

client.login({ clientId  });
sacred ore

and this is on the same computer as discord right, not on a vps or somethingother

iron yew

yeah i have discord on my desktop and im running the code on glitch cause im just testing

sacred ore

wont work on glitch

has to be ran on ur computer

iron yew

ohhh

sacred ore

ye

iron yew

wait so i would need to install

node etc?

sacred ore

if its not installed alr on ur pc

then yes

iron yew

u cant just run this via plain vsc correct?

sacred ore

yes u can

iron yew

wait how

sacred ore

terminal

node .

lol

iron yew

1s lemme open it rq

sorry i dont use alot stuff in terminal xd

'node' is not recognized as an internal or external command, operable program or batch file. yeah i need to get node cuz i dont run cmds on terminal

i just have all my stuff on a vps

sacred ore

yea just search up node.js and get the bin for windows

iron yew

LTS or current?

sacred ore

current

wait no

lts has the updates

too

so just get lts

iron yew

alr

14.15.4

sacred ore

yee thats fine

iron yew

well i installed node

when i use node . i get an err which i dont quite get

although i did do npm install discord-rpc and it worked and its installed

sacred ore

lemm see the err

iron yew

Error: Cannot find module' and then it just says the location of where i opened my workspace

do i need to run something in the node cmd prompt?

sacred ore

let me see the directory

iron yew

wait node and the vsc file location arent in the same area, how do i change where my node packages install? from like the node cmd prompt

sacred ore

node packages should install to project dir

is the terminal not in ur project dir ?

iron yew

no like if i open terminal in vsc and run npm install discord-rpc

it installs that to my workspace area but

if i do the same thing in the node command prompt

it installs it somewhere else

so how do i change the node command prompt download area

sacred ore

because npm installs to the current directory lol

send a ss of project dir

iron yew

1s

wait so what do u want me to send again?

sacred ore

project dir

the directory with your rpc index file

iron yew

ah 1s

this?

sacred ore

you dont have a package.json

run npm init

iron yew

yeah i realised

made it

sacred ore

did it work?

iron yew

how would i run it

sacred ore

node .