Skip to content

Commit 8ffcc6e

Browse files
⬆ update dependencies (#933)
1 parent f8a5c76 commit 8ffcc6e

File tree

10 files changed

+5005
-5601
lines changed

10 files changed

+5005
-5601
lines changed

package.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"node": "16.15.0"
99
},
1010
"scripts": {
11-
"dev": "TS_NODE_FILES=true TS_NODE_PROJECT=\"./tsconfig.json\" nodemon -r dotenv/config -x node --experimental-specifier-resolution=node --loader ts-node/esm ./src/index.ts",
11+
"dev": "cross-env TS_NODE_FILES=true TS_NODE_PROJECT=\"./tsconfig.json\" nodemon -r dotenv/config -x node --experimental-specifier-resolution=node --loader ts-node/esm ./src/index.ts",
1212
"start": "node build/index.js",
1313
"build": "tsc",
1414
"lint": "eslint src && tsc --noEmit",
@@ -23,40 +23,41 @@
2323
"author": "",
2424
"license": "ISC",
2525
"dependencies": {
26-
"@mdn/browser-compat-data": "4.2.1",
27-
"@sentry/node": "6.19.7",
26+
"@mdn/browser-compat-data": "5.0.1",
27+
"@sentry/node": "7.0.0",
2828
"compare-versions": "4.1.3",
29+
"cross-env": "^7.0.3",
2930
"date-fns": "2.28.0",
30-
"discord.js": "13.6.0",
31+
"discord.js": "13.7.0",
3132
"dom-parser": "0.1.6",
3233
"domyno": "1.0.1",
3334
"fuse.js": "6.6.2",
3435
"html-entities": "2.3.3",
3536
"lodash-es": "4.17.21",
36-
"mongoose": "6.3.4",
37+
"mongoose": "6.3.5",
3738
"node-cache": "5.1.2",
38-
"node-fetch": "3.2.4",
39+
"node-fetch": "3.2.5",
3940
"node-html-parser": "5.3.3",
40-
"ts-node": "10.7.0",
41+
"ts-node": "10.8.0",
4142
"typescript": "4.7.2"
4243
},
4344
"devDependencies": {
44-
"@sentry/types": "6.19.7",
45+
"@sentry/types": "7.0.0",
4546
"@types/dom-parser": "0.1.1",
4647
"@types/html-entities": "1.3.4",
47-
"@types/jest": "27.5.1",
48+
"@types/jest": "28.1.0",
4849
"@types/mongoose": "5.11.97",
49-
"@types/node": "16.11.36",
50+
"@types/node": "17.0.39",
5051
"@types/node-fetch": "3.0.3",
5152
"dotenv": "16.0.1",
5253
"eslint": "8.16.0",
53-
"eslint-config-galex": "3.6.5",
54+
"eslint-config-galex": "4.1.3",
5455
"husky": "8.0.1",
55-
"jest": "27.5.1",
56-
"lint-staged": "12.4.1",
56+
"jest": "28.1.0",
57+
"lint-staged": "13.0.0",
5758
"nodemon": "2.0.16",
5859
"prettier": "2.6.2",
59-
"ts-jest": "27.1.5"
60+
"ts-jest": "28.0.4"
6061
},
6162
"husky": {
6263
"hooks": {

src/v2/commands/about/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import type {
2-
ApplicationCommandOptionChoice,
2+
ApplicationCommandOptionChoiceData,
33
Client,
44
CommandInteraction,
5-
Interaction,
65
} from 'discord.js';
76

87
import type { CommandDataWithHandler } from '../../../types';
@@ -22,7 +21,7 @@ const aboutMessages = new Map<string, ValueOrNullary<string>>([
2221
]);
2322

2423
const mapTransformToChoices = map(
25-
(item: string): ApplicationCommandOptionChoice => ({
24+
(item: string): ApplicationCommandOptionChoiceData => ({
2625
name: item,
2726
value: item,
2827
})

src/v2/commands/please/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ApplicationCommandOptionChoice, Client, CommandInteraction } from 'discord.js';
1+
import type { ApplicationCommandOptionChoiceData, Client, CommandInteraction } from 'discord.js';
22

33
import type { CommandDataWithHandler } from '../../../types';
44
import { map } from '../../utils/map.js';
@@ -13,7 +13,7 @@ import { justAsk } from './handlers/justask.js';
1313
const pleaseMessages = new Map<string, ValueOrNullary<string>>([format, code, justAsk, english]);
1414

1515
const mapTransformToChoices = map(
16-
(item: string): ApplicationCommandOptionChoice => ({
16+
(item: string): ApplicationCommandOptionChoiceData => ({
1717
name: item,
1818
value: item,
1919
})

src/v2/commands/resource/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ApplicationCommandOptionChoice, Client, CommandInteraction } from 'discord.js';
1+
import type { ApplicationCommandOptionChoiceData, Client, CommandInteraction } from 'discord.js';
22

33
import { ApplicationCommandOptionType } from '../../../enums.js';
44
import type { CommandDataWithHandler } from '../../../types';
@@ -12,7 +12,7 @@ const resourceMessages = new Map<string, ValueOrNullary<{ content: string }>>([
1212
]);
1313

1414
const mapTransformToChoices = map(
15-
(item: string): ApplicationCommandOptionChoice => ({
15+
(item: string): ApplicationCommandOptionChoiceData => ({
1616
name: item,
1717
value: item,
1818
})

src/v2/commands/shitpost/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ApplicationCommandOptionChoice } from 'discord.js';
1+
import type { ApplicationCommandOptionChoiceData } from 'discord.js';
22

33
import type { CommandDataWithHandler } from '../../../types';
44
import { ADMIN_ROLE_ID, HELPFUL_ROLE_ID, MOD_ROLE_ID, SERVER_ID } from '../../env.js';
@@ -35,7 +35,7 @@ const shitpostReplacements = {
3535
};
3636

3737
const mapTransformToChoices = map(
38-
(item: string): ApplicationCommandOptionChoice => ({
38+
(item: string): ApplicationCommandOptionChoiceData => ({
3939
name: item,
4040
value: item,
4141
})

src/v2/commands/warn/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {
2-
ApplicationCommandOptionChoice,
2+
ApplicationCommandOptionChoiceData,
33
Client,
44
CommandInteraction,
55
} from 'discord.js';

src/v2/commands/whyno/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ApplicationCommandOptionChoice, Client, CommandInteraction } from 'discord.js';
1+
import type { ApplicationCommandOptionChoiceData, Client, CommandInteraction } from 'discord.js';
22

33
import type { CommandDataWithHandler } from '../../../types';
44
import { map } from '../../utils/map.js';
@@ -13,7 +13,7 @@ const whynoMessages = new Map<string, ValueOrNullary<string>>([
1313
]);
1414

1515
const mapTransformToChoices = map(
16-
(item: string): ApplicationCommandOptionChoice => ({
16+
(item: string): ApplicationCommandOptionChoiceData => ({
1717
name: item,
1818
value: item,
1919
})

src/v2/utils/Cache.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addBreadcrumb, Severity } from '@sentry/node';
1+
import { addBreadcrumb } from '@sentry/node';
22
import { EventEmitter } from 'events';
33

44
import { castArray } from './castArray.js';
@@ -136,14 +136,14 @@ const DEFAULT_OPTIONS: CacheOptions = {
136136
* @template Value
137137
* @template Key
138138
*/
139-
export class Cache<Value = any, Key = any> extends EventEmitter {
139+
export class Cache<Value = unknown, Key = unknown> extends EventEmitter {
140140
#data: Map<Key, WrappedValue<Value>>;
141141

142-
options: CacheOptions;
142+
public options: CacheOptions;
143143

144-
checkTimeout: NodeJS.Timeout;
144+
public checkTimeout: NodeJS.Timeout;
145145

146-
constructor(options: CacheOptions) {
146+
public constructor(options: CacheOptions) {
147147
super();
148148
this.options = {
149149
...DEFAULT_OPTIONS,
@@ -160,11 +160,11 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
160160
* @param key cache key
161161
* @returns The value stored in the key
162162
*/
163-
get<T extends Value = Value>(key: Key): T | undefined {
163+
public get<T extends Value = Value>(key: Key): T | undefined {
164164
const data = this.#data.get(key);
165165

166166
addBreadcrumb({
167-
level: Severity.Debug,
167+
level: 'debug',
168168
message: `Cache [Get]: ${String(key)}`,
169169
});
170170

@@ -180,11 +180,11 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
180180
* @param keys an array of keys
181181
* @returns an object containing the values stored in the matching keys
182182
*/
183-
mget<T extends Value = Value>(keys: Key[]): Map<Key, T> {
183+
public mget<T extends Value = Value>(keys: Key[]): Map<Key, T> {
184184
const output: Map<Key, T> = new Map();
185185

186186
addBreadcrumb({
187-
level: Severity.Debug,
187+
level: 'debug',
188188
message: `Cache [MGet]: keys: ${keys.slice(0, 10)} (${
189189
keys.length
190190
} items)`,
@@ -209,11 +209,11 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
209209
* it to a serialized JSON
210210
* @param ttl The time to live in seconds.
211211
*/
212-
set<T extends Value = Value>(key: Key, value: T, ttl?: number): boolean {
212+
public set<T extends Value = Value>(key: Key, value: T, ttl?: number): boolean {
213213
const usedTtl = ttl ?? this.options.stdTTL;
214214

215215
addBreadcrumb({
216-
level: Severity.Debug,
216+
level: 'debug',
217217
message: `Cache [Set]: ${String(key)}: ${String(
218218
value
219219
)} | TTL: ${ttl}/${usedTtl}`,
@@ -231,10 +231,10 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
231231
*
232232
* @param keyValueSet an array of object which includes key,value and ttl
233233
*/
234-
mset<T extends Value = Value>(keyValueSet: ValueSetItem<Key, T>[]): boolean {
234+
public mset<T extends Value = Value>(keyValueSet: ValueSetItem<Key, T>[]): boolean {
235235
const len = keyValueSet.length;
236236
addBreadcrumb({
237-
level: Severity.Debug,
237+
level: 'debug',
238238
message: `Cache [MSet]: ${keyValueSet.length} Items`,
239239
});
240240
for (let i = 0; i < len; i++) {
@@ -250,13 +250,13 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
250250
* @param cb Callback function
251251
* @returns Number of deleted keys
252252
*/
253-
del(keys: Key | Key[]): number {
253+
public del(keys: Key | Key[]): number {
254254
let deleted = 0;
255255
const keyArr = castArray(keys);
256256
const data = this.#data;
257257

258258
addBreadcrumb({
259-
level: Severity.Debug,
259+
level: 'debug',
260260
message: `Cache [Del]: ${String(keyArr.slice(0, 10))} (${
261261
keyArr.length
262262
} items)`,
@@ -282,7 +282,7 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
282282
* @param key cache key
283283
* @returns The value stored in the key
284284
*/
285-
take<T extends Value = Value>(key: Key): T | undefined {
285+
public take<T extends Value = Value>(key: Key): T | undefined {
286286
const output = this.get(key);
287287

288288
if (this.#data.has(key)) {
@@ -295,7 +295,7 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
295295
/**
296296
* reset or redefine the ttl of a key. If `ttl` is not passed or set to 0 it's similar to `.del()`
297297
*/
298-
ttl(key: Key, ttl: number = this.options.stdTTL): boolean {
298+
public ttl(key: Key, ttl: number = this.options.stdTTL): boolean {
299299
if (!key) {
300300
return false;
301301
}
@@ -308,29 +308,29 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
308308
this.del(key);
309309
}
310310
return true;
311-
}
311+
}
312312
return false;
313-
313+
314314
}
315315

316-
getTtl(key: Key): number | undefined {
316+
public getTtl(key: Key): number | undefined {
317317
if (!key) {
318318
return void 0;
319319
}
320320

321321
const value = this.#data.get(key);
322322
if (this.#data.has(key) && this._check(key, value)) {
323323
return value.t;
324-
}
324+
}
325325
return void 0;
326-
326+
327327
}
328328

329329
/**
330330
* list all keys within this cache
331331
* @returns An array of all keys
332332
*/
333-
keys(): IterableIterator<Key> {
333+
public keys(): IterableIterator<Key> {
334334
return this.#data.keys();
335335
}
336336

@@ -348,14 +348,14 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
348348
* @param key cache key to check
349349
* @returns Boolean indicating if the key is cached or not
350350
*/
351-
has(key: Key): boolean {
351+
public has(key: Key): boolean {
352352
return this.has(key) && this._check(key, this.#data.get(key));
353353
}
354354

355355
/**
356356
* flush the whole data and reset the stats
357357
*/
358-
flushAll(_startPeriod = true): void {
358+
public flushAll(_startPeriod = true): void {
359359
this.#data.clear();
360360
this._killCheckPeriod();
361361
this._checkData(_startPeriod);
@@ -365,14 +365,14 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
365365
/**
366366
* This will clear the interval timeout which is set on checkperiod option.
367367
*/
368-
close(): void {
368+
public close(): void {
369369
this._killCheckPeriod();
370370
}
371371

372372
/**
373373
* flush the stats and reset all counters to 0
374374
*/
375-
flushStats(): void {}
375+
public flushStats(): void {}
376376

377377
private _check(key: Key, data) {
378378
let ret = true;
@@ -390,7 +390,7 @@ export class Cache<Value = any, Key = any> extends EventEmitter {
390390
if (this.checkTimeout != null) {
391391
const {checkTimeout} = this;
392392
this.checkTimeout = null;
393-
clearTimeout(checkTimeout);
393+
clearTimeout(checkTimeout);
394394
}
395395
}
396396

src/v2/utils/useData.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { addBreadcrumb, Severity } from '@sentry/node';
1+
import { addBreadcrumb } from '@sentry/node';
22
import type {
33
HeadersInit,
44
RequestInfo,
@@ -57,19 +57,19 @@ type FetchWithFormat<Format> = (
5757
const doFetch: <TParsedResponse>(
5858
cacheKey: string,
5959
mapper: ResponseMapper<TParsedResponse>
60-
) => FetchWithFormat<TParsedResponse> = <TParsedResponse>(cacheKey, mapper) => {
60+
) => FetchWithFormat<TParsedResponse> = <TParsedResponse>(cacheKey, mapper):FetchWithFormat<TParsedResponse> => {
6161
const casedCacheKey = cacheKey.toLowerCase();
62-
const cachedResponse = apiCache.get<TParsedResponse>(casedCacheKey);
62+
const cachedResponse = apiCache.get(casedCacheKey);
6363

6464
if (cachedResponse) {
65-
return () => cachedResponse;
65+
return (async () => cachedResponse) as FetchWithFormat<TParsedResponse>;
6666
}
6767

6868
return async (url, fetchOptions) => {
6969
addBreadcrumb({
7070
category: 'query',
7171
data: typeof url === 'string' ? { url } : undefined,
72-
level: Severity.Info,
72+
level: 'info',
7373
timestamp: Date.now(),
7474
});
7575

@@ -81,7 +81,7 @@ const doFetch: <TParsedResponse>(
8181
console.timeEnd(timeLabel);
8282
const formattedResponse = await mapper(response);
8383
apiCache.set(casedCacheKey, formattedResponse);
84-
return formattedResponse;
84+
return formattedResponse as TParsedResponse;
8585
};
8686
};
8787

0 commit comments

Comments
 (0)