Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Jun 25, 2025

Resolves #17200

Summary by CodeRabbit

  • New Features

    • Added an option to ignore messages sent by the bot itself in new message, thread message, and forum thread message event sources.
    • Users can now enable or disable filtering of bot-authored messages via a new setting.
  • Bug Fixes

    • Corrected import paths for improved reliability across several Discord Bot components.
  • Chores

    • Updated version numbers for multiple Discord Bot components.

@vercel
Copy link

vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Jun 25, 2025 6:14pm
pipedream-docs ⬜️ Ignored (Inspect) Jun 25, 2025 6:14pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jun 25, 2025 6:14pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 25, 2025

Walkthrough

The changes introduce an optional "Ignore Bot Messages" flag to several Discord bot trigger sources, enabling users to filter out messages sent by the configured bot itself. Supporting methods for retrieving and storing the bot's ID, as well as fetching the bot profile, are added to the shared common module. Version numbers and import paths are also updated.

Changes

Files/Paths Change Summary
components/discord_bot/package.json Bumped package version from 0.6.1 to 0.6.2.
components/discord_bot/sources/common/common.mjs Updated import paths; added _getBotId, _setBotId, and getBotProfile methods for bot ID management and profile fetch.
.../sources/new-message-in-channel/new-message-in-channel.mjs
.../sources/new-thread-message/new-thread-message.mjs
.../sources/new-forum-thread-message/new-forum-thread-message.mjs
Added optional ignoreBotMessages prop, deploy hook for bot ID, and logic to filter bot-authored messages before emitting.
.../sources/new-guild-member/new-guild-member.mjs
.../sources/new-tag-added-to-thread/new-tag-added-to-thread.mjs
Updated import paths and incremented version numbers; no functional changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Source (Trigger)
    participant Common Module
    participant Discord API

    User->>Source (Trigger): Enable "Ignore Bot Messages" flag
    Source (Trigger)->>Common Module: deploy() - getBotProfile()
    Common Module->>Discord API: GET /users/@me
    Discord API-->>Common Module: Bot profile (ID)
    Common Module-->>Source (Trigger): Bot ID

    loop On new message event
        Source (Trigger)->>Common Module: _getBotId()
        Source (Trigger)->>Discord API: Fetch new messages
        Discord API-->>Source (Trigger): Messages
        Source (Trigger)->>Source (Trigger): Filter out messages from bot ID if flag enabled
        Source (Trigger)->>User: Emit event(s) for non-bot messages
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Add "Ignore Bot Messages" flag to New Forum Thread Message trigger (#17200)
Only emit event if new message is NOT from the configured Discord bot (#17200)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes were found.

Poem

A bunny hopped through Discord code,
Ignoring bot loops on its road.
Now triggers skip their own replies,
No infinite loops, no workflow sighs.
With flags and filters, bugs are gone,
The rabbit cheers and hops along! 🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/discord_bot/sources/new-forum-thread-message/new-forum-thread-message.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)

components/discord_bot/sources/common/common.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)

components/discord_bot/sources/new-thread-message/new-thread-message.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:201:49)

  • 3 others
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
components/discord_bot/sources/common/common.mjs (1)

26-30: Consider adding error handling for Discord API call.

The getBotProfile() method correctly uses the Discord API endpoint /users/@me. However, consider adding error handling since this method will be called during the deploy hook, and API failures could prevent proper initialization.

 getBotProfile() {
-  return this.discord._makeRequest({
-    path: "/users/@me",
-  });
+  try {
+    return this.discord._makeRequest({
+      path: "/users/@me",
+    });
+  } catch (error) {
+    console.error("Failed to fetch bot profile:", error);
+    throw error;
+  }
 },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db67e3d and e06197a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • components/discord_bot/package.json (1 hunks)
  • components/discord_bot/sources/common/common.mjs (2 hunks)
  • components/discord_bot/sources/new-forum-thread-message/new-forum-thread-message.mjs (5 hunks)
  • components/discord_bot/sources/new-guild-member/new-guild-member.mjs (2 hunks)
  • components/discord_bot/sources/new-message-in-channel/new-message-in-channel.mjs (4 hunks)
  • components/discord_bot/sources/new-tag-added-to-thread/new-tag-added-to-thread.mjs (2 hunks)
  • components/discord_bot/sources/new-thread-message/new-thread-message.mjs (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (24)
components/discord_bot/package.json (1)

3-3: LGTM: Appropriate version bump for new feature.

The version increment from 0.6.1 to 0.6.2 correctly reflects the addition of the new "ignore bot messages" functionality across multiple source files.

components/discord_bot/sources/new-guild-member/new-guild-member.mjs (2)

2-2: LGTM: Import path correctly updated for refactored structure.

The import path change from "../common.mjs" to "../common/common.mjs" aligns with the code organization improvements across the Discord bot sources.


11-11: LGTM: Version increment follows semantic versioning.

The version bump from 0.1.4 to 0.1.5 appropriately reflects the structural changes to the import paths.

components/discord_bot/sources/new-tag-added-to-thread/new-tag-added-to-thread.mjs (2)

2-2: LGTM: Consistent import path refactoring.

The import path update aligns with the broader structural improvements being made across the Discord bot source files.


11-11: LGTM: Appropriate version increment.

Version bump correctly reflects the import path changes made to the file.

components/discord_bot/sources/common/common.mjs (2)

1-2: LGTM: Import paths correctly updated for new directory structure.

The updated import paths properly reference the parent directories after the common module restructuring.


20-25: LGTM: Bot ID database management methods are well-implemented.

The _getBotId() and _setBotId() methods follow consistent patterns with existing database operations and use appropriate key naming.

components/discord_bot/sources/new-thread-message/new-thread-message.mjs (6)

3-3: LGTM: Import path correctly updated.

The import path change aligns with the common module restructuring across the codebase.


12-12: LGTM: Version increment appropriate for new feature.

Version bump from 0.0.5 to 0.0.6 correctly reflects the addition of the ignore bot messages functionality.


23-28: LGTM: Well-designed optional prop for bot message filtering.

The ignoreBotMessages prop is properly configured as an optional boolean with clear labeling and description. The implementation maintains backward compatibility.


30-36: LGTM: Efficient deploy hook implementation.

The deploy hook correctly fetches and stores the bot ID only when the feature is enabled, avoiding unnecessary API calls when the feature is disabled.


41-43: LGTM: Clean bot ID retrieval logic.

The conditional retrieval of bot ID is efficient and follows the expected pattern for optional feature implementation.


101-103: LGTM: Correct message filtering implementation.

The filtering logic properly excludes messages authored by the bot when the feature is enabled. The placement after message retrieval but before emission is optimal for performance.

components/discord_bot/sources/new-forum-thread-message/new-forum-thread-message.mjs (6)

4-4: LGTM: Import path correction looks good.

The import path change to the more specific subdirectory structure aligns with the described refactoring.


13-13: LGTM: Version increment is appropriate.

The version bump from 0.0.4 to 0.0.5 is suitable for this minor feature addition.


38-43: LGTM: Well-defined optional property.

The ignoreBotMessages prop is properly configured with appropriate type, label, description, and marked as optional.


64-66: LGTM: Efficient bot ID retrieval pattern.

The conditional bot ID retrieval is implemented efficiently, fetching the ID only once per run when needed.


133-135: LGTM: Optimal filtering placement.

The message filtering is strategically placed after retrieval but before expensive channel enrichment operations, which optimizes performance by avoiding unnecessary API calls for bot messages.


45-51: To locate these method definitions more reliably, let’s search the entire repo (including arrow‐function and async variants):

#!/bin/bash
# Search for any definition or assignment of getBotProfile and _setBotId
rg -n "getBotProfile" .
rg -n "_setBotId" .
rg -n "async getBotProfile" .
rg -n "getBotProfile\s*=" .
rg -n "_setBotId\s*=" .
components/discord_bot/sources/new-message-in-channel/new-message-in-channel.mjs (5)

3-3: LGTM: Consistent import path update.

The import path change matches the pattern established in the other Discord bot sources.


14-14: LGTM: Appropriate version increment.

Version bump from 0.0.18 to 0.0.19 is suitable for this feature addition.


39-44: LGTM: Consistent property definition.

The ignoreBotMessages prop definition matches the implementation in other Discord bot sources, maintaining consistency across the codebase.


52-58: LGTM: Consistent deploy hook implementation.

The deploy hook follows the same pattern as other Discord bot sources and properly handles the conditional bot ID retrieval and storage.


116-118: LGTM: Efficient message filtering implementation.

The filtering logic is correctly implemented and placed optimally before event emission to avoid processing unnecessary bot messages.

Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

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

Hi @michelle0927, LGTM! Ready for QA!

@michelle0927 michelle0927 merged commit 62c7aef into master Jun 26, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-17200 branch June 26, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add Ignore Bot Messages Flag in Discord Bot - New Forum Thread Message Trigger

3 participants