@hizollo/osu-api 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,909 +1,933 @@
1
- // src/Client.ts
2
- import request2 from "superagent";
3
-
4
- // src/managers/UserManager.ts
5
1
  import request from "superagent";
2
+ import { Buffer } from "node:buffer";
6
3
 
7
4
  // src/types/enums.ts
8
- var GameMode = /* @__PURE__ */ ((GameMode3) => {
9
- GameMode3[GameMode3["Standard"] = 0] = "Standard";
10
- GameMode3[GameMode3["Taiko"] = 1] = "Taiko";
11
- GameMode3[GameMode3["Catch"] = 2] = "Catch";
12
- GameMode3[GameMode3["Mania"] = 3] = "Mania";
13
- return GameMode3;
14
- })(GameMode || {});
15
- var UserRequestType = /* @__PURE__ */ ((UserRequestType2) => {
16
- UserRequestType2["String"] = "string";
17
- UserRequestType2["Id"] = "id";
18
- return UserRequestType2;
19
- })(UserRequestType || {});
20
- var Mods = {
21
- None: 0n,
22
- NoFail: 1n << 0n,
23
- Easy: 1n << 1n,
24
- TouchDevice: 1n << 2n,
25
- Hidden: 1n << 3n,
26
- HardRock: 1n << 4n,
27
- SuddenDeath: 1n << 5n,
28
- DoubleTime: 1n << 6n,
29
- Relax: 1n << 7n,
30
- HalfTime: 1n << 8n,
31
- Nightcore: 1n << 9n,
32
- Flashlight: 1n << 10n,
33
- Autoplay: 1n << 11n,
34
- SpunOut: 1n << 12n,
35
- AutoPilot: 1n << 13n,
36
- Perfect: 1n << 14n,
37
- Key4: 1n << 15n,
38
- Key5: 1n << 16n,
39
- Key6: 1n << 17n,
40
- Key7: 1n << 18n,
41
- Key8: 1n << 19n,
42
- FadeIn: 1n << 20n,
43
- Random: 1n << 21n,
44
- Cinema: 1n << 22n,
45
- Target: 1n << 23n,
46
- Key9: 1n << 24n,
47
- KeyCoop: 1n << 25n,
48
- Key1: 1n << 26n,
49
- Key3: 1n << 27n,
50
- Key2: 1n << 28n,
51
- ScoreV2: 1n << 29n,
52
- Mirror: 1n << 30n
5
+ let GameMode = /* @__PURE__ */ function(GameMode) {
6
+ GameMode[GameMode["Standard"] = 0] = "Standard";
7
+ GameMode[GameMode["Taiko"] = 1] = "Taiko";
8
+ GameMode[GameMode["Catch"] = 2] = "Catch";
9
+ GameMode[GameMode["Mania"] = 3] = "Mania";
10
+ return GameMode;
11
+ }({});
12
+ let UserRequestType = /* @__PURE__ */ function(UserRequestType) {
13
+ UserRequestType["String"] = "string";
14
+ UserRequestType["Id"] = "id";
15
+ return UserRequestType;
16
+ }({});
17
+ const Mods = {
18
+ None: 0n,
19
+ NoFail: 1n << 0n,
20
+ Easy: 1n << 1n,
21
+ TouchDevice: 1n << 2n,
22
+ Hidden: 1n << 3n,
23
+ HardRock: 1n << 4n,
24
+ SuddenDeath: 1n << 5n,
25
+ DoubleTime: 1n << 6n,
26
+ Relax: 1n << 7n,
27
+ HalfTime: 1n << 8n,
28
+ Nightcore: 1n << 9n,
29
+ Flashlight: 1n << 10n,
30
+ Autoplay: 1n << 11n,
31
+ SpunOut: 1n << 12n,
32
+ AutoPilot: 1n << 13n,
33
+ Perfect: 1n << 14n,
34
+ Key4: 1n << 15n,
35
+ Key5: 1n << 16n,
36
+ Key6: 1n << 17n,
37
+ Key7: 1n << 18n,
38
+ Key8: 1n << 19n,
39
+ FadeIn: 1n << 20n,
40
+ Random: 1n << 21n,
41
+ Cinema: 1n << 22n,
42
+ Target: 1n << 23n,
43
+ Key9: 1n << 24n,
44
+ KeyCoop: 1n << 25n,
45
+ Key1: 1n << 26n,
46
+ Key3: 1n << 27n,
47
+ Key2: 1n << 28n,
48
+ ScoreV2: 1n << 29n,
49
+ Mirror: 1n << 30n
53
50
  };
54
- var ModsAbbreviation = {
55
- NoFail: "NF",
56
- Easy: "EZ",
57
- TouchDevice: "TD",
58
- Hidden: "HD",
59
- HardRock: "HR",
60
- SuddenDeath: "SD",
61
- DoubleTime: "DT",
62
- Relax: "RX",
63
- HalfTime: "HT",
64
- Nightcore: "NC",
65
- Flashlight: "FL",
66
- Autoplay: "AT",
67
- SpunOut: "SO",
68
- AutoPilot: "AP",
69
- Perfect: "PF",
70
- Key4: "4K",
71
- Key5: "5K",
72
- Key6: "6K",
73
- Key7: "7K",
74
- Key8: "8K",
75
- FadeIn: "FI",
76
- Random: "RD",
77
- Cinema: "CM",
78
- Target: "TP",
79
- Key9: "9K",
80
- KeyCoop: "CP",
81
- Key1: "1K",
82
- Key3: "3K",
83
- Key2: "2K",
84
- ScoreV2: "SV2",
85
- Mirror: "MR"
51
+ const ModsAbbreviation = {
52
+ NoFail: "NF",
53
+ Easy: "EZ",
54
+ TouchDevice: "TD",
55
+ Hidden: "HD",
56
+ HardRock: "HR",
57
+ SuddenDeath: "SD",
58
+ DoubleTime: "DT",
59
+ Relax: "RX",
60
+ HalfTime: "HT",
61
+ Nightcore: "NC",
62
+ Flashlight: "FL",
63
+ Autoplay: "AT",
64
+ SpunOut: "SO",
65
+ AutoPilot: "AP",
66
+ Perfect: "PF",
67
+ Key4: "4K",
68
+ Key5: "5K",
69
+ Key6: "6K",
70
+ Key7: "7K",
71
+ Key8: "8K",
72
+ FadeIn: "FI",
73
+ Random: "RD",
74
+ Cinema: "CM",
75
+ Target: "TP",
76
+ Key9: "9K",
77
+ KeyCoop: "CP",
78
+ Key1: "1K",
79
+ Key3: "3K",
80
+ Key2: "2K",
81
+ ScoreV2: "SV2",
82
+ Mirror: "MR"
86
83
  };
87
- var BeatmapApprovedState = /* @__PURE__ */ ((BeatmapApprovedState3) => {
88
- BeatmapApprovedState3[BeatmapApprovedState3["Graveyard"] = -2] = "Graveyard";
89
- BeatmapApprovedState3[BeatmapApprovedState3["WIP"] = -1] = "WIP";
90
- BeatmapApprovedState3[BeatmapApprovedState3["Pending"] = 0] = "Pending";
91
- BeatmapApprovedState3[BeatmapApprovedState3["Ranked"] = 1] = "Ranked";
92
- BeatmapApprovedState3[BeatmapApprovedState3["Approved"] = 2] = "Approved";
93
- BeatmapApprovedState3[BeatmapApprovedState3["Qualified"] = 3] = "Qualified";
94
- BeatmapApprovedState3[BeatmapApprovedState3["Loved"] = 4] = "Loved";
95
- return BeatmapApprovedState3;
96
- })(BeatmapApprovedState || {});
97
- var BeatmapGenre = /* @__PURE__ */ ((BeatmapGenre3) => {
98
- BeatmapGenre3[BeatmapGenre3["Any"] = 0] = "Any";
99
- BeatmapGenre3[BeatmapGenre3["Unspecified"] = 1] = "Unspecified";
100
- BeatmapGenre3[BeatmapGenre3["VideoGame"] = 2] = "VideoGame";
101
- BeatmapGenre3[BeatmapGenre3["Anime"] = 3] = "Anime";
102
- BeatmapGenre3[BeatmapGenre3["Rock"] = 4] = "Rock";
103
- BeatmapGenre3[BeatmapGenre3["Pop"] = 5] = "Pop";
104
- BeatmapGenre3[BeatmapGenre3["Other"] = 6] = "Other";
105
- BeatmapGenre3[BeatmapGenre3["Novelty"] = 7] = "Novelty";
106
- BeatmapGenre3[BeatmapGenre3["HipHop"] = 9] = "HipHop";
107
- BeatmapGenre3[BeatmapGenre3["Electronic"] = 10] = "Electronic";
108
- BeatmapGenre3[BeatmapGenre3["Metal"] = 11] = "Metal";
109
- BeatmapGenre3[BeatmapGenre3["Classic"] = 12] = "Classic";
110
- BeatmapGenre3[BeatmapGenre3["Folk"] = 13] = "Folk";
111
- BeatmapGenre3[BeatmapGenre3["Jazz"] = 14] = "Jazz";
112
- return BeatmapGenre3;
113
- })(BeatmapGenre || {});
114
- var BeatmapLanguage = /* @__PURE__ */ ((BeatmapLanguage3) => {
115
- BeatmapLanguage3[BeatmapLanguage3["Any"] = 0] = "Any";
116
- BeatmapLanguage3[BeatmapLanguage3["Unspecified"] = 1] = "Unspecified";
117
- BeatmapLanguage3[BeatmapLanguage3["English"] = 2] = "English";
118
- BeatmapLanguage3[BeatmapLanguage3["Japanese"] = 3] = "Japanese";
119
- BeatmapLanguage3[BeatmapLanguage3["Chinese"] = 4] = "Chinese";
120
- BeatmapLanguage3[BeatmapLanguage3["Instrumental"] = 5] = "Instrumental";
121
- BeatmapLanguage3[BeatmapLanguage3["Korean"] = 6] = "Korean";
122
- BeatmapLanguage3[BeatmapLanguage3["French"] = 7] = "French";
123
- BeatmapLanguage3[BeatmapLanguage3["German"] = 8] = "German";
124
- BeatmapLanguage3[BeatmapLanguage3["Swedish"] = 9] = "Swedish";
125
- BeatmapLanguage3[BeatmapLanguage3["Spanish"] = 10] = "Spanish";
126
- BeatmapLanguage3[BeatmapLanguage3["Italian"] = 11] = "Italian";
127
- BeatmapLanguage3[BeatmapLanguage3["Russian"] = 12] = "Russian";
128
- BeatmapLanguage3[BeatmapLanguage3["Polish"] = 13] = "Polish";
129
- BeatmapLanguage3[BeatmapLanguage3["Other"] = 14] = "Other";
130
- return BeatmapLanguage3;
131
- })(BeatmapLanguage || {});
132
- var ScoreRank = /* @__PURE__ */ ((ScoreRank2) => {
133
- ScoreRank2[ScoreRank2["XH"] = 0] = "XH";
134
- ScoreRank2[ScoreRank2["X"] = 1] = "X";
135
- ScoreRank2[ScoreRank2["SH"] = 2] = "SH";
136
- ScoreRank2[ScoreRank2["S"] = 3] = "S";
137
- ScoreRank2[ScoreRank2["A"] = 4] = "A";
138
- ScoreRank2[ScoreRank2["B"] = 5] = "B";
139
- ScoreRank2[ScoreRank2["C"] = 6] = "C";
140
- ScoreRank2[ScoreRank2["D"] = 7] = "D";
141
- ScoreRank2[ScoreRank2["F"] = 8] = "F";
142
- return ScoreRank2;
143
- })(ScoreRank || {});
144
- var MatchScoringType = /* @__PURE__ */ ((MatchScoringType2) => {
145
- MatchScoringType2[MatchScoringType2["Score"] = 0] = "Score";
146
- MatchScoringType2[MatchScoringType2["Accuracy"] = 1] = "Accuracy";
147
- MatchScoringType2[MatchScoringType2["Combo"] = 2] = "Combo";
148
- MatchScoringType2[MatchScoringType2["ScoreV2"] = 3] = "ScoreV2";
149
- return MatchScoringType2;
150
- })(MatchScoringType || {});
151
- var MatchTeamType = /* @__PURE__ */ ((MatchTeamType2) => {
152
- MatchTeamType2[MatchTeamType2["HeadToHead"] = 0] = "HeadToHead";
153
- MatchTeamType2[MatchTeamType2["TagCoop"] = 1] = "TagCoop";
154
- MatchTeamType2[MatchTeamType2["TeamVs"] = 2] = "TeamVs";
155
- MatchTeamType2[MatchTeamType2["TagTeamVs"] = 3] = "TagTeamVs";
156
- return MatchTeamType2;
157
- })(MatchTeamType || {});
158
- var Team = /* @__PURE__ */ ((Team2) => {
159
- Team2[Team2["None"] = 0] = "None";
160
- Team2[Team2["Blue"] = 1] = "Blue";
161
- Team2[Team2["Red"] = 2] = "Red";
162
- return Team2;
163
- })(Team || {});
84
+ let BeatmapApprovedState = /* @__PURE__ */ function(BeatmapApprovedState) {
85
+ BeatmapApprovedState[BeatmapApprovedState["Graveyard"] = -2] = "Graveyard";
86
+ BeatmapApprovedState[BeatmapApprovedState["WIP"] = -1] = "WIP";
87
+ BeatmapApprovedState[BeatmapApprovedState["Pending"] = 0] = "Pending";
88
+ BeatmapApprovedState[BeatmapApprovedState["Ranked"] = 1] = "Ranked";
89
+ BeatmapApprovedState[BeatmapApprovedState["Approved"] = 2] = "Approved";
90
+ BeatmapApprovedState[BeatmapApprovedState["Qualified"] = 3] = "Qualified";
91
+ BeatmapApprovedState[BeatmapApprovedState["Loved"] = 4] = "Loved";
92
+ return BeatmapApprovedState;
93
+ }({});
94
+ let BeatmapGenre = /* @__PURE__ */ function(BeatmapGenre) {
95
+ BeatmapGenre[BeatmapGenre["Any"] = 0] = "Any";
96
+ BeatmapGenre[BeatmapGenre["Unspecified"] = 1] = "Unspecified";
97
+ BeatmapGenre[BeatmapGenre["VideoGame"] = 2] = "VideoGame";
98
+ BeatmapGenre[BeatmapGenre["Anime"] = 3] = "Anime";
99
+ BeatmapGenre[BeatmapGenre["Rock"] = 4] = "Rock";
100
+ BeatmapGenre[BeatmapGenre["Pop"] = 5] = "Pop";
101
+ BeatmapGenre[BeatmapGenre["Other"] = 6] = "Other";
102
+ BeatmapGenre[BeatmapGenre["Novelty"] = 7] = "Novelty";
103
+ BeatmapGenre[BeatmapGenre["HipHop"] = 9] = "HipHop";
104
+ BeatmapGenre[BeatmapGenre["Electronic"] = 10] = "Electronic";
105
+ BeatmapGenre[BeatmapGenre["Metal"] = 11] = "Metal";
106
+ BeatmapGenre[BeatmapGenre["Classic"] = 12] = "Classic";
107
+ BeatmapGenre[BeatmapGenre["Folk"] = 13] = "Folk";
108
+ BeatmapGenre[BeatmapGenre["Jazz"] = 14] = "Jazz";
109
+ return BeatmapGenre;
110
+ }({});
111
+ let BeatmapLanguage = /* @__PURE__ */ function(BeatmapLanguage) {
112
+ BeatmapLanguage[BeatmapLanguage["Any"] = 0] = "Any";
113
+ BeatmapLanguage[BeatmapLanguage["Unspecified"] = 1] = "Unspecified";
114
+ BeatmapLanguage[BeatmapLanguage["English"] = 2] = "English";
115
+ BeatmapLanguage[BeatmapLanguage["Japanese"] = 3] = "Japanese";
116
+ BeatmapLanguage[BeatmapLanguage["Chinese"] = 4] = "Chinese";
117
+ BeatmapLanguage[BeatmapLanguage["Instrumental"] = 5] = "Instrumental";
118
+ BeatmapLanguage[BeatmapLanguage["Korean"] = 6] = "Korean";
119
+ BeatmapLanguage[BeatmapLanguage["French"] = 7] = "French";
120
+ BeatmapLanguage[BeatmapLanguage["German"] = 8] = "German";
121
+ BeatmapLanguage[BeatmapLanguage["Swedish"] = 9] = "Swedish";
122
+ BeatmapLanguage[BeatmapLanguage["Spanish"] = 10] = "Spanish";
123
+ BeatmapLanguage[BeatmapLanguage["Italian"] = 11] = "Italian";
124
+ BeatmapLanguage[BeatmapLanguage["Russian"] = 12] = "Russian";
125
+ BeatmapLanguage[BeatmapLanguage["Polish"] = 13] = "Polish";
126
+ BeatmapLanguage[BeatmapLanguage["Other"] = 14] = "Other";
127
+ return BeatmapLanguage;
128
+ }({});
129
+ let ScoreRank = /* @__PURE__ */ function(ScoreRank) {
130
+ ScoreRank[ScoreRank["XH"] = 0] = "XH";
131
+ ScoreRank[ScoreRank["X"] = 1] = "X";
132
+ ScoreRank[ScoreRank["SH"] = 2] = "SH";
133
+ ScoreRank[ScoreRank["S"] = 3] = "S";
134
+ ScoreRank[ScoreRank["A"] = 4] = "A";
135
+ ScoreRank[ScoreRank["B"] = 5] = "B";
136
+ ScoreRank[ScoreRank["C"] = 6] = "C";
137
+ ScoreRank[ScoreRank["D"] = 7] = "D";
138
+ ScoreRank[ScoreRank["F"] = 8] = "F";
139
+ return ScoreRank;
140
+ }({});
141
+ let MatchScoringType = /* @__PURE__ */ function(MatchScoringType) {
142
+ MatchScoringType[MatchScoringType["Score"] = 0] = "Score";
143
+ MatchScoringType[MatchScoringType["Accuracy"] = 1] = "Accuracy";
144
+ MatchScoringType[MatchScoringType["Combo"] = 2] = "Combo";
145
+ MatchScoringType[MatchScoringType["ScoreV2"] = 3] = "ScoreV2";
146
+ return MatchScoringType;
147
+ }({});
148
+ let MatchTeamType = /* @__PURE__ */ function(MatchTeamType) {
149
+ MatchTeamType[MatchTeamType["HeadToHead"] = 0] = "HeadToHead";
150
+ MatchTeamType[MatchTeamType["TagCoop"] = 1] = "TagCoop";
151
+ MatchTeamType[MatchTeamType["TeamVs"] = 2] = "TeamVs";
152
+ MatchTeamType[MatchTeamType["TagTeamVs"] = 3] = "TagTeamVs";
153
+ return MatchTeamType;
154
+ }({});
155
+ let Team = /* @__PURE__ */ function(Team) {
156
+ Team[Team["None"] = 0] = "None";
157
+ Team[Team["Blue"] = 1] = "Blue";
158
+ Team[Team["Red"] = 2] = "Red";
159
+ return Team;
160
+ }({});
164
161
 
165
162
  // src/utils/URLBuilder.ts
166
- var URLBuilder = class {
167
- static gameModeToURLPattern(mode) {
168
- switch (mode) {
169
- case 0 /* Standard */:
170
- return "osu";
171
- case 1 /* Taiko */:
172
- return "taiko";
173
- case 2 /* Catch */:
174
- return "fruits";
175
- case 3 /* Mania */:
176
- return "mania";
177
- default:
178
- throw new Error("INVALID_GAMEMODE");
179
- }
180
- }
181
- static avatar(id) {
182
- return `https://a.ppy.sh/${id}`;
183
- }
184
- static profile(idOrName) {
185
- return `https://osu.ppy.sh/users/${idOrName}`;
186
- }
187
- static banner(userId, hash, ext) {
188
- return `https://assets.ppy.sh/user-profile-covers/${userId}/${hash}.${ext}`;
189
- }
190
- static defaultBanner(id, ext) {
191
- return `https://osu.ppy.sh/images/headers/profile-covers/c${id}.${ext}`;
192
- }
193
- static beatmapsetURL(beatmapsetId) {
194
- return `https://osu.ppy.sh/beatmapsets/${beatmapsetId}`;
195
- }
196
- static beatmapURL(beatmapsetId, beatmapId, mode) {
197
- const m = URLBuilder.gameModeToURLPattern(mode);
198
- return `https://osu.ppy.sh/beatmapsets/${beatmapsetId}#${m}/${beatmapId}`;
199
- }
200
- static beatmapCoverImage(beatmapsetId) {
201
- return `https://assets.ppy.sh/beatmaps/${beatmapsetId}/covers/cover.jpg`;
202
- }
203
- static beatmapCoverThumbnail(beatmapsetId) {
204
- return `https://b.ppy.sh/thumb/${beatmapsetId}l.jpg`;
205
- }
206
- static scoreURL(mode, scoreId) {
207
- const m = URLBuilder.gameModeToURLPattern(mode);
208
- return `https://osu.ppy.sh/scores/${m}/${scoreId}`;
209
- }
163
+ var URLBuilder = class URLBuilder {
164
+ static gameModeToURLPattern(mode) {
165
+ switch (mode) {
166
+ case 0: return "osu";
167
+ case 1: return "taiko";
168
+ case 2: return "fruits";
169
+ case 3: return "mania";
170
+ default: throw new Error("INVALID_GAMEMODE");
171
+ }
172
+ }
173
+ static avatar(id) {
174
+ return `https://a.ppy.sh/${id}`;
175
+ }
176
+ static profile(idOrName) {
177
+ return `https://osu.ppy.sh/users/${idOrName}`;
178
+ }
179
+ static banner(userId, hash, ext) {
180
+ return `https://assets.ppy.sh/user-profile-covers/${userId}/${hash}.${ext}`;
181
+ }
182
+ static defaultBanner(id, ext) {
183
+ return `https://osu.ppy.sh/images/headers/profile-covers/c${id}.${ext}`;
184
+ }
185
+ static beatmapsetURL(beatmapsetId) {
186
+ return `https://osu.ppy.sh/beatmapsets/${beatmapsetId}`;
187
+ }
188
+ static beatmapURL(beatmapsetId, beatmapId, mode) {
189
+ return `https://osu.ppy.sh/beatmapsets/${beatmapsetId}#${URLBuilder.gameModeToURLPattern(mode)}/${beatmapId}`;
190
+ }
191
+ static beatmapCoverImage(beatmapsetId) {
192
+ return `https://assets.ppy.sh/beatmaps/${beatmapsetId}/covers/cover.jpg`;
193
+ }
194
+ static beatmapCoverThumbnail(beatmapsetId) {
195
+ return `https://b.ppy.sh/thumb/${beatmapsetId}l.jpg`;
196
+ }
197
+ static scoreURL(mode, scoreId) {
198
+ return `https://osu.ppy.sh/scores/${URLBuilder.gameModeToURLPattern(mode)}/${scoreId}`;
199
+ }
210
200
  };
211
201
 
202
+ // \0@oxc-project+runtime@0.159.0/helpers/esm/typeof.js
203
+ function _typeof(o) {
204
+ "@babel/helpers - typeof";
205
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
206
+ return typeof o;
207
+ } : function(o) {
208
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
209
+ }, _typeof(o);
210
+ }
211
+
212
+ // \0@oxc-project+runtime@0.159.0/helpers/esm/toPrimitive.js
213
+ function toPrimitive(t, e) {
214
+ if ("object" != _typeof(t) || !t) return t;
215
+ var r;
216
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
217
+ var i = r.call(t, e || "default");
218
+ if ("object" != _typeof(i)) return i;
219
+ throw new TypeError("@@toPrimitive must return a primitive value.");
220
+ }
221
+ return ("string" === e ? String : Number)(t);
222
+ }
223
+
224
+ // \0@oxc-project+runtime@0.159.0/helpers/esm/toPropertyKey.js
225
+ function toPropertyKey(t) {
226
+ var i = toPrimitive(t, "string");
227
+ return "symbol" == _typeof(i) ? i : i + "";
228
+ }
229
+
230
+ // \0@oxc-project+runtime@0.159.0/helpers/esm/defineProperty.js
231
+ function _defineProperty(e, r, t) {
232
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
233
+ value: t,
234
+ enumerable: !0,
235
+ configurable: !0,
236
+ writable: !0
237
+ }) : e[r] = t, e;
238
+ }
239
+
212
240
  // src/structures/ModsBitField.ts
213
- var _ModsBitField = class {
214
- constructor(bits = 0n) {
215
- this.bitfield = _ModsBitField.resolve(bits);
216
- }
217
- any(bit) {
218
- return (this.bitfield & _ModsBitField.resolve(bit)) !== 0n;
219
- }
220
- equals(bit) {
221
- return this.bitfield === _ModsBitField.resolve(bit);
222
- }
223
- has(bit) {
224
- bit = _ModsBitField.resolve(bit);
225
- return (this.bitfield & bit) === bit;
226
- }
227
- add(...bits) {
228
- let total = 0n;
229
- for (const bit of bits) {
230
- total |= _ModsBitField.resolve(bit);
231
- }
232
- this.bitfield |= total;
233
- return this;
234
- }
235
- remove(...bits) {
236
- let total = 0n;
237
- for (const bit of bits) {
238
- total |= _ModsBitField.resolve(bit);
239
- }
240
- this.bitfield &= ~total;
241
- return this;
242
- }
243
- toArray() {
244
- return Object.keys(_ModsBitField.Flags).filter((bit) => this.has(bit));
245
- }
246
- serialize() {
247
- const serialized = {};
248
- for (const [flag, bit] of Object.entries(_ModsBitField.Flags)) {
249
- serialized[flag] = this.has(bit);
250
- }
251
- return serialized;
252
- }
253
- isNone() {
254
- return this.bitfield === 0n;
255
- }
256
- valueOf() {
257
- return this.bitfield;
258
- }
259
- static resolve(bit) {
260
- if (Array.isArray(bit)) {
261
- return bit.map(_ModsBitField.resolve).reduce((acc, now) => acc | now, 0n);
262
- }
263
- if (bit instanceof _ModsBitField) {
264
- return bit.bitfield;
265
- }
266
- if (typeof bit === "number")
267
- return BigInt(bit);
268
- if (typeof bit === "string") {
269
- if (!isNaN(+bit))
270
- return BigInt(bit);
271
- const a = _ModsBitField.Flags[bit];
272
- if (typeof a === "undefined")
273
- throw new Error("INVALID_BITFIELD");
274
- return a;
275
- }
276
- return bit;
277
- }
241
+ var _ModsBitField;
242
+ var ModsBitField = class ModsBitField {
243
+ constructor(bits = 0n) {
244
+ _defineProperty(this, "bitfield", void 0);
245
+ this.bitfield = ModsBitField.resolve(bits);
246
+ }
247
+ any(bit) {
248
+ return (this.bitfield & ModsBitField.resolve(bit)) !== 0n;
249
+ }
250
+ equals(bit) {
251
+ return this.bitfield === ModsBitField.resolve(bit);
252
+ }
253
+ has(bit) {
254
+ bit = ModsBitField.resolve(bit);
255
+ return (this.bitfield & bit) === bit;
256
+ }
257
+ add(...bits) {
258
+ let total = 0n;
259
+ for (const bit of bits) total |= ModsBitField.resolve(bit);
260
+ this.bitfield |= total;
261
+ return this;
262
+ }
263
+ remove(...bits) {
264
+ let total = 0n;
265
+ for (const bit of bits) total |= ModsBitField.resolve(bit);
266
+ this.bitfield &= ~total;
267
+ return this;
268
+ }
269
+ toArray() {
270
+ return Object.keys(ModsBitField.Flags).filter((bit) => this.has(bit));
271
+ }
272
+ serialize() {
273
+ const serialized = {};
274
+ for (const [flag, bit] of Object.entries(ModsBitField.Flags)) serialized[flag] = this.has(bit);
275
+ return serialized;
276
+ }
277
+ isNone() {
278
+ return this.bitfield === 0n;
279
+ }
280
+ valueOf() {
281
+ return this.bitfield;
282
+ }
283
+ static resolve(bit) {
284
+ if (Array.isArray(bit)) return bit.map(ModsBitField.resolve).reduce((acc, now) => acc | now, 0n);
285
+ if (bit instanceof ModsBitField) return bit.bitfield;
286
+ if (typeof bit === "number") return BigInt(bit);
287
+ if (typeof bit === "string") {
288
+ if (!isNaN(+bit)) return BigInt(bit);
289
+ const a = ModsBitField.Flags[bit];
290
+ if (typeof a === "undefined") throw new Error("INVALID_BITFIELD");
291
+ return a;
292
+ }
293
+ return bit;
294
+ }
278
295
  };
279
- var ModsBitField = _ModsBitField;
280
- ModsBitField.Flags = Mods;
281
- ModsBitField.KeyMod = Mods.Key1 | Mods.Key2 | Mods.Key3 | Mods.Key4 | Mods.Key5 | Mods.Key6 | Mods.Key7 | Mods.Key8 | Mods.Key9 | Mods.KeyCoop;
282
- ModsBitField.FreeModAllowed = Mods.NoFail | Mods.Easy | Mods.Hidden | Mods.HardRock | Mods.SuddenDeath | Mods.Flashlight | Mods.FadeIn | Mods.Relax | Mods.AutoPilot | Mods.SpunOut | _ModsBitField.KeyMod;
283
- ModsBitField.ScoreIncreaseMods = Mods.Hidden | Mods.HardRock | Mods.DoubleTime | Mods.Flashlight | Mods.FadeIn;
296
+ _ModsBitField = ModsBitField;
297
+ _defineProperty(ModsBitField, "Flags", Mods);
298
+ _defineProperty(ModsBitField, "KeyMod", Mods.Key1 | Mods.Key2 | Mods.Key3 | Mods.Key4 | Mods.Key5 | Mods.Key6 | Mods.Key7 | Mods.Key8 | Mods.Key9 | Mods.KeyCoop);
299
+ _defineProperty(ModsBitField, "FreeModAllowed", Mods.NoFail | Mods.Easy | Mods.Hidden | Mods.HardRock | Mods.SuddenDeath | Mods.Flashlight | Mods.FadeIn | Mods.Relax | Mods.AutoPilot | Mods.SpunOut | _ModsBitField.KeyMod);
300
+ _defineProperty(ModsBitField, "ScoreIncreaseMods", Mods.Hidden | Mods.HardRock | Mods.DoubleTime | Mods.Flashlight | Mods.FadeIn);
284
301
 
285
302
  // src/utils/AccuracyCalculator.ts
286
- var AccuracyCalculator = class {
287
- static standard(count300, count100, count50, countMiss) {
288
- const max = count300 + count100 + count50 + countMiss;
289
- if (!max)
290
- return 0;
291
- return (count300 * 300 + count100 * 100 + count50 * 50) / (max * 300);
292
- }
293
- static taiko(count300, count100, countMiss) {
294
- const max = count300 + count100 + countMiss;
295
- if (!max)
296
- return 0;
297
- return (count300 + count100 * 0.5) / max;
298
- }
299
- static catch(count300, count100, count50, countKatu, countMiss) {
300
- const max = count300 + count100 + count50 + countKatu + countMiss;
301
- if (!max)
302
- return 0;
303
- return (count300 + count100 + count50) / max;
304
- }
305
- static mania(count300, count100, count50, countKatu, countGeki, countMiss) {
306
- const max = count300 + count100 + count50 + countKatu + countGeki + countMiss;
307
- if (!max)
308
- return 0;
309
- return (300 * countGeki + 300 * count300 + 200 * countKatu + 100 * count100 + 50 * count50) / (max * 300);
310
- }
311
- static maniaV2(count300, count100, count50, countKatu, countGeki, countMiss) {
312
- const max = count300 + count100 + count50 + countKatu + countGeki + countMiss;
313
- if (!max)
314
- return 0;
315
- return (305 * countGeki + 300 * count300 + 200 * countKatu + 100 * count100 + 50 * count50) / (max * 305);
316
- }
317
- static calculate(score, v2 = false) {
318
- const { statistics } = score;
319
- switch (score.mode) {
320
- case 0 /* Standard */:
321
- return AccuracyCalculator.standard(
322
- statistics.count300,
323
- statistics.count100,
324
- statistics.count50,
325
- statistics.countMiss
326
- );
327
- case 1 /* Taiko */:
328
- return AccuracyCalculator.taiko(
329
- statistics.count300,
330
- statistics.count100,
331
- statistics.countMiss
332
- );
333
- case 2 /* Catch */:
334
- return AccuracyCalculator.catch(
335
- statistics.count300,
336
- statistics.count100,
337
- statistics.count50,
338
- statistics.countKatu,
339
- statistics.countMiss
340
- );
341
- case 3 /* Mania */:
342
- return v2 ? AccuracyCalculator.maniaV2(
343
- statistics.count300,
344
- statistics.count100,
345
- statistics.count50,
346
- statistics.countKatu,
347
- statistics.countGeki,
348
- statistics.countMiss
349
- ) : AccuracyCalculator.mania(
350
- statistics.count300,
351
- statistics.count100,
352
- statistics.count50,
353
- statistics.countKatu,
354
- statistics.countGeki,
355
- statistics.countMiss
356
- );
357
- }
358
- }
303
+ var AccuracyCalculator = class AccuracyCalculator {
304
+ static standard(count300, count100, count50, countMiss) {
305
+ const max = count300 + count100 + count50 + countMiss;
306
+ if (!max) return 0;
307
+ return (count300 * 300 + count100 * 100 + count50 * 50) / (max * 300);
308
+ }
309
+ static taiko(count300, count100, countMiss) {
310
+ const max = count300 + count100 + countMiss;
311
+ if (!max) return 0;
312
+ return (count300 + count100 * .5) / max;
313
+ }
314
+ static catch(count300, count100, count50, countKatu, countMiss) {
315
+ const max = count300 + count100 + count50 + countKatu + countMiss;
316
+ if (!max) return 0;
317
+ return (count300 + count100 + count50) / max;
318
+ }
319
+ static mania(count300, count100, count50, countKatu, countGeki, countMiss) {
320
+ const max = count300 + count100 + count50 + countKatu + countGeki + countMiss;
321
+ if (!max) return 0;
322
+ return (300 * countGeki + 300 * count300 + 200 * countKatu + 100 * count100 + 50 * count50) / (max * 300);
323
+ }
324
+ static maniaV2(count300, count100, count50, countKatu, countGeki, countMiss) {
325
+ const max = count300 + count100 + count50 + countKatu + countGeki + countMiss;
326
+ if (!max) return 0;
327
+ return (305 * countGeki + 300 * count300 + 200 * countKatu + 100 * count100 + 50 * count50) / (max * 305);
328
+ }
329
+ static calculate(score, v2 = false) {
330
+ const { statistics } = score;
331
+ switch (score.mode) {
332
+ case 0: return AccuracyCalculator.standard(statistics.count300, statistics.count100, statistics.count50, statistics.countMiss);
333
+ case 1: return AccuracyCalculator.taiko(statistics.count300, statistics.count100, statistics.countMiss);
334
+ case 2: return AccuracyCalculator.catch(statistics.count300, statistics.count100, statistics.count50, statistics.countKatu, statistics.countMiss);
335
+ case 3: return v2 ? AccuracyCalculator.maniaV2(statistics.count300, statistics.count100, statistics.count50, statistics.countKatu, statistics.countGeki, statistics.countMiss) : AccuracyCalculator.mania(statistics.count300, statistics.count100, statistics.count50, statistics.countKatu, statistics.countGeki, statistics.countMiss);
336
+ }
337
+ }
359
338
  };
360
339
 
361
340
  // src/structures/BaseScore.ts
362
341
  var BaseScore = class {
363
- constructor(client, data, other) {
364
- this.client = client;
365
- this.score = +data.score;
366
- this.maxCombo = +data.maxcombo;
367
- this.statistics = {
368
- count50: +data.count50,
369
- count100: +data.count100,
370
- count300: +data.count300,
371
- countMiss: +data.countmiss,
372
- countKatu: +data.countkatu,
373
- countGeki: +data.countgeki
374
- };
375
- this.perfect = !!+data.perfect;
376
- this.enabledMods = new ModsBitField(data.enabled_mods);
377
- this.userId = data.user_id;
378
- this.rank = ScoreRank[data.rank];
379
- this.mode = other.mode ?? 0 /* Standard */;
380
- if ("beatmap_id" in data) {
381
- this.beatmapId = data.beatmap_id;
382
- } else {
383
- this.beatmapId = other.mapId;
384
- }
385
- this.accuracy = AccuracyCalculator.calculate(this);
386
- }
387
- async getPlayer(options = {}) {
388
- const candidates = await this.client.users.getUser({
389
- user: this.userId,
390
- type: "id" /* Id */,
391
- ...options
392
- });
393
- return candidates[0];
394
- }
395
- async getBeatmap() {
396
- const candidates = await this.client.beatmaps.getBeatmaps({
397
- beatmapId: this.beatmapId,
398
- mode: this.mode
399
- });
400
- return candidates[0];
401
- }
402
- getReplay() {
403
- return this.client.replays.getReplay({
404
- beatmapId: this.beatmapId,
405
- user: this.userId,
406
- type: "id" /* Id */
407
- });
408
- }
342
+ constructor(client, data, other) {
343
+ _defineProperty(this, "client", void 0);
344
+ _defineProperty(this, "score", void 0);
345
+ _defineProperty(this, "maxCombo", void 0);
346
+ _defineProperty(this, "statistics", void 0);
347
+ _defineProperty(this, "perfect", void 0);
348
+ _defineProperty(this, "enabledMods", void 0);
349
+ _defineProperty(this, "userId", void 0);
350
+ _defineProperty(this, "rank", void 0);
351
+ _defineProperty(this, "mode", void 0);
352
+ _defineProperty(this, "beatmapId", void 0);
353
+ _defineProperty(this, "accuracy", void 0);
354
+ this.client = client;
355
+ this.score = +data.score;
356
+ this.maxCombo = +data.maxcombo;
357
+ this.statistics = {
358
+ count50: +data.count50,
359
+ count100: +data.count100,
360
+ count300: +data.count300,
361
+ countMiss: +data.countmiss,
362
+ countKatu: +data.countkatu,
363
+ countGeki: +data.countgeki
364
+ };
365
+ this.perfect = !!+data.perfect;
366
+ this.enabledMods = new ModsBitField(data.enabled_mods ?? 0n);
367
+ this.userId = data.user_id;
368
+ this.rank = ScoreRank[data.rank];
369
+ this.mode = other.mode ?? 0;
370
+ if ("beatmap_id" in data) this.beatmapId = data.beatmap_id;
371
+ else this.beatmapId = other.mapId;
372
+ const isScoreV2 = this.enabledMods.has(Mods.ScoreV2);
373
+ this.accuracy = AccuracyCalculator.calculate(this, isScoreV2);
374
+ }
375
+ async getPlayer(options = {}) {
376
+ return (await this.client.users.getUser({
377
+ user: this.userId,
378
+ type: "id",
379
+ gameMode: this.mode,
380
+ ...options
381
+ }))[0];
382
+ }
383
+ async getBeatmap() {
384
+ return (await this.client.beatmaps.getBeatmaps({
385
+ beatmapId: this.beatmapId,
386
+ mode: this.mode
387
+ }))[0];
388
+ }
389
+ getReplay() {
390
+ return this.client.replays.getReplay({
391
+ beatmapId: this.beatmapId,
392
+ mode: this.mode,
393
+ user: this.userId,
394
+ type: "id"
395
+ });
396
+ }
409
397
  };
410
398
 
411
399
  // src/structures/BeatmapScore.ts
412
400
  var BeatmapScore = class extends BaseScore {
413
- constructor(client, data, other) {
414
- super(client, data, other);
415
- this.scoreId = null;
416
- this.username = null;
417
- this.pp = null;
418
- this.replayAvailable = null;
419
- this.date = new Date(data.date);
420
- if ("score_id" in data) {
421
- this.scoreId = data.score_id;
422
- }
423
- if ("username" in data) {
424
- this.username = data.username;
425
- }
426
- if ("pp" in data) {
427
- this.pp = +data.pp;
428
- }
429
- if ("replay_available" in data) {
430
- this.replayAvailable = !!+data.replay_available;
431
- }
432
- }
433
- scoreURL() {
434
- if (!this.scoreId)
435
- return null;
436
- return URLBuilder.scoreURL(this.mode, this.scoreId);
437
- }
401
+ constructor(client, data, other) {
402
+ super(client, data, other);
403
+ _defineProperty(this, "date", void 0);
404
+ _defineProperty(this, "scoreId", null);
405
+ _defineProperty(this, "username", null);
406
+ _defineProperty(this, "pp", null);
407
+ _defineProperty(this, "replayAvailable", null);
408
+ this.date = new Date(data.date);
409
+ if ("score_id" in data) this.scoreId = data.score_id;
410
+ if ("username" in data) this.username = data.username;
411
+ if ("pp" in data) this.pp = +data.pp;
412
+ if ("replay_available" in data) this.replayAvailable = !!+data.replay_available;
413
+ }
414
+ scoreURL() {
415
+ if (!this.scoreId) return null;
416
+ return URLBuilder.scoreURL(this.mode, this.scoreId);
417
+ }
438
418
  };
439
419
 
440
420
  // src/structures/UserEvent.ts
441
421
  var UserEvent = class {
442
- constructor(user, data) {
443
- this.user = user;
444
- this.displayHtml = data.display_html;
445
- this.beatmapId = data.beatmap_id;
446
- this.beatmapsetId = data.beatmapset_id;
447
- this.date = new Date(data.date);
448
- this.epicfactor = +data.epicfactor;
449
- }
450
- async getBeatmap() {
451
- const candidates = await this.user.client.beatmaps.getBeatmaps({
452
- beatmapId: this.beatmapId,
453
- beatmapsetId: this.beatmapsetId
454
- });
455
- return candidates[0];
456
- }
457
- async getBeatmapset() {
458
- const beatmap = await this.getBeatmap();
459
- return beatmap?.getBeatmapset();
460
- }
422
+ constructor(user, data) {
423
+ _defineProperty(this, "user", void 0);
424
+ _defineProperty(this, "displayHtml", void 0);
425
+ _defineProperty(this, "beatmapId", void 0);
426
+ _defineProperty(this, "beatmapsetId", void 0);
427
+ _defineProperty(this, "date", void 0);
428
+ _defineProperty(this, "epicfactor", void 0);
429
+ this.user = user;
430
+ this.displayHtml = data.display_html;
431
+ this.beatmapId = data.beatmap_id;
432
+ this.beatmapsetId = data.beatmapset_id;
433
+ this.date = new Date(data.date);
434
+ this.epicfactor = +data.epicfactor;
435
+ }
436
+ async getBeatmap() {
437
+ return (await this.user.client.beatmaps.getBeatmaps({
438
+ beatmapId: this.beatmapId,
439
+ beatmapsetId: this.beatmapsetId
440
+ }))[0];
441
+ }
442
+ async getBeatmapset() {
443
+ return (await this.getBeatmap())?.getBeatmapset();
444
+ }
461
445
  };
462
446
 
463
447
  // src/structures/User.ts
464
448
  var User = class {
465
- constructor(client, data) {
466
- this.client = client;
467
- this.id = data.user_id;
468
- this.username = data.username;
469
- this.joinDate = new Date(data.join_date);
470
- this.count300 = +data.count300;
471
- this.count100 = +data.count100;
472
- this.count50 = +data.count50;
473
- this.playcount = +data.playcount;
474
- this.playtime = +data.total_seconds_played;
475
- this.rankedScore = +data.ranked_score;
476
- this.totalScore = +data.total_score;
477
- this.rank = +data.pp_rank;
478
- this.level = +data.level;
479
- this.pp = +data.pp_raw;
480
- this.accuracy = +data.accuracy;
481
- this.scoreRankCount = {
482
- ss: +data.count_rank_ss,
483
- ssh: +data.count_rank_ssh,
484
- s: +data.count_rank_s,
485
- sh: +data.count_rank_sh,
486
- a: +data.count_rank_a
487
- };
488
- this.country = data.country;
489
- this.countryRank = +data.pp_country_rank;
490
- this.events = data.events.map((v) => new UserEvent(this, v));
491
- this.banner = null;
492
- }
493
- avatarURL() {
494
- return URLBuilder.avatar(this.id);
495
- }
496
- profileURL() {
497
- return URLBuilder.profile(this.id);
498
- }
499
- async fetchBanner(force = false) {
500
- if (!force && this.banner)
501
- return this.banner;
502
- const url = await this.client.users.fetchBanner({ id: this.id });
503
- return this.banner = url;
504
- }
505
- getBest(options = {}) {
506
- return this.client.users.getUserBest({
507
- user: this.id,
508
- type: "id" /* Id */,
509
- ...options
510
- });
511
- }
512
- getRecent(options = {}) {
513
- return this.client.users.getUserRecent({
514
- user: this.id,
515
- type: "id" /* Id */,
516
- ...options
517
- });
518
- }
449
+ constructor(client, data) {
450
+ _defineProperty(this, "client", void 0);
451
+ _defineProperty(this, "id", void 0);
452
+ _defineProperty(this, "username", void 0);
453
+ _defineProperty(this, "joinDate", void 0);
454
+ _defineProperty(this, "playcount", void 0);
455
+ _defineProperty(this, "level", void 0);
456
+ _defineProperty(this, "country", void 0);
457
+ _defineProperty(this, "playtime", void 0);
458
+ _defineProperty(this, "events", void 0);
459
+ _defineProperty(this, "banner", void 0);
460
+ _defineProperty(this, "count300", void 0);
461
+ _defineProperty(this, "count100", void 0);
462
+ _defineProperty(this, "count50", void 0);
463
+ _defineProperty(this, "rankedScore", void 0);
464
+ _defineProperty(this, "totalScore", void 0);
465
+ _defineProperty(this, "rank", void 0);
466
+ _defineProperty(this, "countryRank", void 0);
467
+ _defineProperty(this, "pp", void 0);
468
+ _defineProperty(this, "accuracy", void 0);
469
+ _defineProperty(this, "scoreRankCount", void 0);
470
+ this.client = client;
471
+ this.id = data.user_id;
472
+ this.username = data.username;
473
+ this.joinDate = new Date(data.join_date);
474
+ this.count300 = +data.count300;
475
+ this.count100 = +data.count100;
476
+ this.count50 = +data.count50;
477
+ this.playcount = +data.playcount;
478
+ this.playtime = +data.total_seconds_played;
479
+ this.rankedScore = +data.ranked_score;
480
+ this.totalScore = +data.total_score;
481
+ this.rank = +data.pp_rank;
482
+ this.level = +data.level;
483
+ this.pp = +data.pp_raw;
484
+ this.accuracy = +data.accuracy;
485
+ this.scoreRankCount = {
486
+ ss: +data.count_rank_ss,
487
+ ssh: +data.count_rank_ssh,
488
+ s: +data.count_rank_s,
489
+ sh: +data.count_rank_sh,
490
+ a: +data.count_rank_a
491
+ };
492
+ this.country = data.country;
493
+ this.countryRank = +data.pp_country_rank;
494
+ this.events = data.events.map((v) => new UserEvent(this, v));
495
+ this.banner = null;
496
+ }
497
+ avatarURL() {
498
+ return URLBuilder.avatar(this.id);
499
+ }
500
+ profileURL() {
501
+ return URLBuilder.profile(this.id);
502
+ }
503
+ async fetchBanner(force = false) {
504
+ if (!force && this.banner) return this.banner;
505
+ const url = await this.client.users.fetchBanner({ id: this.id });
506
+ return this.banner = url;
507
+ }
508
+ getBest(options = {}) {
509
+ return this.client.users.getUserBest({
510
+ user: this.id,
511
+ type: "id",
512
+ ...options
513
+ });
514
+ }
515
+ getRecent(options = {}) {
516
+ return this.client.users.getUserRecent({
517
+ user: this.id,
518
+ type: "id",
519
+ ...options
520
+ });
521
+ }
519
522
  };
520
523
 
521
524
  // src/managers/BaseManager.ts
522
525
  var BaseManager = class {
523
- constructor(client) {
524
- this.client = client;
525
- }
526
+ constructor(client) {
527
+ _defineProperty(this, "client", void 0);
528
+ this.client = client;
529
+ }
526
530
  };
527
531
 
532
+ // src/utils/omitUndefined.ts
533
+ function omitUndefined(obj) {
534
+ return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== void 0));
535
+ }
536
+
528
537
  // src/managers/UserManager.ts
529
538
  var UserManager = class extends BaseManager {
530
- async getUser(options) {
531
- const queries = {
532
- u: options.user,
533
- m: options.gameMode,
534
- type: options.type,
535
- event_days: options.eventDays
536
- };
537
- const res = await this.client.request({
538
- path: "get_user",
539
- queries
540
- });
541
- return res.map((v) => new User(this.client, v));
542
- }
543
- async fetchBanner({ id }) {
544
- const context = await request.get(`https://osu.ppy.sh/users/${id}`);
545
- const banner_regex = new RegExp(`https:\\\\\\/\\\\\\/assets\\.ppy\\.sh\\\\\\/user-profile-covers\\\\\\/${id}\\\\\\/(?<hash>[0-9a-z]*?)\\.(?<ext>.*?)&`, "gm");
546
- const banner = banner_regex.exec(context.text);
547
- if (banner) {
548
- const url2 = URLBuilder.banner(id, banner?.groups?.hash, banner?.groups?.ext);
549
- return url2;
550
- }
551
- const default_banner_regex = new RegExp("https:\\\\\\/\\\\\\/osu\\.ppy\\.sh\\\\\\/images\\\\\\/headers\\\\\\/profile-covers\\\\\\/c(?<id>\\d)\\.(?<ext>.*?)&", "gm");
552
- const defaultBanner = default_banner_regex.exec(context.text);
553
- const url = URLBuilder.defaultBanner(defaultBanner?.groups?.id, defaultBanner?.groups?.ext);
554
- return url;
555
- }
556
- async getUserBest(options) {
557
- const queries = {
558
- u: options.user,
559
- m: options.mode,
560
- type: options.type,
561
- limit: options.limit
562
- };
563
- const res = await this.client.request({
564
- path: "get_user_best",
565
- queries
566
- });
567
- return res.map((v) => new BeatmapScore(this.client, v, { mode: options.mode }));
568
- }
569
- async getUserRecent(options) {
570
- const queries = {
571
- u: options.user,
572
- m: options.mode,
573
- type: options.type,
574
- limit: options.limit
575
- };
576
- const res = await this.client.request({
577
- path: "get_user_recent",
578
- queries
579
- });
580
- return res.map((v) => new BeatmapScore(this.client, v, { mode: options.mode }));
581
- }
539
+ async getUser(options) {
540
+ const queries = omitUndefined({
541
+ u: options.user,
542
+ m: options.gameMode,
543
+ type: options.type,
544
+ event_days: options.eventDays
545
+ });
546
+ return (await this.client.request({
547
+ path: "get_user",
548
+ queries
549
+ })).map((v) => new User(this.client, v));
550
+ }
551
+ async fetchBanner({ id }) {
552
+ const context = await request.get(`https://osu.ppy.sh/users/${id}`);
553
+ const banner = new RegExp(`https:\\\\\\/\\\\\\/assets\\.ppy\\.sh\\\\\\/user-profile-covers\\\\\\\/${id}\\\\\\/(?<hash>[0-9a-z]*?)\\.(?<ext>.*?)&`, "gm").exec(context.text);
554
+ if (banner) return URLBuilder.banner(id, banner?.groups?.hash, banner?.groups?.ext);
555
+ const defaultBanner = (/* @__PURE__ */ new RegExp("https:\\\\\\/\\\\\\/osu\\.ppy\\.sh\\\\\\/images\\\\\\/headers\\\\\\/profile-covers\\\\\\/c(?<id>\\d)\\.(?<ext>.*?)&", "gm")).exec(context.text);
556
+ return URLBuilder.defaultBanner(defaultBanner?.groups?.id, defaultBanner?.groups?.ext);
557
+ }
558
+ async getUserBest(options) {
559
+ const queries = omitUndefined({
560
+ u: options.user,
561
+ m: options.mode,
562
+ type: options.type,
563
+ limit: options.limit
564
+ });
565
+ return (await this.client.request({
566
+ path: "get_user_best",
567
+ queries
568
+ })).map((v) => new BeatmapScore(this.client, v, omitUndefined({ mode: options.mode })));
569
+ }
570
+ async getUserRecent(options) {
571
+ const queries = omitUndefined({
572
+ u: options.user,
573
+ m: options.mode,
574
+ type: options.type,
575
+ limit: options.limit
576
+ });
577
+ return (await this.client.request({
578
+ path: "get_user_recent",
579
+ queries
580
+ })).map((v) => new BeatmapScore(this.client, v, omitUndefined({ mode: options.mode })));
581
+ }
582
582
  };
583
583
 
584
584
  // src/utils/toSqlDate.ts
585
585
  function toSqlDate(date) {
586
- return date.toISOString().slice(0, 19).replace("T", " ");
586
+ return date.toISOString().slice(0, 19).replace("T", " ");
587
587
  }
588
588
 
589
589
  // src/structures/Beatmapset.ts
590
590
  var Beatmapset = class {
591
- constructor(client, data, maps) {
592
- this.client = client;
593
- this.beatmaps = maps;
594
- this.id = data.beatmapsetId;
595
- this.approvedState = data.approvedState;
596
- this.length = data.totalLength;
597
- this.submitDate = data.submitDate;
598
- this.approvedDate = data.approvedDate;
599
- this.lastUpdate = data.lastUpdate;
600
- this.artist = data.artist;
601
- this.title = data.title;
602
- this.creator = data.creator;
603
- this.creatorId = data.creatorId;
604
- this.source = data.source;
605
- this.tags = data.tags.slice();
606
- this.genre = data.genre;
607
- this.language = data.language;
608
- this.favoriteCount = data.favoriteCount;
609
- this.rating = data.rating;
610
- this.downloadUnavailable = data.downloadUnavailable;
611
- this.audioUnavailable = data.audioUnavailable;
612
- }
613
- beatmapsetURL() {
614
- return URLBuilder.beatmapsetURL(this.id);
615
- }
616
- coverImageURL() {
617
- return URLBuilder.beatmapCoverImage(this.id);
618
- }
619
- coverThumbnailURL() {
620
- return URLBuilder.beatmapCoverThumbnail(this.id);
621
- }
622
- async getCreator() {
623
- const candidates = await this.client.users.getUser({
624
- user: this.creatorId,
625
- type: "id" /* Id */
626
- });
627
- return candidates[0];
628
- }
591
+ constructor(client, data, maps) {
592
+ _defineProperty(this, "client", void 0);
593
+ _defineProperty(this, "beatmaps", void 0);
594
+ _defineProperty(this, "id", void 0);
595
+ _defineProperty(this, "approvedState", void 0);
596
+ _defineProperty(this, "length", void 0);
597
+ _defineProperty(this, "submitDate", void 0);
598
+ _defineProperty(this, "approvedDate", void 0);
599
+ _defineProperty(this, "lastUpdate", void 0);
600
+ _defineProperty(this, "artist", void 0);
601
+ _defineProperty(this, "title", void 0);
602
+ _defineProperty(this, "creator", void 0);
603
+ _defineProperty(this, "creatorId", void 0);
604
+ _defineProperty(this, "source", void 0);
605
+ _defineProperty(this, "tags", void 0);
606
+ _defineProperty(this, "genre", void 0);
607
+ _defineProperty(this, "language", void 0);
608
+ _defineProperty(this, "favoriteCount", void 0);
609
+ _defineProperty(this, "rating", void 0);
610
+ _defineProperty(this, "downloadUnavailable", void 0);
611
+ _defineProperty(this, "audioUnavailable", void 0);
612
+ this.client = client;
613
+ this.beatmaps = maps;
614
+ this.id = data.beatmapsetId;
615
+ this.approvedState = data.approvedState;
616
+ this.length = data.totalLength;
617
+ this.submitDate = data.submitDate;
618
+ this.approvedDate = data.approvedDate;
619
+ this.lastUpdate = data.lastUpdate;
620
+ this.artist = data.artist;
621
+ this.title = data.title;
622
+ this.creator = data.creator;
623
+ this.creatorId = data.creatorId;
624
+ this.source = data.source;
625
+ this.tags = data.tags.slice();
626
+ this.genre = data.genre;
627
+ this.language = data.language;
628
+ this.favoriteCount = data.favoriteCount;
629
+ this.rating = data.rating;
630
+ this.downloadUnavailable = data.downloadUnavailable;
631
+ this.audioUnavailable = data.audioUnavailable;
632
+ }
633
+ beatmapsetURL() {
634
+ return URLBuilder.beatmapsetURL(this.id);
635
+ }
636
+ coverImageURL() {
637
+ return URLBuilder.beatmapCoverImage(this.id);
638
+ }
639
+ coverThumbnailURL() {
640
+ return URLBuilder.beatmapCoverThumbnail(this.id);
641
+ }
642
+ async getCreator() {
643
+ return (await this.client.users.getUser({
644
+ user: this.creatorId,
645
+ type: "id"
646
+ }))[0];
647
+ }
629
648
  };
630
649
 
631
650
  // src/structures/Beatmap.ts
632
651
  var Beatmap = class {
633
- constructor(client, data) {
634
- this.client = client;
635
- this.id = data.beatmap_id;
636
- this.beatmapsetId = data.beatmapset_id;
637
- this.approvedState = +data.approved;
638
- this.totalLength = +data.total_length;
639
- this.hitLength = +data.hit_length;
640
- this.diffcultyName = data.version;
641
- this.hash = data.file_md5;
642
- this.difficulty = {
643
- ApproachRate: +data.diff_approach,
644
- CircleSize: +data.diff_size,
645
- OverallDifficulty: +data.diff_overall,
646
- HPDrainRate: +data.diff_drain,
647
- aim: +(data.diff_aim ?? 0),
648
- speed: +(data.diff_speed ?? 0),
649
- rating: +(data.difficultyrating ?? 0)
650
- };
651
- this.mode = +data.mode;
652
- this.objectCount = {
653
- circle: +data.count_normal,
654
- slider: +data.count_slider,
655
- spinner: +data.count_spinner
656
- };
657
- this.submitDate = new Date(data.submit_date);
658
- if (!data.approved_date) {
659
- this.approvedDate = null;
660
- } else {
661
- this.approvedDate = new Date(data.approved_date);
662
- }
663
- this.lastUpdate = new Date(data.last_update);
664
- this.artist = data.artist;
665
- this.title = data.title;
666
- this.creator = data.creator;
667
- this.creatorId = data.creator_id;
668
- this.bpm = +data.bpm;
669
- this.source = data.source;
670
- this.tags = data.tags.split(" ");
671
- this.genre = +data.genre_id;
672
- this.language = +data.language_id;
673
- this.favoriteCount = +data.favourite_count;
674
- this.rating = +data.rating;
675
- this.downloadUnavailable = !!+data.download_unavailable;
676
- this.audioUnavailable = !!+data.audio_unavailable;
677
- this.playcount = +data.playcount;
678
- this.passcount = +data.passcount;
679
- if (data.max_combo) {
680
- this.maxCombo = +data.max_combo;
681
- } else {
682
- this.maxCombo = null;
683
- }
684
- }
685
- beatmapsetURL() {
686
- return URLBuilder.beatmapsetURL(this.beatmapsetId);
687
- }
688
- beatmapURL() {
689
- return URLBuilder.beatmapURL(this.beatmapsetId, this.id, this.mode);
690
- }
691
- coverImageURL() {
692
- return URLBuilder.beatmapCoverImage(this.beatmapsetId);
693
- }
694
- coverThumbnailURL() {
695
- return URLBuilder.beatmapCoverThumbnail(this.beatmapsetId);
696
- }
697
- async getCreator() {
698
- const candidates = await this.client.users.getUser({
699
- user: this.creatorId,
700
- type: "id" /* Id */
701
- });
702
- return candidates[0];
703
- }
704
- async getBeatmapset() {
705
- const set = await this.client.beatmaps.getBeatmaps({
706
- beatmapsetId: this.beatmapsetId
707
- });
708
- return new Beatmapset(this.client, this, set);
709
- }
652
+ constructor(client, data) {
653
+ this.client = client;
654
+ _defineProperty(this, "id", void 0);
655
+ _defineProperty(this, "beatmapsetId", void 0);
656
+ _defineProperty(this, "approvedState", void 0);
657
+ _defineProperty(this, "totalLength", void 0);
658
+ _defineProperty(this, "hitLength", void 0);
659
+ _defineProperty(this, "diffcultyName", void 0);
660
+ _defineProperty(this, "hash", void 0);
661
+ _defineProperty(this, "difficulty", void 0);
662
+ _defineProperty(this, "mode", void 0);
663
+ _defineProperty(this, "objectCount", void 0);
664
+ _defineProperty(this, "submitDate", void 0);
665
+ _defineProperty(this, "approvedDate", void 0);
666
+ _defineProperty(this, "lastUpdate", void 0);
667
+ _defineProperty(this, "artist", void 0);
668
+ _defineProperty(this, "title", void 0);
669
+ _defineProperty(this, "creator", void 0);
670
+ _defineProperty(this, "creatorId", void 0);
671
+ _defineProperty(this, "bpm", void 0);
672
+ _defineProperty(this, "source", void 0);
673
+ _defineProperty(this, "tags", void 0);
674
+ _defineProperty(this, "genre", void 0);
675
+ _defineProperty(this, "language", void 0);
676
+ _defineProperty(this, "favoriteCount", void 0);
677
+ _defineProperty(this, "rating", void 0);
678
+ _defineProperty(this, "downloadUnavailable", void 0);
679
+ _defineProperty(this, "audioUnavailable", void 0);
680
+ _defineProperty(this, "playcount", void 0);
681
+ _defineProperty(this, "passcount", void 0);
682
+ _defineProperty(this, "maxCombo", void 0);
683
+ this.id = data.beatmap_id;
684
+ this.beatmapsetId = data.beatmapset_id;
685
+ this.approvedState = +data.approved;
686
+ this.totalLength = +data.total_length;
687
+ this.hitLength = +data.hit_length;
688
+ this.diffcultyName = data.version;
689
+ this.hash = data.file_md5;
690
+ this.difficulty = {
691
+ ApproachRate: +data.diff_approach,
692
+ CircleSize: +data.diff_size,
693
+ OverallDifficulty: +data.diff_overall,
694
+ HPDrainRate: +data.diff_drain,
695
+ aim: +(data.diff_aim ?? 0),
696
+ speed: +(data.diff_speed ?? 0),
697
+ rating: +(data.difficultyrating ?? 0)
698
+ };
699
+ this.mode = +data.mode;
700
+ this.objectCount = {
701
+ circle: +data.count_normal,
702
+ slider: +data.count_slider,
703
+ spinner: +data.count_spinner
704
+ };
705
+ this.submitDate = new Date(data.submit_date);
706
+ if (!data.approved_date) this.approvedDate = null;
707
+ else this.approvedDate = new Date(data.approved_date);
708
+ this.lastUpdate = new Date(data.last_update);
709
+ this.artist = data.artist;
710
+ this.title = data.title;
711
+ this.creator = data.creator;
712
+ this.creatorId = data.creator_id;
713
+ this.bpm = +data.bpm;
714
+ this.source = data.source;
715
+ this.tags = data.tags.split(" ");
716
+ this.genre = +data.genre_id;
717
+ this.language = +data.language_id;
718
+ this.favoriteCount = +data.favourite_count;
719
+ this.rating = +data.rating;
720
+ this.downloadUnavailable = !!+data.download_unavailable;
721
+ this.audioUnavailable = !!+data.audio_unavailable;
722
+ this.playcount = +data.playcount;
723
+ this.passcount = +data.passcount;
724
+ if (data.max_combo) this.maxCombo = +data.max_combo;
725
+ else this.maxCombo = null;
726
+ }
727
+ beatmapsetURL() {
728
+ return URLBuilder.beatmapsetURL(this.beatmapsetId);
729
+ }
730
+ beatmapURL() {
731
+ return URLBuilder.beatmapURL(this.beatmapsetId, this.id, this.mode);
732
+ }
733
+ coverImageURL() {
734
+ return URLBuilder.beatmapCoverImage(this.beatmapsetId);
735
+ }
736
+ coverThumbnailURL() {
737
+ return URLBuilder.beatmapCoverThumbnail(this.beatmapsetId);
738
+ }
739
+ async getCreator() {
740
+ return (await this.client.users.getUser({
741
+ user: this.creatorId,
742
+ type: "id"
743
+ }))[0];
744
+ }
745
+ async getBeatmapset() {
746
+ const set = await this.client.beatmaps.getBeatmaps({ beatmapsetId: this.beatmapsetId });
747
+ return new Beatmapset(this.client, this, set);
748
+ }
710
749
  };
711
750
 
712
751
  // src/managers/BeatmapManager.ts
713
752
  var BeatmapManager = class extends BaseManager {
714
- async getBeatmaps(options = {}) {
715
- const queries = {
716
- since: options.since && toSqlDate(options.since),
717
- s: options.beatmapsetId,
718
- b: options.beatmapId,
719
- u: options.user,
720
- type: options.type,
721
- m: options.mode,
722
- a: options.showConverted,
723
- h: options.hash,
724
- limit: options.limit,
725
- mods: ModsBitField.resolve(options.mods ?? 0)
726
- };
727
- const res = await this.client.request({
728
- path: "get_beatmaps",
729
- queries
730
- });
731
- return res.map((v) => new Beatmap(this.client, v));
732
- }
753
+ async getBeatmaps(options = {}) {
754
+ const queries = omitUndefined({
755
+ since: options.since && toSqlDate(options.since),
756
+ s: options.beatmapsetId,
757
+ b: options.beatmapId,
758
+ u: options.user,
759
+ type: options.type,
760
+ m: options.mode,
761
+ a: options.showConverted,
762
+ h: options.hash,
763
+ limit: options.limit,
764
+ mods: ModsBitField.resolve(options.mods ?? 0)
765
+ });
766
+ return (await this.client.request({
767
+ path: "get_beatmaps",
768
+ queries
769
+ })).map((v) => new Beatmap(this.client, v));
770
+ }
733
771
  };
734
772
 
735
773
  // src/managers/ScoreManager.ts
736
774
  var ScoreManager = class extends BaseManager {
737
- async getScores(options) {
738
- const mods = options.mods == void 0 ? void 0 : ModsBitField.resolve(options.mods);
739
- const queries = {
740
- b: options.beatmapId,
741
- u: options.user,
742
- m: options.mode,
743
- mods,
744
- type: options.type,
745
- limit: options.limit
746
- };
747
- const res = await this.client.request({
748
- path: "get_scores",
749
- queries
750
- });
751
- return res.map((v) => new BeatmapScore(this.client, v, { mapId: options.beatmapId, mode: options.mode }));
752
- }
775
+ async getScores(options) {
776
+ const mods = options.mods == void 0 ? void 0 : ModsBitField.resolve(options.mods);
777
+ const queries = omitUndefined({
778
+ b: options.beatmapId,
779
+ u: options.user,
780
+ m: options.mode,
781
+ mods,
782
+ type: options.type,
783
+ limit: options.limit
784
+ });
785
+ return (await this.client.request({
786
+ path: "get_scores",
787
+ queries
788
+ })).map((v) => new BeatmapScore(this.client, v, omitUndefined({
789
+ mapId: options.beatmapId,
790
+ mode: options.mode
791
+ })));
792
+ }
753
793
  };
754
794
 
755
795
  // src/structures/Replay.ts
756
- import { Buffer } from "node:buffer";
757
796
  var Replay = class {
758
- constructor(client, data) {
759
- this.client = client;
760
- this.content = data.content;
761
- this.stream = Buffer.from(this.content, "base64");
762
- }
797
+ constructor(client, data) {
798
+ _defineProperty(this, "client", void 0);
799
+ _defineProperty(this, "content", void 0);
800
+ _defineProperty(this, "stream", void 0);
801
+ this.client = client;
802
+ this.content = data.content;
803
+ this.stream = Buffer.from(this.content, "base64");
804
+ }
763
805
  };
764
806
 
765
807
  // src/managers/ReplayManager.ts
766
808
  var ReplayManager = class extends BaseManager {
767
- async getReplay(options) {
768
- if ((!options.beatmapId || !options.user) && !options.scoreId) {
769
- throw new Error("You should provide either beatmapId and user or scordId to get replay");
770
- }
771
- const mods = options.mods == void 0 ? void 0 : ModsBitField.resolve(options.mods);
772
- const queries = {
773
- b: options.beatmapId,
774
- u: options.user,
775
- m: options.mode,
776
- s: options.scoreId,
777
- type: options.type,
778
- mods
779
- };
780
- const res = await this.client.request({
781
- path: "get_replay",
782
- queries
783
- });
784
- return new Replay(this.client, res);
785
- }
809
+ async getReplay(options) {
810
+ if ((!options.beatmapId || !options.user) && !options.scoreId) throw new Error("You should provide either beatmapId and user or scordId to get replay");
811
+ const mods = options.mods == void 0 ? void 0 : ModsBitField.resolve(options.mods);
812
+ const queries = omitUndefined({
813
+ b: options.beatmapId,
814
+ u: options.user,
815
+ m: options.mode,
816
+ s: options.scoreId,
817
+ type: options.type,
818
+ mods
819
+ });
820
+ const res = await this.client.request({
821
+ path: "get_replay",
822
+ queries
823
+ });
824
+ return new Replay(this.client, res);
825
+ }
786
826
  };
787
827
 
788
828
  // src/structures/MatchScore.ts
789
829
  var MatchScore = class extends BaseScore {
790
- constructor(client, data, other) {
791
- super(client, data, other);
792
- this.slot = +data.slot;
793
- this.team = +data.team;
794
- this.pass = !!+data.pass;
795
- }
830
+ constructor(client, data, other) {
831
+ super(client, data, other);
832
+ _defineProperty(this, "slot", void 0);
833
+ _defineProperty(this, "team", void 0);
834
+ _defineProperty(this, "pass", void 0);
835
+ this.slot = +data.slot;
836
+ this.team = +data.team;
837
+ this.pass = !!+data.pass;
838
+ }
796
839
  };
797
840
 
798
841
  // src/structures/MatchGame.ts
799
842
  var MatchGame = class {
800
- constructor(match, data) {
801
- this.client = match.client;
802
- this.match = match;
803
- this.id = data.game_id;
804
- this.startAt = new Date(data.start_time);
805
- this.endAt = new Date(data.end_time);
806
- this.beatmapId = data.beatmap_id;
807
- this.mode = +data.play_mode;
808
- this.matchType = +data.match_type;
809
- this.scoringType = +data.scoring_type;
810
- this.teamType = +data.team_type;
811
- this.mods = new ModsBitField(data.mods);
812
- this.scores = data.scores.map((score) => new MatchScore(this.client, score, {
813
- mode: +data.play_mode,
814
- mapId: data.beatmap_id
815
- }));
816
- }
817
- async getBeatmap() {
818
- const candidates = await this.client.beatmaps.getBeatmaps({
819
- beatmapId: this.beatmapId
820
- });
821
- return candidates[0];
822
- }
843
+ constructor(match, data) {
844
+ _defineProperty(this, "client", void 0);
845
+ _defineProperty(this, "match", void 0);
846
+ _defineProperty(this, "id", void 0);
847
+ _defineProperty(this, "startAt", void 0);
848
+ _defineProperty(this, "endAt", void 0);
849
+ _defineProperty(this, "beatmapId", void 0);
850
+ _defineProperty(this, "mode", void 0);
851
+ _defineProperty(this, "matchType", void 0);
852
+ _defineProperty(this, "scoringType", void 0);
853
+ _defineProperty(this, "teamType", void 0);
854
+ _defineProperty(this, "mods", void 0);
855
+ _defineProperty(this, "scores", void 0);
856
+ this.client = match.client;
857
+ this.match = match;
858
+ this.id = data.game_id;
859
+ this.startAt = new Date(data.start_time);
860
+ this.endAt = new Date(data.end_time);
861
+ this.beatmapId = data.beatmap_id;
862
+ this.mode = +data.play_mode;
863
+ this.matchType = +data.match_type;
864
+ this.scoringType = +data.scoring_type;
865
+ this.teamType = +data.team_type;
866
+ this.mods = new ModsBitField(data.mods);
867
+ this.scores = data.scores.map((score) => new MatchScore(this.client, score, {
868
+ mode: +data.play_mode,
869
+ mapId: data.beatmap_id
870
+ }));
871
+ }
872
+ async getBeatmap() {
873
+ return (await this.client.beatmaps.getBeatmaps({ beatmapId: this.beatmapId }))[0];
874
+ }
823
875
  };
824
876
 
825
877
  // src/structures/Match.ts
826
878
  var Match = class {
827
- constructor(client, data) {
828
- this.client = client;
829
- const { match, games } = data;
830
- this.id = match.match_id;
831
- this.name = match.name;
832
- this.startAt = new Date(match.start_time);
833
- if (match.end_time) {
834
- this.endAt = new Date(match.end_time);
835
- } else {
836
- this.endAt = null;
837
- }
838
- this.games = games.map((data2) => new MatchGame(this, data2));
839
- }
879
+ constructor(client, data) {
880
+ _defineProperty(this, "client", void 0);
881
+ _defineProperty(this, "id", void 0);
882
+ _defineProperty(this, "name", void 0);
883
+ _defineProperty(this, "startAt", void 0);
884
+ _defineProperty(this, "endAt", void 0);
885
+ _defineProperty(this, "games", void 0);
886
+ this.client = client;
887
+ const { match, games } = data;
888
+ this.id = match.match_id;
889
+ this.name = match.name;
890
+ this.startAt = new Date(match.start_time);
891
+ if (match.end_time) this.endAt = new Date(match.end_time);
892
+ else this.endAt = null;
893
+ this.games = games.map((data) => new MatchGame(this, data));
894
+ }
840
895
  };
841
896
 
842
897
  // src/managers/MatchManager.ts
843
898
  var MatchManager = class extends BaseManager {
844
- async getMatch(options) {
845
- const queries = {
846
- mp: options.matchId
847
- };
848
- const res = await this.client.request({
849
- path: "get_match",
850
- queries
851
- });
852
- if (res.match === 0) {
853
- return null;
854
- }
855
- return new Match(this.client, res);
856
- }
899
+ async getMatch(options) {
900
+ const queries = { mp: options.matchId };
901
+ const res = await this.client.request({
902
+ path: "get_match",
903
+ queries
904
+ });
905
+ if (res.match === 0) return null;
906
+ return new Match(this.client, res);
907
+ }
857
908
  };
858
909
 
859
910
  // src/Client.ts
860
911
  var Client = class {
861
- constructor(options) {
862
- this.apiKey = options.apiKey;
863
- this.users = new UserManager(this);
864
- this.beatmaps = new BeatmapManager(this);
865
- this.scores = new ScoreManager(this);
866
- this.replays = new ReplayManager(this);
867
- this.matches = new MatchManager(this);
868
- }
869
- async request(options) {
870
- if (!options?.path)
871
- throw new Error("MISSING_PATH");
872
- const response = await request2.get(`https://osu.ppy.sh/api/${options.path}`).query({ k: this.apiKey }).query(options.queries);
873
- return response.body;
874
- }
875
- };
876
- export {
877
- AccuracyCalculator,
878
- BaseManager,
879
- BaseScore,
880
- Beatmap,
881
- BeatmapApprovedState,
882
- BeatmapGenre,
883
- BeatmapLanguage,
884
- BeatmapManager,
885
- BeatmapScore,
886
- Beatmapset,
887
- Client,
888
- GameMode,
889
- Match,
890
- MatchGame,
891
- MatchManager,
892
- MatchScore,
893
- MatchScoringType,
894
- MatchTeamType,
895
- Mods,
896
- ModsAbbreviation,
897
- ModsBitField,
898
- Replay,
899
- ReplayManager,
900
- ScoreManager,
901
- ScoreRank,
902
- Team,
903
- URLBuilder,
904
- User,
905
- UserEvent,
906
- UserManager,
907
- UserRequestType
912
+ constructor(options) {
913
+ _defineProperty(this, "apiKey", void 0);
914
+ _defineProperty(this, "users", void 0);
915
+ _defineProperty(this, "beatmaps", void 0);
916
+ _defineProperty(this, "scores", void 0);
917
+ _defineProperty(this, "replays", void 0);
918
+ _defineProperty(this, "matches", void 0);
919
+ this.apiKey = options.apiKey;
920
+ this.users = new UserManager(this);
921
+ this.beatmaps = new BeatmapManager(this);
922
+ this.scores = new ScoreManager(this);
923
+ this.replays = new ReplayManager(this);
924
+ this.matches = new MatchManager(this);
925
+ }
926
+ async request(options) {
927
+ if (!options?.path) throw new Error("MISSING_PATH");
928
+ return (await request.get(`https://osu.ppy.sh/api/${options.path}`).query({ k: this.apiKey }).query(options.queries)).body;
929
+ }
908
930
  };
931
+
932
+ export { AccuracyCalculator, BaseManager, BaseScore, Beatmap, BeatmapApprovedState, BeatmapGenre, BeatmapLanguage, BeatmapManager, BeatmapScore, Beatmapset, Client, GameMode, Match, MatchGame, MatchManager, MatchScore, MatchScoringType, MatchTeamType, Mods, ModsAbbreviation, ModsBitField, Replay, ReplayManager, ScoreManager, ScoreRank, Team, URLBuilder, User, UserEvent, UserManager, UserRequestType };
909
933
  //# sourceMappingURL=index.mjs.map