Repository navigation
Conversation
Summary by BeetleThis PR is a comprehensive code cleanup and quality improvement initiative that addresses multiple technical debt items and enhances functionality. The PR consists of 17 commits that:
📁 File Changes Summary (Consolidated across all commits):
Total Changes: 15 files changed, +64 additions, -57 deletions🗺️ Walkthrough:graph TD
A["User Command: usage"] -->|"Check for mentions"| B{"Has mention or args?"}
B -->|"Args but no mention"| C["Reply with usage help"]
B -->|"Has mention"| D["Fetch target user"]
B -->|"No args/mention"| E["Use current user"]
D --> F["Fetch guild member for display name"]
E --> F
F --> G["Build card options"]
G --> H["Render usage card"]
H --> I["Send attachment with user ID"]
I --> J["Success"]
C --> K["Return early"]
L["Code Quality Improvements"] -->|"Type Safety"| M["Replace any with CanvasRenderingContext2D"]
L -->|"Async/Await"| N["Add missing await on message.reply"]
L -->|"Remove Dead Code"| O["Delete unused modules and constants"]
L -->|"Redundancy"| P["Remove duplicate imports and logic"]
🎯 Key Changes:
📊 Impact Assessment:
⚙️ SettingsSeverity Threshold: 📖 User Guide
|
|
Note Linting checks passed successfully 🎉 All formatting and code quality checks are clean. You're good to merge 🚀 |
| } | ||
|
|
There was a problem hiding this comment.
The removal of CONTEXTS.set(userId, history); breaks the core functionality of the addToContext function. Without this line, the context is never persisted to the CONTEXTS map, making all the history management logic (size limiting, etc.) ineffective. This will cause context retrieval to fail for all users.
Confidence: 5/5
Suggested Fix
| } | |
| export function addToContext( | |
| userId: string, | |
| message: Message, | |
| role: "user" | "assistant" | |
| ) { | |
| if (!CONTEXTS.has(userId)) { | |
| CONTEXTS.set(userId, []); | |
| } | |
| const history = CONTEXTS.get(userId)!; | |
| history.push({ | |
| role, | |
| content: message, | |
| }); | |
| if (history.length > MAX_MESSAGES) { | |
| history.shift(); | |
| } | |
| CONTEXTS.set(userId, history); | |
| } | |
Restore the CONTEXTS.set(userId, history); line at the end of the function to persist the updated history back to the map.
Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
In src/utils/context.ts around line 40, the line CONTEXTS.set(userId, history);
was accidentally removed, which breaks context persistence. Restore this line at
the end of the addToContext function to ensure the updated history is saved back
to the CONTEXTS map.
📍 This suggestion applies to lines 39-40
Summary by BeetleThis PR fixes a critical bug in the context management system where the 📁 File Changes Summary (Consolidated across all commits):
Total Changes: 1 file changed, +2 additions, -0 deletions 🎯 Key Changes:
📊 Impact Assessment:
⚙️ SettingsSeverity Threshold: 📖 User Guide
|
|
✅ You're good to merge this PR! No issues found. Great job! Settings⚙️ SettingsSeverity Threshold: 📖 User Guide
|
|
Note Linting checks passed successfully 🎉 All formatting and code quality checks are clean. You're good to merge 🚀 |
Summary by BeetleThis PR removes the ability for users to query token usage for other users via the 📁 File Changes Summary (Consolidated across all commits):
Total Changes: 1 file changed, +9 additions, -21 deletions 🎯 Key Changes:
📊 Impact Assessment:
⚙️ SettingsSeverity Threshold: 📖 User Guide
|
| async execute({ message }: CommandCallbackOpts) { | ||
| if (message.author.bot) return; | ||
|
|
||
| if (message.mentions.users.first()) { |
There was a problem hiding this comment.
The code accesses message.mentions.users.first() without optional chaining, but the original code used message.mentions?.users?.first(). This could throw a runtime error if message.mentions or message.mentions.users is undefined or null.
Confidence: 4/5
Suggested Fix
| if (message.mentions.users.first()) { | |
| if (message.mentions?.users?.first()) { | |
The optional chaining operator (?.) safely accesses nested properties and returns undefined if any part of the chain is null or undefined, preventing runtime errors.
Prompt for AI
Copy this prompt to your AI IDE to fix this issue locally:
In src/commands/ai/usage.ts around line 14, the code accesses message.mentions.users.first()
without optional chaining, which could throw a runtime error if message.mentions or
message.mentions.users is undefined. Change it to use optional chaining:
message.mentions?.users?.first() to safely handle cases where these properties don't exist.
|
Note Linting checks passed successfully 🎉 All formatting and code quality checks are clean. You're good to merge 🚀 |
Summary by BeetleThis PR addresses a potential null reference error in the AI usage command by adding optional chaining operators to the 📁 File Changes Summary (Consolidated across all commits):
Total Changes: 1 file changed, +1 additions, -1 deletions 🎯 Key Changes:
📊 Impact Assessment:
⚙️ SettingsSeverity Threshold: 📖 User Guide
|
|
✅ You're good to merge this PR! No issues found. Great job! Settings⚙️ SettingsSeverity Threshold: 📖 User Guide
|
|
Note Linting checks passed successfully 🎉 All formatting and code quality checks are clean. You're good to merge 🚀 |
|
wait |
New Feature
Bug Fixes
awaitonmessage.reply()in ping and permission check commandsmemberfetch in rank command (unnecessary Discord API call)CONTEXTS.set()in addToContextlettoconstin getAllFilesDead Code Removal
fileOps.ts(unused module)regex.ts(unused constants)SubcommandCallbackOptstype__filenamevariabledotenv/configimports (already loaded in index.ts)Type Safety
ctx: anywithctx: CanvasRenderingContext2Din usageCard, leaderboardCard, and statsCardFiles Changed
src/commands/ai/usage.ts,src/commands/ai/rank.ts,src/commands/misc/ping.ts,src/commands/misc/help.ts,src/events/messageCreate/handleCommands.ts,src/events/messageCreate/aiMode.ts,src/utils/ai.ts,src/utils/context.ts,src/utils/getAllFiles.ts,src/types/command.ts,src/visuals/usageCard.ts,src/visuals/leaderboardCard.ts,src/visuals/statsCard.tssrc/utils/fileOps.ts(deleted),src/constants/regex.ts(deleted)