only allow clients to run this function
All checks were successful
Publish JS SDK / docker (push) Successful in 18s

This commit is contained in:
Braydon 2024-09-09 20:00:38 -04:00
parent 2b5e14b734
commit 3021920142
6 changed files with 16 additions and 17 deletions

@ -1,6 +1,6 @@
{ {
"name": "usetether", "name": "usetether",
"version": "1.0.6", "version": "1.0.7",
"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": [

@ -1,7 +1,7 @@
import TetherConfig from "@/types/config";
import DiscordUser from "@/types/user";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import Snowflake from "@/types/snowflake"; import { Snowflake } from "@/types/snowflake";
import { TetherConfig } from "@/types/config";
import { DiscordUser } from "@/types/user";
export const useTetherWS = ( export const useTetherWS = (
snowflake: Snowflake, snowflake: Snowflake,
@ -14,6 +14,10 @@ export const useTetherWS = (
const url: string = `ws${secure && "s"}://${endpoint}/gateway`; const url: string = `ws${secure && "s"}://${endpoint}/gateway`;
useEffect(() => { useEffect(() => {
// Prevent from running on the server
if (typeof window === "undefined") {
return;
}
let socket: WebSocket; // The current WebSocket connection let socket: WebSocket; // The current WebSocket connection
/** /**

@ -1,4 +1,4 @@
type TetherConfig = { export type TetherConfig = {
/** /**
* The API endpoint to connect to. * The API endpoint to connect to.
*/ */
@ -9,4 +9,3 @@ type TetherConfig = {
*/ */
secure?: boolean; secure?: boolean;
}; };
export default TetherConfig;

@ -1,2 +1 @@
type Snowflake = `${bigint}`; export type Snowflake = `${bigint}`;
export default Snowflake;

@ -1,7 +1,6 @@
type SocketPacket = { export type SocketPacket = {
/** /**
* The OP code for this packet. * The OP code for this packet.
*/ */
op: number; op: number;
}; };
export default SocketPacket;

@ -1,4 +1,4 @@
type DiscordUser = { export type DiscordUser = {
/** /**
* The unique snowflake of this user. * The unique snowflake of this user.
*/ */
@ -69,7 +69,7 @@ type DiscordUser = {
/** /**
* A user's flags. * A user's flags.
*/ */
type UserFlags = { export type UserFlags = {
/** /**
* The list of flags the user has. * The list of flags the user has.
*/ */
@ -101,7 +101,7 @@ type UserFlags = {
/** /**
* A user's avatar. * A user's avatar.
*/ */
type Avatar = { export type Avatar = {
/** /**
* The id of the user's avatar. * The id of the user's avatar.
*/ */
@ -116,7 +116,7 @@ type Avatar = {
/** /**
* A user's banner. * A user's banner.
*/ */
type Banner = { export type Banner = {
/** /**
* The id of the user's avatar. * The id of the user's avatar.
*/ */
@ -131,7 +131,7 @@ type Banner = {
/** /**
* A user's Spotify activity data. * A user's Spotify activity data.
*/ */
type SpotifyActivity = { export type SpotifyActivity = {
/** /**
* The currently playing song. * The currently playing song.
*/ */
@ -167,5 +167,3 @@ type SpotifyActivity = {
*/ */
ends: number; ends: number;
}; };
export default DiscordUser;