Websocket

URL

wss://api.vcodes.xyz/v1/gateway?token={TOKEN}

Events

You can see the events on the Events page.
1
module.exports = class vCodes extends EventEmitter {
2
constructor(token) {
3
super();
4
this.ws = new WebSocket("wss://api.vcodes.xyz/v1/gateway?token=" + token);
5
this.ws.on("message", async msg => {
6
const message = JSON.parse(msg.toString());
7
if (message.type == "ERROR") throw new Error("(vcodes.js): " + message.message);
8
if (message.type == "CONNECT") {
9
this.token = token
10
return this.emit("ready", message.data);
11
}
12
13
const _event = message.type
14
.toLowerCase()
15
.split("_")
16
.map((part, index) => {
17
if (index == 0) return part;
18
return part.charAt(0).toUpperCase() + part.slice(1);
19
});
20
21
this.emit(_event.join(""), message.data);
22
});
23
};
24
};
Copied!
1
const myModule = require('./libs/module.js');
2
const _myModule = new myModule("token");
3
4
_myModule.on("ready", () => {
5
console.log("Ready event triggered");
6
});
Copied!
Export as PDF
Copy link