This commit is contained in:
parent
edf386ebca
commit
6ddd31b03a
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "usetether",
|
"name": "usetether",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"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": [
|
||||||
@ -10,7 +10,7 @@
|
|||||||
"restful",
|
"restful",
|
||||||
"realtime"
|
"realtime"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/Rainnny7/Tether",
|
"homepage": "https://usetether.rest",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/Rainnny7/Tether.git"
|
"url": "git+https://github.com/Rainnny7/Tether.git"
|
||||||
|
@ -2,7 +2,13 @@ import TetherConfig from "@/types/config";
|
|||||||
import DiscordUser from "@/types/user";
|
import DiscordUser from "@/types/user";
|
||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
|
|
||||||
export const useTether = (snowflake: number, {endpoint = "usetether.rest", secure = true, realtime = false}: TetherConfig): DiscordUser | undefined => {
|
export const useTether = (
|
||||||
|
snowflake: number,
|
||||||
|
{endpoint, secure, realtime}: TetherConfig = {
|
||||||
|
endpoint: "usetether.rest",
|
||||||
|
secure: true,
|
||||||
|
realtime: false
|
||||||
|
}): DiscordUser | undefined => {
|
||||||
const [user] = useState<DiscordUser | undefined>();
|
const [user] = useState<DiscordUser | undefined>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -13,11 +19,7 @@ export const useTether = (snowflake: number, {endpoint = "usetether.rest", secur
|
|||||||
*/
|
*/
|
||||||
const connect = () => {
|
const connect = () => {
|
||||||
socket = new WebSocket(`ws${secure && "s"}://${endpoint}/gateway`); // Connect to the gateway
|
socket = new WebSocket(`ws${secure && "s"}://${endpoint}/gateway`); // Connect to the gateway
|
||||||
|
socket.addEventListener("open", () => console.log("[Tether] WebSocket connection established!"));
|
||||||
socket.addEventListener("open", () => {
|
|
||||||
console.log("[Tether] WebSocket connection established!");
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.addEventListener("close", connect);
|
socket.addEventListener("close", connect);
|
||||||
|
|
||||||
socket.addEventListener("message", event => {
|
socket.addEventListener("message", event => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user