Comments (17)
For javscript, You can copy all the codes from the gateway folder from kizzy-demo-ts repository.
It has some basic things implemented, you can add the rest by yourself.
If by nodejs
you meant your app won't be able to access browser apis then you just need to replace browser Websocket with Websocket from ws
library.
from kizzy.
For javscript, You can copy all the codes from the gateway folder from kizzy-demo-ts repository.
It has some basic things implemented, you can add the rest by yourself.
If by
nodejs
you meant your app won't be able to access browser apis then you just need to replace browser Websocket with Websocket fromws
library.
This repository is being of great help because I still hadn't found anything about it unfortunately I didn't understand the functions very much because I'm not familiar with the typescript
from kizzy.
Looking at your code, I was able to contact myself in Javascript but I didn't get where I wanted ;) the custom rich precense can you help me? Follow the code
import WebSocket from 'ws';
const OpCodes = {
Hello: 10,
Heartbeat: 1,
Dispatch: 0,
Reconnect: 7,
InvalidSession: 9,
};
const token = 'TOKEN';
const ws = new WebSocket('wss://gateway.discord.gg/?v=9&encoding=json');
let seq = 0;
let session_id = "";
let resume_gateway_url = "";
ws.on("open", () => {
console.log("Socket Opened");
ws.send(send(identify(token)));
});
ws.on("message", (event) => {
const message = event.toString("utf8");
const { t, op, d } = JSON.parse(message);
switch (op) {
case OpCodes.Hello:
console.log('Got op 10 HELLO');
const { heartbeat_interval } = d;
heartbeat(heartbeat_interval, seq);
send(identify(token));
break;
case OpCodes.Heartbeat:
console.log("Got Op 1 Sending Heartbeat");
ws.send({
op: OpCodes.Heartbeat,
d: seq === 0 ? null : seq.toString(),
});
break;
case OpCodes.Dispatch:
if (!t) return;
switch (t) {
case 'READY':
console.log('Received READY event');
const { user } = d;
ws.emit('open', user);
session_id = d.session_id;
resume_gateway_url = d.resume_gateway_url;
break;
default:
break;
}
break;
case OpCodes.Reconnect:
console.log("Got op 7 Closing and Reconnecting Session");
ws.close(4000);
break;
case OpCodes.InvalidSession:
console.log("Got Op 9 Reconnect Failed");
ws.send(identify(token));
break;
default:
console.log("Received unknown message:", parsedData);
}
});
function heartbeat(ms, seq) {
setInterval(() => {
return setInterval(() => {
send({ op: OpCodes.Heartbeat, d: seq });
}, ms);
});
};
function send(data) {
ws.send(JSON.stringify(data))
}
async function identify(token) {
if (!token) {
new Error('Token Not Specified')
}
return {
op: 2,
d: {
token: token,
properties: {
$os: "disco",
$browser: "chrome",
$device: "chrome",
},
compress: false,
capabilities: 65,
largeThreshold: 100
}
};
};
from kizzy.
Uh, I think you only need to import ws and replace the Websocket
with one from ws
then you can just use it like what's described in the readme file
import { Client } from "@dead8309/kizzy-rpc";
const client = new Client();
client.on("ready", () => {
client.user?.setActivity({
name: "Hey"
});
});
client.login(TOKEN);
from kizzy.
I don't understand anything ,-,
from kizzy.
Uh, I think you only need to import ws and replace the
Websocket
with one fromws
then you can just use it like what's described in the readme fileimport { Client } from "@dead8309/kizzy-rpc"; const client = new Client(); client.on("ready", () => { client.user?.setActivity({ name: "Hey" }); }); client.login(TOKEN);
The token has the scope of everything in rpc:
$ tsnd --respawn --transpile-only rpc.ts [INFO] 01:13:53 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.1, typescript ver. 5.1.6)
Socket Opened
Got op 10 HELLO
Authentication failed.
from kizzy.
https://github.com/sebastianjnuwu/gateway
from kizzy.
Socket Opened Got op 10 HELLO Authentication failed.
You need to pass in your token
from kizzy.
Socket Opened Got op 10 HELLO Autenticação falhou.
Você precisa passar seu token
But I passed, the user token takes it, right? Can you test the code you made and see if the rpc shows up? I made some changes see there
from kizzy.
But I passed, the user token takes it, right? Can you test the code you made and see if the rpc shows up? I made some changes see there
Yes it works fine. maybe you did something wrong ?
from kizzy.
But I passed, the user token takes it, right? Can you test the code you made and see if the rpc shows up? I made some changes see there
Yes it works fine. maybe you did something wrong ?
So what I did:
• I made the authorization link and marked everything from rpc in discord Developers
• I took the authorization link code and generated the user token
• I put it in the code and ran yarn and yarn dev
from kizzy.
Gateway needs user token not oauth token
from kizzy.
Gateway needs user token not oauth token
? When you logon to your rpc site it says that user is undefined
from kizzy.
I think that's why it's failing authentication all the time;
Putting the email and password on your correct website comes to me:
from kizzy.
const client = new Client();
client.on("ready", (user) => {
console.log(user) // idl
client.user?.setActivity({
name: "Hey"
});
});
from kizzy.
Login through email and password is still experimental in that site, you need to use token
from kizzy.
O login por e-mail e senha ainda é experimental nesse site, você precisa usar token
Using the token it says error "4000" or "4003" that it was not possible to connect like my code
from kizzy.
Related Issues (20)
- Choose Activity Status HOT 2
- Easier app Detection management HOT 1
- Duplicate "exit" buttons.
- Spotify media bar HOT 7
- Incorrect Timestamps when playing music. HOT 5
- Kizzy crashes in android 11 HOT 2
- rps not working HOT 6
- wrong date time. HOT 1
- Unable to give access to notification access HOT 1
- I cant login to my discord HOT 1
- App detection RPC stops after a moment HOT 2
- Discord RPC limits from 2 to 3 minutes HOT 4
- Use "global_name" instead of "username"
- 24 hr format for timestamps
- Remove parameters from attachment URLS
- Show Album name (Media RPC)
- Detecting paused media HOT 2
- Please increase versionCode with each release HOT 1
- "Listening to" instead of "Playing" when using Media Rpc HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kizzy.