This commit is contained in:
parent
cc9693ebd7
commit
372eaf589b
BIN
JS-SDK/bun.lockb
BIN
JS-SDK/bun.lockb
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "usetether",
|
||||
"version": "1.1.7",
|
||||
"version": "1.1.8",
|
||||
"author": "Braydon (Rainnny) <braydonrainnny@gmail.com>",
|
||||
"description": "An API designed to provide real-time access to a user's Discord data.",
|
||||
"keywords": [
|
||||
@ -28,7 +28,6 @@
|
||||
"devDependencies": {
|
||||
"@types/bun": "latest",
|
||||
"@types/react": "^18.3.5",
|
||||
"@types/react-dom": "^18.3.0",
|
||||
"react": "^18.3.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
|
||||
import { Snowflake } from "@/types/snowflake";
|
||||
import { TetherConfig } from "@/types/config";
|
||||
import { DiscordUser } from "@/types/user";
|
||||
import { SocketPacket, UserStatusPacket } from "@/types/socket";
|
||||
import { UserStatusPacket } from "@/types/socket";
|
||||
|
||||
export const useTetherWS = (
|
||||
snowflake: Snowflake,
|
||||
@ -39,12 +39,12 @@ export const useTetherWS = (
|
||||
socket.addEventListener("close", connect); // Reconnect on close
|
||||
|
||||
socket.addEventListener("message", (event) => {
|
||||
const packet: SocketPacket = JSON.parse(
|
||||
const statusPacket: UserStatusPacket = JSON.parse(
|
||||
event.data
|
||||
) as SocketPacket;
|
||||
if (packet.op === 1) {
|
||||
setUser((packet as UserStatusPacket).user);
|
||||
console.log("user status update", user);
|
||||
) as UserStatusPacket;
|
||||
if (statusPacket.op === 1) {
|
||||
setUser(statusPacket.user);
|
||||
console.log("user status update", statusPacket.user);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { DiscordUser } from "@/types/user";
|
||||
|
||||
export type SocketPacket = {
|
||||
type SocketPacket = {
|
||||
/**
|
||||
* The OP code for this packet.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user