Skip to content

Commit d3a94fe

Browse files
committed
feat: add types to all commands
1 parent cf876dc commit d3a94fe

File tree

142 files changed

+9853
-8987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+9853
-8987
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"bracketSpacing": true,
66
"proseWrap": "always",
77
"singleQuote": false,
8-
"printWidth": 120,
8+
"printWidth": 170,
99
"endOfLine": "lf",
1010
"useTabs": false,
1111
"tabWidth": 2,

API/constants/accessories.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** @type {Record<string, number>} */
2+
const MAGICAL_POWER = {
3+
common: 3,
4+
uncommon: 5,
5+
rare: 8,
6+
epic: 12,
7+
legendary: 16,
8+
mythic: 22,
9+
special: 3,
10+
very: 5
11+
};
12+
13+
module.exports = {
14+
MAGICAL_POWER
15+
};

API/constants/bestiary.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
const axios = require("axios");
1+
// @ts-ignore
2+
const { get } = require("axios");
23

4+
/**
5+
* @typedef {import('./bestiary.types').BestiaryConstant} BestiaryConstants
6+
* @typedef {import('./bestiary.types').Mob} Mob
7+
* @typedef {import('./bestiary.types').RawMob} RawMob
8+
*/
9+
10+
/**
11+
* @param {RawMob[]} mobs
12+
* @returns {Mob[]}
13+
* */
314
function formatBestiaryMobs(mobs) {
415
const output = [];
516
for (const mob of mobs) {
@@ -14,20 +25,24 @@ function formatBestiaryMobs(mobs) {
1425
return output;
1526
}
1627

28+
/** @type {Partial<{ lastUpdated: number, data: BestiaryConstants }>} */
1729
const cache = {};
30+
31+
/**
32+
* @returns {Promise<BestiaryConstants | null>}
33+
* */
1834
async function getBestiaryConstants() {
1935
if (cache.lastUpdated && cache.lastUpdated + 1000 * 60 * 60 * 12 > Date.now()) {
20-
return cache.data;
36+
return cache.data ?? null;
2137
}
2238

23-
const response = await axios.get(
24-
"https://raw.githubusercontent.com/NotEnoughUpdates/NotEnoughUpdates-REPO/refs/heads/master/constants/bestiary.json"
25-
);
39+
const response = await get("https://raw.githubusercontent.com/NotEnoughUpdates/NotEnoughUpdates-REPO/refs/heads/master/constants/bestiary.json");
2640
const bestiary = response?.data;
2741
if (!bestiary) {
2842
return null;
2943
}
3044

45+
/** @type {BestiaryConstants} */
3146
const output = { brackets: bestiary.brackets, islands: {} };
3247
for (const [islandId, islandData] of Object.entries(bestiary).filter(([key]) => key !== "brackets")) {
3348
if (islandData.hasSubcategories === true) {
@@ -37,9 +52,7 @@ async function getBestiaryConstants() {
3752
}
3853

3954
const id = islandId === categoryId ? islandId : `${islandId}:${categoryId}`;
40-
const name = categoryData.name.includes(islandData.name)
41-
? categoryData.name
42-
: `${categoryData.name} ${islandData.name}`;
55+
const name = categoryData.name.includes(islandData.name) ? categoryData.name : `${categoryData.name} ${islandData.name}`;
4356
output.islands[id] = {
4457
name: name,
4558
mobs: formatBestiaryMobs(categoryData.mobs)

API/constants/bestiary.types.d.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export type BestiaryConstant = {
2+
brackets: Record<string, number[]>;
3+
islands: Record<string, Island>;
4+
};
5+
6+
type Island = {
7+
name: string;
8+
mobs: Mob[];
9+
};
10+
11+
type Mob = {
12+
name: string;
13+
cap: number;
14+
mobs: string[];
15+
bracket: number;
16+
};
17+
18+
type RawMob = {
19+
name: string;
20+
item?: string;
21+
skullOwner?: string;
22+
texture?: string;
23+
cap: number;
24+
mobs: string[];
25+
bracket: number;
26+
};

API/constants/calendar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// CREDITS: https://github.com/slothpixel/core (Modified)
2+
// @ts-nocheck
23
const { nth, parseTimestamp } = require("../../src/contracts/helperFunctions.js");
34

45
const months = [

API/constants/fetchur_items.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @typedef {Record<number, {
3+
* name: string,
4+
* quantity: number,
5+
* text: string,
6+
* image: string,
7+
* description: string
8+
* }>} fetchur_items
9+
*/
110
module.exports = {
211
0: {
312
name: "Red Wool",

API/constants/functions.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

API/constants/leveling.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,7 @@ const skillTables = {
201201
farming: 60,
202202
taming: 60
203203
},
204-
skills: [
205-
"combat",
206-
"farming",
207-
"fishing",
208-
"mining",
209-
"foraging",
210-
"enchanting",
211-
"alchemy",
212-
"carpentry",
213-
"runecrafting",
214-
"social",
215-
"taming"
216-
],
204+
skills: ["combat", "farming", "fishing", "mining", "foraging", "enchanting", "alchemy", "carpentry", "runecrafting", "social", "taming"],
217205
classes: ["healer", "mage", "berserk", "archer", "tank"],
218206
cosmeticSkills: ["runecrafting", "social"],
219207
infiniteLeveling: ["dungeoneering", "skyblockLevel"],

0 commit comments

Comments
 (0)