From 74789ef5dadf36f8c6f71ad1742760bfff6679ef Mon Sep 17 00:00:00 2001 From: GDColon Date: Sun, 19 Dec 2021 23:23:50 -0500 Subject: [PATCH] RGB codes for icon responses --- api/comments.js | 6 +- api/leaderboards/leaderboardLevel.js | 6 +- api/leaderboards/scores.js | 6 +- api/profile.js | 3 + html/api.html | 111 +++++++++++++++------------ 5 files changed, 78 insertions(+), 54 deletions(-) diff --git a/api/comments.js b/api/comments.js index e38498d..e9bc42e 100644 --- a/api/comments.js +++ b/api/comments.js @@ -1,3 +1,5 @@ +const colors = require('../misc/icons/colors.json'); + module.exports = async (app, req, res) => { if (req.offline) return res.sendError() @@ -64,7 +66,9 @@ module.exports = async (app, req, res) => { icon: +y[9] || 1, col1: +y[10], col2: +y[11], - glow: +y[15] > 1 + glow: +y[15] > 1, + col1RGB: colors[y[10]] || colors["0"], + col2RGB: colors[y[11]] || colors["3"] } app.userCache(req.id, comment.accountID, comment.playerID, comment.username) } diff --git a/api/leaderboards/leaderboardLevel.js b/api/leaderboards/leaderboardLevel.js index 71e816f..39f7915 100644 --- a/api/leaderboards/leaderboardLevel.js +++ b/api/leaderboards/leaderboardLevel.js @@ -1,3 +1,5 @@ +const colors = require('../../misc/icons/colors.json'); + module.exports = async (app, req, res) => { if (req.offline) return res.sendError() @@ -37,7 +39,9 @@ module.exports = async (app, req, res) => { icon: +x[9], col1: +x[10], col2: +x[11], - glow: +x[15] > 1 + glow: +x[15] > 1, + col1RGB: colors[x[10]] || colors["0"], + col2RGB: colors[x[11]] || colors["3"] } keys.forEach(k => delete x[k]) app.userCache(req.id, x.accountID, x.playerID, x.username) diff --git a/api/leaderboards/scores.js b/api/leaderboards/scores.js index 730d461..15dcab3 100644 --- a/api/leaderboards/scores.js +++ b/api/leaderboards/scores.js @@ -1,3 +1,5 @@ +const colors = require('../../misc/icons/colors.json'); + module.exports = async (app, req, res) => { if (req.offline) return res.sendError() @@ -37,7 +39,9 @@ module.exports = async (app, req, res) => { icon: +x[9] || 1, col1: +x[10], col2: +x[11], - glow: +x[15] > 1 + glow: +x[15] > 1, + col1RGB: colors[x[10]] || colors["0"], + col2RGB: colors[x[11]] || colors["3"] } keys.forEach(k => delete x[k]) app.userCache(req.id, x.accountID, x.playerID, x.username) diff --git a/api/profile.js b/api/profile.js index 142011d..0ad1fe1 100644 --- a/api/profile.js +++ b/api/profile.js @@ -1,4 +1,5 @@ const fs = require('fs') +const colors = require('../misc/icons/colors.json'); module.exports = async (app, req, res, api, getLevels) => { @@ -76,6 +77,8 @@ module.exports = async (app, req, res, api, getLevels) => { col2: +account[11], deathEffect: +account[48] || 1, glow: account[28] == "1", + col1RGB: colors[account[10]] || colors["0"], + col2RGB: colors[account[11]] || colors["3"] } if (api) return res.status(200).send(userData) diff --git a/html/api.html b/html/api.html index 79a6213..1f7ad44 100644 --- a/html/api.html +++ b/html/api.html @@ -107,14 +107,14 @@

Using "daily" or "weekly" as the level ID will return the current daily/weekly level (always downloaded)


-

Parameters (1)

+

Parameters (1)

download: Whether or not to actually download the level (much slower)

*By default it performs a search for the level ID and returns as much information as possible without downloading


-

Response (47)

+

Response (47)

*Values that require a download are in red and values that only work with daily/weekly levels are blue

name: The name of the level

@@ -167,7 +167,7 @@

-

Example

+

Example

Example Request

/api/level/4284013

@@ -175,7 +175,7 @@

Example Response

-

...

+

Loading...


@@ -194,13 +194,13 @@

Unlike the Geometry Dash API, both username and ID can be used to fetch a user profile.


-

Parameters (1)

+

Parameters (1)

player: Forces the player ID to be used for fetching (normally Account ID is tried first)


-

Response (28)

+

Response (30)

username: The name of the player

playerID: The unique ID for all accounts

@@ -221,10 +221,11 @@

twitch: The URL of the player's Twitch account, if linked. Plug it into https://twitch.tv/{twitch}

glow: If the player's icon has a glow or not

icon, ship, ball, ufo, wave, robot, spider, col1, col2, deathEffect: The number of the icon/color used for each form. The actual icon can be generated through /icon

+

col1RGB, col2RGB: The RGB color values for each player color


-

Example

+

Example

Example Request

/api/profile/robtop

@@ -232,7 +233,7 @@

Example Response

-

...

+

Loading...


@@ -251,7 +252,7 @@

Use an asterisk (*) as your search query if you do not wish to search by level name (if you intend on using filters)


-

Parameters (19)

+

Parameters (19)


-

Response*

+

Response*


-

Examples

+

Examples

@@ -334,7 +335,7 @@

Returns the top player, creator, and accurate leaderboards


-

Parameters (6)

+

Parameters (6)

*Values that only work with the accurate leaderboard are in red

count: The amount of players to list (default is 100, max is 5000, does not work with accurate leaderboard)

@@ -346,7 +347,7 @@

-

Response (10)

+

Response (10)

The API will return an array of each player with the following information:

rank: Position on the leaderboard

@@ -362,7 +363,7 @@

-

Examples

+

Examples

Example Requests

/api/leaderboard?count=10 (Fetches the top 10 players)

@@ -372,7 +373,7 @@

Example Response

(first example used)

-

...

+

Loading...


@@ -392,13 +393,13 @@

I'm putting this in the same section because they're basically the same lol


-

Parameters (0)

+

Parameters (0)

No parameters for this one!


-

Response (8)

+

Response (8)

*Values in blue are used in gauntlets, everything else is exclusive to map packs

id: The ID of the map pack, or index/type of the gauntlet

@@ -412,14 +413,14 @@

-

Example

+

Example

Example Request

/api/mappacks


Example Response

-

...

+

Loading...


@@ -438,14 +439,14 @@

Returns the leaderboard for a level


-

Parameters (2)

+

Parameters (2)

count: The amount of players to list (default is 100, max is 200)

week: Whether or not to fetch the weekly leaderboard instead of the regular one


-

Response (7)

+

Response (7)

The API will return an array of each player with the following information:

rank: Position on the leaderboard

@@ -459,14 +460,14 @@

-

Example

+

Example

Example Request

/api/leaderboardLevel/1063115 (Fetches the leaderboard for Dynamic on Track)


Example Response

-

...

+

Loading...


@@ -484,7 +485,7 @@

Returns up to 10 comments or profile posts


-

Parameters (4)

+

Parameters (4)

page: The page of the search

top: Whether or not to sort by most liked (comments only)

@@ -495,7 +496,7 @@

-

Response (16)

+

Response (16)

The API will return an array of each comment with the following information.
Values that don't work for profile posts are in red

content: The comment text

@@ -517,7 +518,7 @@

-

Examples

+

Examples

Example Requests

/api/comments/26681070?top (Fetches Sonic Wave's most liked comments)

@@ -527,7 +528,7 @@

Example Response

(first example used)

-

...

+

Loading...

@@ -544,7 +545,7 @@

*Commenting has a rate limit of 15 seconds


-

Parameters (6)

+

Parameters (6)

comment: The content of the comment

username: Your username

@@ -557,7 +558,7 @@
-

Example

+

Example

Example Request

POST /postComment
@@ -584,7 +585,7 @@

Leaves a profile post. This one is a POST request!


-

Parameters (5)

+

Parameters (5)

comment: The content of the profile post

username: Your username

@@ -595,7 +596,7 @@
-

Example

+

Example

Example Requests

POST /postProfileComment
@@ -621,7 +622,7 @@

Likes/dislikes level, comment, or post. This one is a POST request!


-

Parameters (6)

+

Parameters (6)

ID: The ID of the item to like. This should be a level ID, comment ID, or profile post ID

like: Whether to like or dislike the level. 1=like, 0=dislike

@@ -633,7 +634,7 @@
-

Example

+

Example

Example Request

Drop a like on RobTop's popular "can you handle the kappa" comment:

@@ -666,7 +667,7 @@

I decided to put all 4 of these requests in one section because they're fairly similar ¯\_(ツ)_/¯


-

Parameters

+

Parameters

All:

accountID: Your account ID

@@ -689,7 +690,7 @@
-

Example

+

Example

Example Request

Fetch your messages:

@@ -739,18 +740,18 @@
If the song was published after March 2017, the artist must also be whitelisted by a GD moderator.


-

Parameters (0)

+

Parameters (0)

No parameters for this one!


-

Response (1)

+

Response (1)

literally just returns true or false (or -1 if there's an error)

there used to be more but rob disabled his song api sooo

-