Skip to content

Commit 4e9f40f

Browse files
committed
Removed @nexusmods/nexus-api dependency
1 parent ad99d7e commit 4e9f40f

File tree

5 files changed

+120
-11
lines changed

5 files changed

+120
-11
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"typescript": "^5.8.2"
2929
},
3030
"dependencies": {
31-
"@nexusmods/nexus-api": "^1.1.5",
3231
"@types/cookie-parser": "^1.4.8",
3332
"@types/express": "^5.0.1",
3433
"@types/jsonwebtoken": "^9.0.9",

src/api/DiscordBotUser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as NexusModsOAuth from '../server/NexusModsOAuth';
22
import * as DiscordOAuth from '../server/DiscordOAuth';
3-
import { IUpdateEntry, IValidateKeyResponse } from '@nexusmods/nexus-api';
3+
import { IValidateKeyResponse } from '../types/NexusModsAPIv1';
44
import { NexusUser } from '../types/users';
55
import { baseheader, Logger } from './util';
66
import { updateUser } from './users';
@@ -138,7 +138,7 @@ export class DiscordBotUser {
138138
async (query: string, adult: boolean, gameId?: number) =>
139139
v1.quicksearch(query, adult, gameId),
140140
UpdatedMods:
141-
async (domain: string, period?: string): Promise<IUpdateEntry[]> =>
141+
async (domain: string, period?: string) =>
142142
v1.updatedMods(this.headers(), this.logger, domain, period),
143143
Mod:
144144
async (domain: string, id: number) =>

src/api/queries/v1.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { IChangelogs, IGameInfo, IGameListEntry, IModFiles, IModInfo, IValidateKeyResponse } from '@nexusmods/nexus-api';
1+
import { IChangelogs, IGameInfo, IGameListEntry, IModFiles, IModInfo, IUpdateEntry, IValidateKeyResponse } from '../../types/NexusModsAPIv1';
22
import axios, { AxiosError } from 'axios';
33
import { NexusAPIServerError, NexusSearchResult } from '../../types/util';
44
import { Logger } from "../util";
55

66
const nexusAPI: string = 'https://api.nexusmods.com/';
77

8-
async function v1APIQuery (logger: Logger, path: string, headers: Record<string, string>, params?: { [key: string]: any }): Promise<any> {
8+
async function v1APIQuery <T>(logger: Logger, path: string, headers: Record<string, string>, params?: { [key: string]: any }): Promise<T> {
99
const authType = headers['apikey'] ? 'APIKEY' : 'OAUTH';
1010
try {
1111
const query = await axios({
@@ -55,7 +55,7 @@ export async function quicksearch(query: string, bIncludeAdult: boolean, game_id
5555
}
5656

5757
export async function updatedMods(headers: Record<string,string>, logger: Logger, gameDomain: string, period: string = '1w', ) {
58-
return v1APIQuery(logger, `/v1/games/${gameDomain}/mods/updated.json`, headers, { period });
58+
return v1APIQuery<IUpdateEntry[]>(logger, `/v1/games/${gameDomain}/mods/updated.json`, headers, { period });
5959
}
6060

6161
export async function modInfo(headers: Record<string,string>, logger: Logger, gameDomain: string, modId: number): Promise<IModInfo> {

src/interactions/settings.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { updateServer, getServer, getConditionsForRole, addConditionForRole } fr
1111
import { BotServer } from "../types/servers";
1212
import { ClientExt, DiscordInteraction } from "../types/DiscordTypes";
1313
import { KnownDiscordServers, Logger } from "../api/util";
14-
import { IGameInfo } from "@nexusmods/nexus-api";
1514
import { IGameStatic } from "../api/queries/other";
1615
import { autocompleteGameName } from "../api/util";
1716
import { changeRoleForConditions, deleteAllConditionsForRole, deleteConditionForRole, IConditionForRole } from "../api/server_role_conditions";
@@ -110,8 +109,8 @@ type OptionNames = 'game' | 'role' | 'count' | 'op' | 'type';
110109

111110
interface IBotServerChange {
112111
name: string;
113-
cur: any | Role | IGameInfo | string | undefined;
114-
new: any | Role | IGameInfo | string | undefined;
112+
cur: any | Role | IGameStatic | string | undefined;
113+
new: any | Role | IGameStatic | string | undefined;
115114
data: Partial<BotServer>;
116115
};
117116

@@ -331,8 +330,8 @@ async function removeRoleConditions(interaction: ChatInputCommandInteraction, ga
331330
}
332331

333332
const updateEmbed = (data: IBotServerChange): EmbedBuilder => {
334-
const curVal = (data.cur as IGameInfo) ? data.cur?.name : !data.cur ? '*none*' : data.cur?.toString();
335-
const newVal = (data.new as IGameInfo) ? data.new?.name : !data.new ? '*none*' : data.cur?.toString();
333+
const curVal = (data.cur as IGameStatic) ? data.cur?.name : !data.cur ? '*none*' : data.cur?.toString();
334+
const newVal = (data.new as IGameStatic) ? data.new?.name : !data.new ? '*none*' : data.cur?.toString();
336335
return new EmbedBuilder()
337336
.setTitle('Configuration updated')
338337
.setColor(0xda8e35)

src/types/NexusModsAPIv1.ts

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
export interface IChangelogs {
2+
[versionNumber: string]: string[];
3+
}
4+
5+
export interface IUpdateEntry {
6+
mod_id: number;
7+
latest_file_update: number;
8+
latest_mod_activity: number;
9+
}
10+
11+
type EndorsedStatus = 'Undecided' | 'Abstained' | 'Endorsed';
12+
type ModStatus = 'under_moderation' | 'published' | 'not_published' | 'publish_with_game' | 'removed' | 'wastebinned' | 'hidden';
13+
export interface IModInfo {
14+
mod_id: number;
15+
game_id: number;
16+
domain_name: string;
17+
category_id: number;
18+
contains_adult_content: boolean;
19+
name?: string;
20+
summary?: string;
21+
description?: string;
22+
version: string;
23+
author: string;
24+
user: IUser;
25+
uploaded_by: string;
26+
uploaded_users_profile_url: string;
27+
status: ModStatus;
28+
available: boolean;
29+
picture_url?: string;
30+
created_timestamp: number;
31+
created_time: string;
32+
updated_timestamp: number;
33+
updated_time: string;
34+
allow_rating: boolean;
35+
endorsement_count: number;
36+
mod_downloads: number;
37+
mod_unique_downloads: number;
38+
endorsement?: {
39+
endorse_status: EndorsedStatus;
40+
timestamp: number;
41+
version: number;
42+
};
43+
}
44+
45+
interface IFileInfo {
46+
file_id: number;
47+
category_id: number;
48+
category_name: string;
49+
changelog_html: string;
50+
content_preview_link: string;
51+
name: string;
52+
description: string;
53+
version: string;
54+
size: number;
55+
size_kb: number;
56+
file_name: string;
57+
uploaded_timestamp: number;
58+
uploaded_time: string;
59+
mod_version: string;
60+
external_virus_scan_url: string;
61+
is_primary: boolean;
62+
}
63+
export interface IModFiles {
64+
file_updates: IFileUpdate[];
65+
files: IFileInfo[];
66+
}
67+
interface IFileUpdate {
68+
new_file_id: number;
69+
new_file_name: string;
70+
old_file_id: number;
71+
old_file_name: string;
72+
uploaded_time: string;
73+
uploaded_timestamp: number;
74+
}
75+
76+
interface ICategory {
77+
category_id: number;
78+
name: string;
79+
parent_category: number | false;
80+
}
81+
82+
export interface IGameListEntry {
83+
id: number;
84+
domain_name: string;
85+
name: string;
86+
forum_url: string;
87+
nexusmods_url: string;
88+
genre: string;
89+
mods: number;
90+
file_count: number;
91+
downloads: number;
92+
approved_date: number;
93+
}
94+
export interface IGameInfo extends IGameListEntry {
95+
categories: ICategory[];
96+
}
97+
98+
interface IUser {
99+
member_id: number;
100+
member_group_id: number;
101+
name: string;
102+
}
103+
export interface IValidateKeyResponse {
104+
user_id: number;
105+
key: string;
106+
name: string;
107+
is_premium: boolean;
108+
is_supporter: boolean;
109+
email: string;
110+
profile_url: string;
111+
}

0 commit comments

Comments
 (0)