Skip to content

feat: remove automatic code detection and reformatting feature#30

Merged
calebephrem merged 4 commits into
open-devhub:mainfrom
calebephrem:main
Jul 2, 2026
Merged

feat: remove automatic code detection and reformatting feature#30
calebephrem merged 4 commits into
open-devhub:mainfrom
calebephrem:main

Conversation

@calebephrem

Copy link
Copy Markdown
Member

No description provided.

@devhub-bot devhub-bot Bot added feat New feature fix Bug fix labels Jul 2, 2026
@beetle-ai

beetle-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary by Beetle

This PR focuses on improving the bot's command reliability and removing an automatic feature that may have caused user friction. The changes include enhanced error handling for the man command to prevent crashes from missing arguments, and the complete removal of the automatic code detection and reformatting feature that would intercept and reformat user messages containing code.

📁 File Changes Summary (Consolidated across all commits):

File Status Changes Description
src/commands/docs/man.ts Modified +16/-4 Enhanced error handling by validating term argument before API call, improved error messages to distinguish between missing arguments and failed lookups, and refactored to use single term instead of joined args array
src/utils/man.ts Modified +0/-1 Removed unused section variable that was extracted but never utilized in the function
src/utils/detectCode.ts Deleted +0/-166 Removed entire code detection utility including language detection via flourite, line-by-line code analysis heuristics, and section parsing logic
src/events/messageCreate/detectCode.ts Deleted +0/-55 Removed automatic message interceptor that would delete user messages and repost them with formatted code blocks
CHANGELOG.md
README.md
Modified +0/-9 Removed all documentation references to the automatic code reformatting feature from changelog and user-facing documentation

Total Changes: 6 files changed, +16 additions, -236 deletions

🗺️ Walkthrough:

sequenceDiagram
participant User
participant Discord
participant ManCommand
participant ManAPI
User->>Discord: ";man"
Discord->>ManCommand: Execute command
ManCommand->>ManCommand: Validate term argument
alt No term provided
ManCommand->>Discord: "Missing Term" error embed
Discord->>User: Error message
else Term provided
ManCommand->>ManAPI: Fetch man page
alt Page not found
ManAPI-->>ManCommand: null
ManCommand->>Discord: "Man Page Not Found" embed
Discord->>User: Not found message
else Page found
ManAPI-->>ManCommand: Page data
ManCommand->>Discord: Formatted man page embed
Discord->>User: Man page content
end
Note over User,ManAPI: Automatic code detection removed Messages no longer intercepted
Loading

🎯 Key Changes:

  • Improved man command robustness: Added validation to check for missing term argument before making API calls, preventing potential crashes and providing clearer error messages to users
  • Better error messaging: Split error handling into two distinct cases - missing arguments vs. failed lookups - making it easier for users to understand what went wrong
  • Removed automatic code reformatting: Eliminated the feature that would automatically detect code in messages, delete the original message, and repost with formatting - this feature required Manage Messages permission and may have been intrusive
  • Code cleanup: Removed unused variables and 220+ lines of code detection logic including language detection heuristics and message interception handlers
  • Documentation updates: Cleaned up user-facing documentation to reflect the removal of automatic features

📊 Impact Assessment:

  • Security: ✅ Positive impact - Removing the automatic message deletion feature reduces the bot's permission requirements and attack surface. The bot no longer needs Manage Messages permission, following the principle of least privilege. Input validation in the man command prevents potential injection or crash scenarios from malformed input.
  • Performance: ✅ Positive impact - Removing the detectCode event handler eliminates processing overhead on every message sent in channels where the bot is present. The flourite language detection library and complex regex operations are no longer executed, reducing CPU usage and improving response times for legitimate commands.
  • Maintainability: ✅ Significant improvement - Removed 220+ lines of complex heuristic code that would require ongoing maintenance as new programming languages and patterns emerge. The man command is now more straightforward with clear error paths. Reduced dependencies (flourite) simplifies the codebase and reduces potential breaking changes from upstream libraries.
  • Testing: ⚠️ Consideration needed - The man command now has two distinct error paths that should be tested: (1) missing argument validation, and (2) API lookup failure. The removal of automatic code detection eliminates a complex feature that was difficult to test comprehensively due to its heuristic nature. Consider adding unit tests for the new validation logic in the man command.
⚙️ Settings

Severity Threshold: Medium — Balanced feedback — medium and high severity issues only.Change in Settings
Custom Rules: Define your own review rules — Set Custom Rules
PR Summary: Configure PR summary — Change in Settings

📖 User Guide
  • Once repos are connected, PR analysis is automatically enabled. You can disable analysis for this repo from beetleai.dev/analysis
  • Comment @beetle on any PR to start analysis manually
  • Comment @beetle stop to stop any ongoing analysis

Follow us: Beetle · X · LinkedIn

Comment thread src/commands/docs/man.ts Outdated
// };
const page = await man(args.join(" "));
if (!page) {
const term = args[0];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks support for multi-word man page terms. The original code used args.join(" ") to handle terms like "git commit" or "docker compose", but the new code only uses args[0], which would only capture the first word.
Example of broken behavior:

  • User input: !man git commit
  • Old behavior: Searches for "git commit" ✅
  • New behavior: Searches for "git" only ❌

Confidence: 5/5

Suggested Fix
Suggested change
const term = args[0];
const term = args.join(" ");

Change args[0] back to args.join(" ") to preserve the original multi-word term support. The validation check if (!term) will still work correctly because args.join(" ") returns an empty string when the array is empty, which is falsy.

Prompt for AI

Copy this prompt to your AI IDE to fix this issue locally:

In src/commands/docs/man.ts at line 25, the code currently uses args[0] which only
captures the first word of the man page term, breaking support for multi-word terms
like "git commit" or "docker compose". Change it to args.join(" ") to restore the
original behavior while keeping the improved error handling. The validation check
if (!term) will still work correctly because join returns an empty string for empty
arrays, which is falsy.

@devhub-bot

devhub-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Note

Linting checks passed successfully 🎉

All formatting and code quality checks are clean.

You're good to merge 🚀

@beetle-ai

beetle-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary by Beetle

This PR introduces a new crate command for searching Rust packages on crates.io and standardizes the field layout across all package search commands (npm, pip, crate). The changes improve consistency in how package information is displayed to users and expand the bot's package search capabilities to include the Rust ecosystem.

📁 File Changes Summary (Consolidated across all commits):

File Status Changes Description
src/commands/search/crate.ts Added +133/-0 New command implementation for searching Rust crates on crates.io with comprehensive package metadata display including version, downloads, repository, and license information
src/commands/search/npm.ts
src/commands/search/pip.ts
Modified +5/-22 Standardized field organization across package search commands: removed extraneous comments, reorganized embed fields for consistency (Author → Publisher → Recent Downloads → Repository → License), and removed less critical fields (Python Requires, Documentation button)
CHANGELOG.md
README.md
Modified +8/-5 Updated documentation to reflect new crate command and clarified man command description for better user understanding

Total Changes: 5 files changed, +148 additions, -28 deletions

🗺️ Walkthrough:

sequenceDiagram
participant User
participant Bot
participant CratesIO as crates.io API
participant PyPI as PyPI API
participant NPM as npm Registry
User->>Bot: ;crate tokio
Bot->>CratesIO: GET /api/v1/crates?q=tokio
CratesIO-->>Bot: Crate metadata
Bot->>Bot: Format embed with standardized fields
Note over Bot: Version, Publisher, Recent Downloads, Repository, License
Bot-->>User: Embed + Action Buttons
User->>Bot: ;pip requests
Bot->>PyPI: GET /pypi/{package}/json
PyPI-->>Bot: Package metadata
Bot->>Bot: Format with same field order
Bot-->>User: Consistent embed layout
User->>Bot: ;npm express
Bot->>NPM: GET /{package}
NPM-->>Bot: Package metadata
Bot->>Bot: Apply standardized formatting
Bot-->>User: Unified user experience
Loading

🎯 Key Changes:

  • New Rust Package Search: Added crate command with aliases crates and cargo to search crates.io registry, completing the trifecta of major package ecosystems (JavaScript/npm, Python/PyPI, Rust/crates.io)
  • Standardized Field Layout: Reorganized embed fields across all package search commands to follow consistent order: Version → Author/Publisher → Recent Downloads → Repository → License
  • Improved User Experience: Unified field naming (changed "Author" to "Publisher" in pip command) and removed less critical information to reduce visual clutter
  • Enhanced Documentation: Updated README and CHANGELOG to reflect new capabilities and clarify command descriptions

📊 Impact Assessment:

  • Security: ✅ Positive - Uses proper User-Agent headers for API requests, implements safe URL encoding, and includes error handling for failed API calls. No sensitive data exposure or security regressions introduced.
  • Performance: ⚡ Neutral - New command adds minimal overhead with single API call pattern similar to existing commands. Removed unnecessary fields may slightly reduce embed rendering time. No performance bottlenecks identified.
  • Maintainability: 📈 Improved - Standardized field structure across all package search commands makes the codebase more predictable and easier to maintain. Consistent patterns reduce cognitive load for future contributors. Minor issue: Button label copy-paste error on line 97 ("View on npm" should be "View on crates.io") should be fixed.
  • Testing: ⚠️ Needs Attention - No test coverage visible for the new crate command. Recommend adding unit tests for: API response parsing, error handling (no results, network failures), embed formatting, and alias functionality. Existing commands (npm, pip) should also have regression tests to ensure field reorganization doesn't break functionality.
⚙️ Settings

Severity Threshold: Medium — Balanced feedback — medium and high severity issues only.Change in Settings
Custom Rules: Define your own review rules — Set Custom Rules
PR Summary: Configure PR summary — Change in Settings

📖 User Guide
  • Once repos are connected, PR analysis is automatically enabled. You can disable analysis for this repo from beetleai.dev/analysis
  • Comment @beetle on any PR to start analysis manually
  • Comment @beetle stop to stop any ongoing analysis

Follow us: Beetle · X · LinkedIn

@beetle-ai

beetle-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary by Beetle

This PR introduces several improvements to the Quillbot Discord bot, focusing on command enhancements and feature cleanup. The changes include improved error handling for the man command, removal of the automatic code detection/reformatting feature, and addition of a new crate command for searching Rust packages. The PR also includes documentation updates and field reorganization for package search commands to maintain consistency across similar features.

📁 File Changes Summary (Consolidated across all commits):

File Status Changes Description
src/commands/docs/man.ts Modified +17/-5 Enhanced error handling with separate validation for missing terms vs. not-found pages; improved user feedback with clearer error messages
src/commands/search/crate.ts Added +133/-0 New command to search Rust crates from crates.io registry with detailed package information, download stats, and repository links
src/commands/search/npm.ts
src/commands/search/pip.ts
Modified +5/-22 Reorganized embed fields for consistency across package search commands; removed redundant comments and simplified field ordering
src/utils/man.ts Modified +0/-1 Removed unused section variable extraction
src/utils/detectCode.ts
src/events/messageCreate/detectCode.ts
Deleted +0/-221 Removed automatic code detection and reformatting feature entirely, including language detection logic and message handling
CHANGELOG.md
README.md
Modified +8/-14 Updated documentation to reflect new crate command, improved man command description, and removed references to automatic code reformatting feature

Total Changes: 10 files changed, +163 additions, -264 deletions

🗺️ Walkthrough:

graph TD
A["User sends ;crate tokio"] --> B["crate.ts command handler"]
B --> C["Fetch from crates.io API"]
C --> D{"Crate found?"}
D -->|"No"| E["Return 'No crates found' message"]
D -->|"Yes"| F["Extract crate metadata"]
F --> G["Build embed with fields"]
G --> H["Add version, downloads, license"]
H --> I["Create action buttons"]
I --> J["Add crates.io link"]
J --> K{"Homepage exists?"}
K -->|"Yes"| L["Add homepage button"]
K -->|"No"| M["Skip homepage button"]
L --> N["Send embed with buttons"]
M --> N
O["User sends ;man without args"] --> P["man.ts validation"]
P --> Q{"Term provided?"}
Q -->|"No"| R["Return 'Missing Term' error"]
Q -->|"Yes"| S["Fetch man page"]
S --> T{"Page found?"}
T -->|"No"| U["Return 'Man Page Not Found' error"]
T -->|"Yes"| V["Display man page embed"]
style B fill:#4CAF50
style F fill:#2196F3
style P fill:#FF9800
style G fill:#2196F3
Loading

🎯 Key Changes:

  • New crate Command: Adds comprehensive Rust package search functionality with crates.io integration, displaying version info, download statistics, repository links, and license information
  • Enhanced Error Handling: The man command now properly validates input before attempting to fetch pages, providing clearer error messages for missing terms vs. non-existent pages
  • Feature Removal: Completely removed the automatic code detection and reformatting feature, including the detectCode utility and messageCreate event handler, simplifying the bot's automatic behaviors
  • Documentation Consistency: Reorganized embed fields across package search commands (npm, pip, crate) to maintain a consistent user experience with standardized field ordering
  • Code Cleanup: Removed unused variables and comments, improving code maintainability

📊 Impact Assessment:

  • Security: ✅ Positive impact - Removal of automatic message deletion feature (detectCode) eliminates potential permission abuse vectors and reduces the bot's required permissions footprint. The new crate command properly uses User-Agent headers for API requests.
  • Performance: ✅ Improved - Removing the automatic code detection feature eliminates processing overhead on every message event, significantly reducing CPU usage in active servers. The new crate command uses efficient single-request API calls with pagination limits.
  • Maintainability: ✅ Significantly improved - Deletion of 221 lines of complex code detection logic (including language detection with flourite) reduces technical debt. The codebase is now simpler with fewer dependencies. Field reorganization across search commands creates a more maintainable pattern for future package search additions.
  • Testing: ⚠️ Needs attention - No test coverage visible for the new crate command. Error handling improvements in man.ts should be validated with edge cases (empty strings, special characters, multi-word terms). The removal of detectCode feature should be verified to ensure no orphaned event listeners or dependencies remain.
⚙️ Settings

Severity Threshold: Medium — Balanced feedback — medium and high severity issues only.Change in Settings
Custom Rules: Define your own review rules — Set Custom Rules
PR Summary: Configure PR summary — Change in Settings

📖 User Guide
  • Once repos are connected, PR analysis is automatically enabled. You can disable analysis for this repo from beetleai.dev/analysis
  • Comment @beetle on any PR to start analysis manually
  • Comment @beetle stop to stop any ongoing analysis

Follow us: Beetle · X · LinkedIn

@beetle-ai

beetle-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

✅ You're good to merge this PR! No issues found. Great job!

Settings
⚙️ Settings

Severity Threshold: Medium — Balanced feedback — medium and high severity issues only.Change in Settings
Custom Rules: Define your own review rules — Set Custom Rules
PR Summary: Configure PR summary — Change in Settings

📖 User Guide
  • Once repos are connected, PR analysis is automatically enabled. You can disable analysis for this repo from beetleai.dev/analysis
  • Comment @beetle on any PR to start analysis manually
  • Comment @beetle stop to stop any ongoing analysis

@devhub-bot

devhub-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Note

Linting checks passed successfully 🎉

All formatting and code quality checks are clean.

You're good to merge 🚀

Comment on lines +25 to +31
const searchRes = await fetch(
`https://crates.io/api/v1/crates?q=${encodeURIComponent(query)}&per_page=1`,
{
headers: { "User-Agent": "DiscordBot (contact@yourbotdomain.com)" },
},
);
const searchData = await searchRes.json();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code doesn't validate the HTTP response status before attempting to parse JSON. If the crates.io API returns an error status (4xx, 5xx), calling .json() on a non-JSON response will throw an exception that gets caught generically, hiding the actual API error from users.

Confidence: 5/5

Suggested Fix
Suggested change
const searchRes = await fetch(
`https://crates.io/api/v1/crates?q=${encodeURIComponent(query)}&per_page=1`,
{
headers: { "User-Agent": "DiscordBot (contact@yourbotdomain.com)" },
},
);
const searchData = await searchRes.json();
const searchRes = await fetch(
`https://crates.io/api/v1/crates?q=${encodeURIComponent(query)}&per_page=1`,
{
headers: { "User-Agent": "DiscordBot (contact@yourbotdomain.com)" },
},
);
if (!searchRes.ok) {
return message.reply(`Failed to fetch crate data: ${searchRes.status} ${searchRes.statusText}`);
}
const searchData = await searchRes.json();

Add HTTP response status validation after the fetch call and before parsing JSON. This prevents attempting to parse error HTML/text responses as JSON and provides clearer error messages to users.

Prompt for AI

Copy this prompt to your AI IDE to fix this issue locally:

In src/commands/search/crate.ts around line 25-31, the fetch call to crates.io API doesn't validate the HTTP response status before calling .json(). Add a check for searchRes.ok after line 30 and before line 31, and return an appropriate error message if the response status indicates failure (4xx or 5xx). This prevents JSON parsing errors when the API returns non-JSON error responses.

📍 This suggestion applies to lines 25-31

);
}

const row = new ActionRowBuilder().addComponents(...componentButtons);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ActionRowBuilder is instantiated without a generic type parameter, which will cause TypeScript compilation errors or runtime issues when calling .toJSON(). Discord.js v14+ requires explicit typing for ActionRowBuilder components.

Confidence: 5/5

Suggested Fix
Suggested change
const row = new ActionRowBuilder().addComponents(...componentButtons);
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(...componentButtons);

Add the generic type parameter <ButtonBuilder> to ActionRowBuilder to ensure type safety and prevent runtime errors when converting to JSON.

Prompt for AI

Copy this prompt to your AI IDE to fix this issue locally:

In src/commands/search/crate.ts at line 113, the ActionRowBuilder is missing its generic type parameter. Add <ButtonBuilder> after ActionRowBuilder to properly type the component row, which is required for Discord.js v14+ and prevents type errors when calling .toJSON().

@beetle-ai

beetle-ai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary by Beetle

This PR introduces a new ;gem command that enables users to search and retrieve detailed information about Ruby gems directly from the RubyGems registry. The command follows the established pattern of package lookup commands (like ;crate and ;npm), providing comprehensive gem metadata including version, author, downloads, repository links, and documentation in a rich Discord embed format.

📁 File Changes Summary (Consolidated across all commits):

File Status Changes Description
src/commands/search/gem.ts Added +141/-0 New command implementation for Ruby gem search functionality. Queries the RubyGems API, formats results into Discord embeds with metadata (version, author, downloads, license), and provides interactive buttons for documentation and homepage links.
CHANGELOG.md Modified +1/-0 Added entry documenting the new gem command feature in the unreleased changes section.
README.md Modified +1/-0 Updated command reference table to include the ;gem command with description of its functionality.

Total Changes: 3 files changed, +143 additions, -0 deletions

🗺️ Walkthrough:

sequenceDiagram
participant User
participant Discord
participant GemCommand
participant RubyGemsAPI
User->>Discord: ;gem rails
Discord->>GemCommand: Execute command with args
alt No query provided
GemCommand->>User: Error: "Please provide a search term"
else Query provided
GemCommand->>RubyGemsAPI: GET /api/v1/search.json?query=rails
alt API Error
RubyGemsAPI-->>GemCommand: Error response
GemCommand->>User: Error embed
else Success
RubyGemsAPI-->>GemCommand: JSON array of gems
alt No results
GemCommand->>User: "No Ruby gems found"
else Results found
GemCommand->>GemCommand: Format first result
Note over GemCommand: Extract metadata: version, author, downloads, repository, license
GemCommand->>GemCommand: Build embed & buttons
GemCommand->>User: Rich embed with gem details + action buttons
end
Loading

🎯 Key Changes:

  • New Package Search Command: Implements ;gem command with aliases gems and gempkg for searching Ruby gems on rubygems.org
  • Comprehensive Metadata Display: Shows version, author, publisher, total downloads, repository link, and license information in a formatted embed
  • Smart Description Handling: Truncates long descriptions at 800 characters while preserving word boundaries for readability
  • Interactive UI Components: Provides clickable buttons for RubyGems page, homepage, and documentation links when available
  • GitHub Repository Detection: Intelligently formats GitHub repository URLs for cleaner display
  • Error Handling: Includes robust error handling for API failures and empty search results with user-friendly messages
  • Consistent Branding: Uses RubyGems logo as thumbnail and official color scheme (#e9573f) for visual consistency

📊 Impact Assessment:

  • Security: ✅ Low Risk - Uses encodeURIComponent() for query sanitization preventing injection attacks. Relies on official RubyGems API (https). No sensitive data handling or authentication required. Consider adding rate limiting to prevent API abuse.
  • Performance: ✅ Good - Efficient single API call with early returns for error cases. Description truncation prevents oversized embeds. Fetches only the first search result to minimize data transfer. Potential improvement: Add caching for frequently searched gems to reduce API calls.
  • Maintainability: ✅ Excellent - Clean, well-structured code following established command patterns. Clear variable naming and logical flow. Comprehensive error handling with descriptive messages. TypeScript types ensure type safety. Consistent with existing commands (;crate, ;npm) making it easy for developers to understand and extend.
  • Testing: ⚠️ Needs Attention - No test coverage included in this PR. Recommended tests:
  • Unit tests for API response parsing
  • Edge cases: empty results, malformed API responses, missing optional fields
  • Integration tests for command execution flow
  • Validation of embed formatting and button generation
  • Error handling scenarios (API timeout, network failures)
⚙️ Settings

Severity Threshold: Medium — Balanced feedback — medium and high severity issues only.Change in Settings
Custom Rules: Define your own review rules — Set Custom Rules
PR Summary: Configure PR summary — Change in Settings

📖 User Guide
  • Once repos are connected, PR analysis is automatically enabled. You can disable analysis for this repo from beetleai.dev/analysis
  • Comment @beetle on any PR to start analysis manually
  • Comment @beetle stop to stop any ongoing analysis

Follow us: Beetle · X · LinkedIn

Comment on lines +23 to +25
const searchRes = await fetch(
`https://rubygems.org/api/v1/search.json?query=${encodeURIComponent(query)}`,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetch request lacks a timeout, which can cause the Discord bot to hang indefinitely if the RubyGems API is slow or unresponsive. This can lead to resource exhaustion and poor user experience.

Confidence: 5/5

Suggested Fix
Suggested change
const searchRes = await fetch(
`https://rubygems.org/api/v1/search.json?query=${encodeURIComponent(query)}`,
);
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 10000);
const searchRes = await fetch(
`https://rubygems.org/api/v1/search.json?query=${encodeURIComponent(query)}`,
{ signal: controller.signal }
);
clearTimeout(timeoutId);

Add a 10-second timeout to prevent the request from hanging indefinitely. Wrap the fetch in a try-catch to handle AbortError appropriately.

Prompt for AI

Copy this prompt to your AI IDE to fix this issue locally:

In src/commands/search/gem.ts around line 23, the fetch request to the RubyGems API lacks a timeout mechanism, which can cause the bot to hang indefinitely if the API is slow or unresponsive; add an AbortController with a 10-second timeout to the fetch request, and handle the AbortError in the catch block to provide a user-friendly timeout message.

📍 This suggestion applies to lines 23-25

throw new Error("RubyGems API failed to respond properly.");
}

const searchData = await searchRes.json();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The searchRes.json() call can throw an error if the API returns invalid JSON, but this isn't caught separately from other errors. This could expose internal error details to users or cause unclear error messages.

Confidence: 5/5

Suggested Fix
Suggested change
const searchData = await searchRes.json();
const searchData = await searchRes.json().catch(() => {
throw new Error("Invalid response format from RubyGems API");
});

Add explicit error handling for JSON parsing failures to provide clearer error messages and prevent exposing internal error details.

Prompt for AI

Copy this prompt to your AI IDE to fix this issue locally:

In src/commands/search/gem.ts around line 31, the JSON parsing of the API response can throw an error if the response is malformed, but this isn't handled separately; wrap the json() call in a try-catch or use .catch() to throw a more specific error message like "Invalid response format from RubyGems API" to improve error clarity.

);
}

const row = new ActionRowBuilder().addComponents(...buttons);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActionRowBuilder requires a generic type parameter in Discord.js v14+. Without it, TypeScript will throw a compilation error, and the toJSON() method may not work correctly.

Confidence: 5/5

Suggested Fix
Suggested change
const row = new ActionRowBuilder().addComponents(...buttons);
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(...buttons);

Add the generic type parameter <ButtonBuilder> to ensure type safety and proper compilation.

Prompt for AI

Copy this prompt to your AI IDE to fix this issue locally:

In src/commands/search/gem.ts at line 121, the ActionRowBuilder is missing its required generic type parameter; change it to ActionRowBuilder<ButtonBuilder> to ensure proper TypeScript compilation and type safety with Discord.js v14+.

@devhub-bot

devhub-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Note

Linting checks passed successfully 🎉

All formatting and code quality checks are clean.

You're good to merge 🚀

@calebephrem calebephrem merged commit 38f198b into open-devhub:main Jul 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat New feature fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant