Skip to content

Commit 89570a8

Browse files
committed
refactor: Move all 'tools' to their own util files
1 parent 88ed077 commit 89570a8

45 files changed

Lines changed: 55 additions & 53 deletions

Some content is hidden

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

src/cache/ugo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { uploadToPastie } from 'ps-client/tools';
44
import { usePersistedCache } from '@/cache/persisted';
55
import { TimeZone } from '@/ps/handlers/cron/constants';
66
import { BG_STRUCHNI_MODIFIER, BOARD_GAMES_STRUCHNI_ORDER, UGO_2025_SPOTLIGHTS } from '@/ps/ugo/constants';
7-
import { toId } from '@/tools';
87
import { Logger } from '@/utils/logger';
98
import { mapValues } from '@/utils/map';
9+
import { toId } from '@/utils/toId';
1010

1111
import type { UGOBoardGames } from '@/ps/ugo/constants';
1212
import type { Client } from 'ps-client';

src/config/ps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { toId } from '@/tools';
1+
import { toId } from '@/utils/toId';
22

33
export const ranks = ['locked', 'muted', 'regular', 'whitelist', 'voice', 'driver', 'mod', 'bot', 'owner', 'admin'] as const;
44

src/database/alts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import mongoose from 'mongoose';
22

33
import { IS_ENABLED } from '@/enabled';
4-
import { toId } from '@/tools';
4+
import { toId } from '@/utils/toId';
55

66
interface Model {
77
id: string;

src/database/games.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { IS_ENABLED } from '@/enabled';
66
import { ScrabbleMods } from '@/ps/games/scrabble/constants';
77
import { GamesList } from '@/ps/games/types';
88
import { UGO_2025_END, UGO_2025_START } from '@/ps/ugo/constants';
9-
import { toId } from '@/tools';
109
import { instantInRange } from '@/utils/timeInRange';
10+
import { toId } from '@/utils/toId';
1111

1212
import type { Log as ScrabbleLog } from '@/ps/games/scrabble/logs';
1313
import type { WinCtx as ScrabbleWinCtx } from '@/ps/games/scrabble/types';

src/database/points.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import mongoose from 'mongoose';
22

33
import { PSRoomConfigs } from '@/cache';
44
import { IS_ENABLED } from '@/enabled';
5-
import { toId } from '@/tools';
5+
import { toId } from '@/utils/toId';
66

77
export type Model = { id: string; userId: string; name: string; roomId: string; points: Record<string, number> };
88
type MapModel = Omit<Model, 'points'> & { points: Map<string, number> };

src/database/psrooms.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import mongoose from 'mongoose';
22

33
import { PSRoomConfigs } from '@/cache';
44
import { IS_ENABLED } from '@/enabled';
5-
import { toId } from '@/tools';
65
import { Logger } from '@/utils/logger';
6+
import { toId } from '@/utils/toId';
77

88
import type { AuthKey, PSRoomConfig } from '@/types/ps';
99

src/database/quotes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import mongoose from 'mongoose';
22

33
import { IS_ENABLED } from '@/enabled';
4-
import { toId } from '@/tools';
4+
import { toId } from '@/utils/toId';
55

66
const schema = new mongoose.Schema({
77
quote: {

src/database/seens.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import mongoose from 'mongoose';
22

33
import { IS_ENABLED } from '@/enabled';
4-
import { toId } from '@/tools';
4+
import { toId } from '@/utils/toId';
55

66
// We don't really care about storing joins (since we can just use their 'online' status)
77
// Instead, we store the last time they were seen online; i.e. their leave time, not join

src/discord/commands/parselb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { PSRoomConfigs } from '@/cache';
22
import { bulkAddPoints } from '@/database/points';
33
import { SERVER_ID } from '@/discord/constants/servers/hindi';
44
import getSecretFunction from '@/secrets/functions';
5-
import { toId } from '@/tools';
65
import { ChatError } from '@/utils/chatError';
6+
import { toId } from '@/utils/toId';
77

88
import type { NoTranslate } from '@/i18n/types';
99
import type { DiscordCommand } from '@/types/chat';

src/eval.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { inspect } from 'util';
66

77
import * as _cache from '@/cache';
88
import _Sentinel from '@/sentinel';
9-
import * as _Tools from '@/tools';
109
import { ansiToHtml } from '@/utils/ansiToHtml';
1110
import { cachebust as _cachebust } from '@/utils/cachebust';
1211
import { $ as _$ } from '@/utils/child_process';
1312
import { fsPath as _fsPath } from '@/utils/fsPath';
1413
import { jsxToHTML as _jsxToHTML } from '@/utils/jsxToHTML';
1514
import { Logger } from '@/utils/logger';
1615
import { paste as _paste } from '@/utils/paste';
16+
import { toId as _toId } from '@/utils/toId';
1717

1818
import type { PSCommandContext } from '@/types/chat';
1919
import type { PSMessage } from '@/types/ps';
@@ -26,7 +26,7 @@ const fs = _fs;
2626
const fsSync = _fsSync;
2727
const fsPath = _fsPath;
2828
const path = _path;
29-
const Tools = _Tools;
29+
const toId = _toId;
3030
const $ = _$;
3131
const Sentinel = _Sentinel;
3232
const jsxToHTML = _jsxToHTML;
@@ -36,7 +36,7 @@ const paste = _paste;
3636
const E: Record<string, unknown> = {};
3737

3838
// Storing in context for eval()
39-
const _evalContext = [cache, cachebust, fs, fsSync, fsPath, path, Tools, $, Sentinel, E, jsxToHTML, paste];
39+
const _evalContext = [cache, cachebust, fs, fsSync, fsPath, path, toId, $, Sentinel, E, jsxToHTML, paste];
4040

4141
export type EvalModes = 'COLOR_OUTPUT_HTML' | 'COLOR_OUTPUT_ANSI' | 'FULL_OUTPUT' | 'ABBR_OUTPUT' | 'NO_OUTPUT';
4242
export type EvalOutput = {

0 commit comments

Comments
 (0)