-
Notifications
You must be signed in to change notification settings - Fork 0
Discord WebSocket
HyperGaming99 edited this page Jul 13, 2026
·
1 revision
Öffne die in DISCORD_WS_PUBLIC_URL konfigurierte Adresse, normalerweise:
wss://0x79.one/discord/socket
const socket = new WebSocket('wss://0x79.one/discord/socket');
socket.addEventListener('message', ({ data }) => {
const message = JSON.parse(data);
if (message.op === 1) {
socket.send(JSON.stringify({
op: 2,
d: { subscribe_to_id: '925802573506674729' }
}));
setInterval(() => {
socket.send(JSON.stringify({ op: 3 }));
}, message.d.heartbeat_interval);
}
if (message.t === 'INIT_STATE' || message.t === 'PRESENCE_UPDATE') {
console.log(message.d);
}
});| Opcode oder Event | Richtung | Bedeutung |
|---|---|---|
op 1 |
Server → Client | Hello mit heartbeat_interval
|
op 2 |
Client → Server | Abo über subscribe_to_id oder subscribe_to_ids
|
op 3 |
Beide | Heartbeat und Bestätigung |
op 4 |
Client → Server | Abmelden über unsubscribe_from_id(s)
|
INIT_STATE |
Server → Client | Zustand direkt nach dem Abo |
PRESENCE_UPDATE |
Server → Client | Live-Update einer abonnierten ID |
Pro Verbindung sind maximal 100 IDs erlaubt. subscribe_to_all funktioniert nur, wenn der Betreiber DISCORD_WS_ALLOW_SUBSCRIBE_ALL=true aktiviert hat.