Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 39d73df

Browse files
committed
Merge remote-tracking branch 'origin/curseforge-service' into curseforge-service
2 parents a5c6faf + 77bfc5b commit 39d73df

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

nodecg-io-curseforge/extension/curseforgeClient.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@ export class CurseForge {
2727
* @param query The CurseSearchQuery to use. See documentation of CurseSearchQuery for more info.
2828
*/
2929
async searchForAddons(query: CurseSearchQuery): Promise<CurseAddon[]> {
30-
let params = "";
31-
if (query.categoryID != undefined) params += `&categoryId=${query.categoryID}`;
32-
if (query.gameId != undefined) params += `&gameId=${query.gameId}`;
33-
if (query.gameVersion != undefined) params += `&gameVersion=${query.gameVersion}`;
34-
if (query.index != undefined) params += `&index=${query.index}`;
35-
if (query.pageSize != undefined) params += `&pageSize=${query.pageSize}`;
36-
if (query.searchFilter != undefined) params += `&searchFilter=${query.searchFilter}`;
37-
if (query.sectionId != undefined) params += `&sectionId=${query.sectionId}`;
38-
if (query.sort != undefined) params += `&sort=${query.sort}`;
39-
if (params != "") params = "?" + params.substr(1);
40-
const response = (await this.rawRequest("GET", `addon/search${params}`)) as unknown[];
30+
const params = new URLSearchParams();
31+
Object.entries(query)
32+
.forEach(e => {
33+
if (e[1]) params.append(e[0], e[1].toString())
34+
});
35+
36+
const response = (await this.rawRequest("GET", `addon/search?${params}`)) as unknown[];
4137
return response.map((x: CurseAddonInfo) => new CurseAddon(this, x.id, x));
4238
}
4339

@@ -187,15 +183,7 @@ export class CurseForge {
187183
* A curse addon such as a Minecraft mod.
188184
*/
189185
export class CurseAddon {
190-
private readonly curse: CurseForge;
191-
readonly addonId: number;
192-
readonly info: CurseAddonInfo;
193-
194-
constructor(curse: CurseForge, addonId: number, info: CurseAddonInfo) {
195-
this.curse = curse;
196-
this.addonId = addonId;
197-
this.info = info;
198-
}
186+
constructor(private readonly curse: CurseForge, public readonly addonId: number, public readonly info: CurseAddonInfo) {}
199187

200188
/**
201189
* Creates an addon.

0 commit comments

Comments
 (0)