Skip to content

Commit a6c3ab2

Browse files
committed
Various code cleanup
1 parent 7bd4005 commit a6c3ab2

File tree

151 files changed

+504
-568
lines changed

Some content is hidden

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

151 files changed

+504
-568
lines changed

data/osb/creatables.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"hash": "382baccc4a91a3e8fa11baedaf38068f",
3-
"date": "2025-07-01T02:09:21.011Z",
3+
"date": "2025-07-05T08:06:15.546Z",
44
"data": [
55
{
66
"name": "3rd age felling axe",

data/osb/monsters.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"hash": "5ae5cdbcf62f6f12b26280bf8ee45383",
3-
"date": "2025-07-01T02:09:21.000Z",
3+
"date": "2025-07-05T08:06:15.532Z",
44
"data": [
55
{
66
"id": 2,

packages/oldschooljs/metadata.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ Files in ./dist/cjs:
44
./dist/cjs/EItem.cjs: 333.84 KB 341,850 bytes
55
./dist/cjs/EMonster.cjs: 25.5 KB 26,114 bytes
66
./dist/cjs/gear/index.cjs: 1.77 KB 1,810 bytes
7-
./dist/cjs/index.cjs: 863.75 KB 884,476 bytes
7+
./dist/cjs/index.cjs: 864.36 KB 885,106 bytes
88
./dist/cjs/item_data-OPRFPN4I.json: 5.25 MB 5,509,046 bytes
99
./dist/cjs/monsters_data-5F625L5X.json: 363.54 KB 372,262 bytes
10-
./dist/cjs/structures/Hiscores.cjs: 39.8 KB 40,753 bytes
10+
./dist/cjs/structures/Hiscores.cjs: 39.85 KB 40,804 bytes
1111
./dist/cjs/structures/Wiki.cjs: 3.8 KB 3,889 bytes
12-
./dist/cjs/util/util.cjs: 37.9 KB 38,806 bytes
12+
./dist/cjs/util/util.cjs: 37.95 KB 38,857 bytes
1313

1414
Total size: 7.01 MB
1515

@@ -20,11 +20,11 @@ Files in ./dist/esm:
2020
./dist/esm/EItem.mjs: 332.86 KB 340,850 bytes
2121
./dist/esm/EMonster.mjs: 24.51 KB 25,099 bytes
2222
./dist/esm/gear/index.mjs: 807 B 807 bytes
23-
./dist/esm/index.mjs: 856.23 KB 876,782 bytes
23+
./dist/esm/index.mjs: 856.85 KB 877,412 bytes
2424
./dist/esm/item_data-OPRFPN4I.json: 5.25 MB 5,509,046 bytes
2525
./dist/esm/monsters_data-5F625L5X.json: 363.54 KB 372,262 bytes
26-
./dist/esm/structures/Hiscores.mjs: 39.22 KB 40,165 bytes
26+
./dist/esm/structures/Hiscores.mjs: 39.27 KB 40,216 bytes
2727
./dist/esm/structures/Wiki.mjs: 2.23 KB 2,288 bytes
28-
./dist/esm/util/util.mjs: 36.58 KB 37,457 bytes
28+
./dist/esm/util/util.mjs: 36.63 KB 37,508 bytes
2929

3030
Total size: 6.99 MB

packages/oldschooljs/src/item-groups/outfits.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,10 @@ export const zombieOutfit = [
4646
export const mimeOutfit = [EItem.MIME_MASK, EItem.MIME_TOP, EItem.MIME_LEGS, EItem.MIME_GLOVES, EItem.MIME_BOOTS];
4747

4848
export const anglerOutfit = [EItem.ANGLER_HAT, EItem.ANGLER_TOP, EItem.ANGLER_WADERS, EItem.ANGLER_BOOTS];
49+
50+
export const prospectorOutfit = [
51+
EItem.PROSPECTOR_HELMET,
52+
EItem.PROSPECTOR_JACKET,
53+
EItem.PROSPECTOR_LEGS,
54+
EItem.PROSPECTOR_BOOTS
55+
];

packages/oldschooljs/src/itemGroups.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,27 @@ export const runeHeraldicShields = [
1717
EItem.RUNE_SHIELD_H5
1818
];
1919

20-
const karilsItems = [EItem.KARILS_COIF, EItem.KARILS_LEATHERTOP, EItem.KARILS_LEATHERSKIRT, EItem.KARILS_CROSSBOW];
21-
const dharokItems = [EItem.DHAROKS_HELM, EItem.DHAROKS_PLATEBODY, EItem.DHAROKS_PLATELEGS, EItem.DHAROKS_GREATAXE];
22-
const guthansItems = [EItem.GUTHANS_HELM, EItem.GUTHANS_PLATEBODY, EItem.GUTHANS_CHAINSKIRT, EItem.GUTHANS_WARSPEAR];
23-
const toragsItems = [EItem.TORAGS_HELM, EItem.TORAGS_PLATEBODY, EItem.TORAGS_PLATELEGS, EItem.TORAGS_HAMMERS];
24-
const veracsItems = [EItem.VERACS_HELM, EItem.VERACS_BRASSARD, EItem.VERACS_PLATESKIRT, EItem.VERACS_FLAIL];
25-
const ahrimsItems = [EItem.AHRIMS_HOOD, EItem.AHRIMS_ROBETOP, EItem.AHRIMS_ROBESKIRT, EItem.AHRIMS_STAFF];
20+
export const karilsItems = [
21+
EItem.KARILS_COIF,
22+
EItem.KARILS_LEATHERTOP,
23+
EItem.KARILS_LEATHERSKIRT,
24+
EItem.KARILS_CROSSBOW
25+
];
26+
export const dharokItems = [
27+
EItem.DHAROKS_HELM,
28+
EItem.DHAROKS_PLATEBODY,
29+
EItem.DHAROKS_PLATELEGS,
30+
EItem.DHAROKS_GREATAXE
31+
];
32+
export const guthansItems = [
33+
EItem.GUTHANS_HELM,
34+
EItem.GUTHANS_PLATEBODY,
35+
EItem.GUTHANS_CHAINSKIRT,
36+
EItem.GUTHANS_WARSPEAR
37+
];
38+
export const toragsItems = [EItem.TORAGS_HELM, EItem.TORAGS_PLATEBODY, EItem.TORAGS_PLATELEGS, EItem.TORAGS_HAMMERS];
39+
export const veracsItems = [EItem.VERACS_HELM, EItem.VERACS_BRASSARD, EItem.VERACS_PLATESKIRT, EItem.VERACS_FLAIL];
40+
export const ahrimsItems = [EItem.AHRIMS_HOOD, EItem.AHRIMS_ROBETOP, EItem.AHRIMS_ROBESKIRT, EItem.AHRIMS_STAFF];
2641

2742
export const barrowsItemArr = [karilsItems, ahrimsItems, guthansItems, toragsItems, veracsItems, dharokItems];
2843

@@ -166,5 +181,7 @@ export const demonBaneWeapons = [
166181
EItem.PURGING_STAFF
167182
];
168183

184+
export const virtusOutfit = [EItem.VIRTUS_MASK, EItem.VIRTUS_ROBE_TOP, EItem.VIRTUS_ROBE_BOTTOM];
185+
169186
export * from './item-groups/boss-cl';
170187
export * from './item-groups/outfits';

packages/oldschooljs/src/structures/Bank.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ export default class Bank {
336336

337337
toNamedBank(): Record<string, number> {
338338
const namedBank: Record<string, number> = {};
339-
for (const [item, quantity] of this.items()) {
339+
for (const [item, quantity] of this.items().sort((a, b) => a[0].name.localeCompare(b[0].name))) {
340340
namedBank[item.name] = quantity;
341341
}
342342
return namedBank;

packages/toolkit/esbuild.cjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ const entryPoints = [
55
'src/structures.ts',
66
'src/constants.ts',
77
'src/testBotWebsocket.ts',
8-
'src/util/datetime.ts'
8+
'src/util/datetime.ts',
9+
'src/string-util.ts',
10+
'src/discord-util.ts'
911
];
1012

1113
const baseConfig = {

packages/toolkit/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
"types": "./dist/util/datetime.d.ts",
3434
"require": "./dist/cjs/util/datetime.cjs",
3535
"import": "./dist/esm/util/datetime.mjs"
36+
},
37+
"./discord-util": {
38+
"types": "./dist/discord-util.d.ts",
39+
"require": "./dist/cjs/discord-util.cjs",
40+
"import": "./dist/esm/discord-util.mjs"
41+
},
42+
"./string-util": {
43+
"types": "./dist/string-util.d.ts",
44+
"require": "./dist/cjs/string-util.cjs",
45+
"import": "./dist/esm/string-util.mjs"
3646
}
3747
},
3848
"scripts": {

packages/toolkit/src/util/mahoji.ts renamed to packages/toolkit/src/discord-util.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
import deepMerge from 'deepmerge';
12
import type { BaseMessageOptions, InteractionReplyOptions } from 'discord.js';
3+
import type { CommandResponse } from './util.js';
24

3-
import type { CommandResponse } from '../util';
5+
export * from './util/paginatedMessage.js';
6+
export * from './util/discord';
7+
export * from './util/discordJS';
8+
export * from './lib/MahojiClient/Mahoji';
9+
export * from './lib/MahojiClient/mahojiTypes';
410

511
export function normalizeMahojiResponse(one: Awaited<CommandResponse>): BaseMessageOptions {
612
if (!one) return {};
@@ -30,3 +36,28 @@ export function roughMergeMahojiResponse(
3036

3137
return newResponse;
3238
}
39+
40+
const TOO_LONG_STR = 'The result was too long (over 2000 characters), please read the attached file.';
41+
42+
export function returnStringOrFile(string: string | InteractionReplyOptions): Awaited<CommandResponse> {
43+
if (typeof string === 'string') {
44+
if (string.length > 2000) {
45+
return {
46+
content: TOO_LONG_STR,
47+
files: [{ attachment: Buffer.from(string), name: 'result.txt' }]
48+
};
49+
}
50+
return string;
51+
}
52+
if (string.content && string.content.length > 2000) {
53+
return deepMerge(
54+
string,
55+
{
56+
content: TOO_LONG_STR,
57+
files: [{ attachment: Buffer.from(string.content), name: 'result.txt' }]
58+
},
59+
{ clone: false }
60+
);
61+
}
62+
return string;
63+
}

packages/toolkit/src/lib/MahojiClient/Mahoji.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
type Snowflake,
1515
type User
1616
} from 'discord.js';
17-
import type { CommandOption, CommandOptions, CommandRunOptions } from './mahojiTypes';
17+
import type { CommandOption, CommandOptions, CommandResponse, CommandRunOptions } from './mahojiTypes';
1818

1919
export function convertCommandOptionToAPIOption(option: CommandOption): any {
2020
switch (option.type) {
@@ -194,8 +194,6 @@ export async function handleAutocomplete(
194194
return [];
195195
}
196196

197-
export type CommandResponse = Promise<null | string | InteractionReplyOptions>;
198-
199197
export type ICommand = Readonly<{
200198
name: string;
201199
description: string;

0 commit comments

Comments
 (0)