-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bot: debug handleInteractionResponseEdit #235
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
bot/src/rabbitmq/events/interactionResponseEdit.ts (2)
Line range hint
9-24
: Improve type safety and validationThe function could benefit from the following improvements:
- Replace
any
type with a proper interface/type definition- Add validation for required fields
- Consider uncommenting the logger.info statements for better observability
Consider applying these changes:
- export async function handleInteractionResponseEdit(msg: any): Promise<void> { + interface InteractionMessage { + content: { + interaction: unknown; + data: unknown; + }; + } + + export async function handleInteractionResponseEdit(msg: InteractionMessage): Promise<void> { try { - // logger.info({ msg, event: Event.DISCORD_BOT.INTERACTION_RESPONSE.EDIT }, 'is running'); + logger.info({ msg, event: Event.DISCORD_BOT.INTERACTION_RESPONSE.EDIT }, 'is running'); + if (!msg?.content?.interaction || !msg?.content?.data) { + throw new Error('Missing required fields in message'); + } const interaction = msg.content.interaction; const data = msg.content.data; await interactionService.editOriginalInteractionResponse(interaction, data); - // logger.info({ msg, event: Event.DISCORD_BOT.INTERACTION_RESPONSE.EDIT }, 'is done'); + logger.info({ msg, event: Event.DISCORD_BOT.INTERACTION_RESPONSE.EDIT }, 'is done'); } catch (error) { logger.error({ msg, event: Event.DISCORD_BOT.INTERACTION_RESPONSE.EDIT, error }, 'is failed'); } }
Remove debug console.log statements and maintain consistent logging pattern
The verification reveals inconsistent logging patterns across interaction handlers:
interactionResponseCreate.ts
properly uses logger.info for start and completioninteractionResponseDelete.ts
has commented-out logger.info statementsinteractionResponseEdit.ts
has both commented-out logger.info and debug console.log statementsPlease:
- Remove all console.log debug statements from interactionResponseEdit.ts
- Uncomment the logger.info statements to match the pattern in interactionResponseCreate.ts
- Consider uncommenting logger.info statements in interactionResponseDelete.ts for consistency
🔗 Analysis chain
Line range hint
1-24
: Verify consistent logging patterns across the codebaseLet's ensure that other interaction handlers follow consistent logging patterns.
Let me check the logging patterns in the other interaction handlers to ensure consistency.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for inconsistent logging patterns in interaction handlers # Search for console.log statements in interaction handlers echo "Checking for console.log statements in interaction handlers:" rg "console\.log" "bot/src/rabbitmq/events/" # Search for similar handler patterns to ensure consistency echo -e "\nChecking other interaction handlers for logging patterns:" rg "handleInteraction.*Response" "bot/src/rabbitmq/events/"Length of output: 1207
Script:
#!/bin/bash # Check the content of other interaction handlers echo "Content of interactionResponseDelete.ts:" cat bot/src/rabbitmq/events/interactionResponseDelete.ts echo -e "\nContent of interactionResponseCreate.ts:" cat bot/src/rabbitmq/events/interactionResponseCreate.tsLength of output: 2288
const data = msg?.content.data | ||
console.log(msg) | ||
console.log('***************') | ||
console.log(msg?.content) | ||
console.log(msg?.content.data) | ||
console.log('***************') | ||
console.log(msg?.interaction) | ||
console.log(msg?.content.interaction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove debug console.log statements
The console.log statements appear to be temporary debugging code. These should be removed or replaced with proper structured logging.
Replace the debug statements with proper logging:
- console.log(msg)
- console.log('***************')
- console.log(msg?.content.data)
- console.log('***************')
- console.log(msg?.content.interaction)
+ logger.debug({
+ messageData: msg?.content.data,
+ interaction: msg?.content.interaction
+ }, 'Processing interaction response edit');
Committable suggestion skipped: line range outside the PR's diff.
Summary by CodeRabbit
Bug Fixes
Chores