refactor: switch to .ts imports for some HidenCloud requirements#21
Conversation
Summary by BeetleThis PR refactors the entire codebase to use 📁 File Changes Summary (Consolidated across all commits):
Total Changes: 40 files changed, +123 additions, -101 deletions 🗺️ Walkthrough:graph TD
A["Entry Point src/index.ts"] --> B["Event Handler src/handlers/eventHandler.ts"]
B --> C["Client Ready Events src/events/clientReady/"]
B --> D["Message Create Events src/events/messageCreate/"]
B --> E["Guild Create Events src/events/guildCreate/"]
D --> F["Command Handler handleCommands.ts"]
F --> G["Command Categories"]
G --> H["Code Commands format, run, suggest, etc."]
G --> I["Mod Commands ban, unban, checkban"]
G --> J["Tools Commands color, http, regex, etc."]
G --> K["Support Commands feature, report"]
H --> L["Shared Utilities"]
I --> L
J --> L
K --> L
L --> M["cacheDB.ts Database Caching"]
L --> N["firestore.ts Database Operations"]
L --> O["stats.ts Statistics Tracking"]
L --> P["getConfig.ts Configuration"]
N --> Q["Firebase Config src/config/firebase.ts"]
style A fill:#e1f5ff
style L fill:#fff4e1
style Q fill:#ffe1e1
Note1["All imports now use .ts extensions instead of .js for HidenCloud compatibility"]
A -.-> Note1
🎯 Key Changes:
📊 Impact Assessment:
⚙️ SettingsSeverity Threshold: 📖 User Guide
|
| if (args[0] || message.guildId) { | ||
| const serverStats = await getServerStats( | ||
| (args[0] || message.guildId) ?? "", | ||
| ); |
There was a problem hiding this comment.
The conditional logic change introduces a bug that alters the command's behavior. The original code if (args[0]) only fetched server-specific stats when an argument was explicitly provided. The new condition if (args[0] || message.guildId) will almost always evaluate to true in guild contexts (since message.guildId typically exists), causing the command to always fetch server stats even when the user intended to view global stats.
This breaks the command's logic flow: when no argument is provided, the code should skip to line 58 to fetch global stats, but now it will incorrectly enter the server stats branch.
Confidence: 5/5
Suggested Fix
| if (args[0] || message.guildId) { | |
| const serverStats = await getServerStats( | |
| (args[0] || message.guildId) ?? "", | |
| ); | |
| if (args[0]) { | |
| const serverStats = await getServerStats( | |
| args[0] ?? message.guildId ?? "", | |
| ); | |
Revert the condition to if (args[0]) to preserve the original behavior. If you need to handle null/undefined args[0], use the nullish coalescing operator within the function call to fall back to message.guildId only when args[0] is explicitly provided but happens to be nullish.
Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
In src/commands/!stats/stats.ts around line 12, the conditional logic was changed from "if (args[0])" to "if (args[0] || message.guildId)" which breaks the command's intended behavior. When no argument is provided, the command should fetch global stats (line 58), but the new condition will almost always be true in guild contexts, causing it to incorrectly fetch server stats instead. Revert the condition to "if (args[0])" and keep the nullish coalescing operator inside the function call for safety: "args[0] ?? message.guildId ?? ''".
📍 This suggestion applies to lines 12-15
| "allowImportingTsExtensions": true, | ||
| "noEmit": true, |
There was a problem hiding this comment.
The combination of allowImportingTsExtensions: true and noEmit: true will prevent TypeScript from generating any JavaScript output files. This configuration is incompatible with standard Node.js execution unless you have an external bundler (like esbuild, webpack, or tsx) configured to handle the transpilation.
Impact: The build process will fail because:
noEmit: truetells TypeScript to skip emitting.jsfiles- Node.js cannot directly execute
.tsfiles with.tsimports - The
dist/directory (configured inoutDir) will remain empty
This will cause runtime failures when trying to run the application unless there's a separate build tool configured that isn't visible in this PR.
Confidence: 5/5
Suggested Fix
If you're using a bundler like esbuild or tsx for runtime execution, this configuration is correct. However, if you're relying on TypeScript's compiler for builds, you need to remove noEmit:
| "allowImportingTsExtensions": true, | |
| "noEmit": true, | |
| "allowImportingTsExtensions": true, | |
Remove the noEmit: true line to allow TypeScript to generate JavaScript output. Alternatively, if you must keep noEmit: true, ensure you have a separate build tool configured (esbuild, webpack, tsx, etc.) and document this requirement in the PR description or README.
Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
In tsconfig.json around line 27-28, the configuration has both "allowImportingTsExtensions: true" and "noEmit: true" which prevents TypeScript from generating any JavaScript output files. This will break the build process unless there's an external bundler configured. If you're using TypeScript's compiler for builds, remove the "noEmit: true" line. If you're using an external bundler like esbuild or tsx, keep this configuration but ensure the bundler is properly configured and document this requirement in the project's build documentation.
📍 This suggestion applies to lines 27-28
No description provided.