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