Skip to content

Commit

Permalink
Hypixel API • Reborn documentation Presence
Browse files Browse the repository at this point in the history
  • Loading branch information
StavZ committed Jan 18, 2021
1 parent 776eaf9 commit 103dd48
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
24 changes: 24 additions & 0 deletions websites/H/Hypixel API Reborn/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://schemas.premid.app/metadata/1.0",
"author": {
"name": "StavZDev",
"id": "291568379423096832"
},
"service": "Hypixel API Reborn",
"description": {
"en": "Hypixel API • Reborn is the only Hypixel API wrapper for Node.js/Typescript with intellisense support.",
"ru": "Hypixel API • Reborn - единственный парсер Hypixel API для Node.js/Typescript с поддержкой intellisense."
},
"url": "hypixel.stavzdev.xyz",
"version": "1.0.0",
"logo": "https://i.imgur.com/eQzO2nG.png",
"thumbnail": "https://i.imgur.com/9BpoEmx.png",
"color": "#ff8c00",
"tags": [
"development",
"other",
"hypixel-api-reborn",
"programming"
],
"category": "other"
}
31 changes: 31 additions & 0 deletions websites/H/Hypixel API Reborn/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var presence = new Presence({
clientId: "800651916345999360"
});

presence.on("UpdateData", () => {
let route = document.location.hash.split("/");

let data: PresenceData = {
largeImageKey: "logo",
};

if (route.length === 1 || route[1] === "") {
data.details = "Browsing the main page...";
} else if (route[1] === "docs") {
data.smallImageKey = route[2];
data.smallImageText = `${route[2].replace(/^[a-z]/i, (c) => c.toUpperCase())} - ${Number(route[3][0]) ? `v${route[3]}` : `${route[3]}`}`;

if (route[4].startsWith("search?q=")) {
data.details = "Searching for:";
data.state = route[4].slice(9);
} else if (route[4] === "general") {
data.details = "Viewing:";
data.state = route[5] === "faq" ? route[5].toUpperCase() : `${route[5].replace(/^[a-z]/i, (c) => c.toUpperCase())}`;
} else {
data.details = `Looking for a${(route[5].split("?scrollTo=")[1] && route[5].split("?scrollTo=")[1].startsWith("e-")) || route[4] === "examples" ? "n" : ""} ${route[5].split("?scrollTo=")[1] && route[5].split("?scrollTo=")[1].startsWith("e-") ? "event" : `${route[4].endsWith("s") && route[4] !== "class" ? route[4].substring(0, route[4].length - 1) : route[4].replace(/^[a-z]/i, (c) => c.toUpperCase())}`}`;
data.state = `${route[5].split("?scrollTo=")[0]}${route[5].split("?scrollTo=")[1] ? `#${route[5].split("?scrollTo=")[1][1] === "-" ? route[5].split("?scrollTo=")[1].slice(2) : route[5].split("?scrollTo=")[1]}` : ""}`;
}
}

presence.setActivity(data);
});
6 changes: 6 additions & 0 deletions websites/H/Hypixel API Reborn/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/"
}
}

0 comments on commit 103dd48

Please sign in to comment.