Skip to content

Smart contract discord notifications #93

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

mauridev777
Copy link

@mauridev777 mauridev777 commented Jul 11, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@mauridev777
Copy link
Author

mauridev777 commented Jul 11, 2025

Sending for the BNB Hack - BNB chain cookbook. Wishlist topic number 10 : Discord bot: Create and on chain webhook to listen for blockchain events and integrate it with Discord bot for real-time notifications.

BNB Chain Discord Notification Webhook

Copy link
Contributor

@VamshiVerma VamshiVerma left a comment

Choose a reason for hiding this comment

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

Great work on setting up the Discord notification system with clear documentation and structure. The implementation is clean and easy to follow, but there are a few high-priority concerns: please address Discord webhook error handling (add retries/logging). Overall, this is a solid feature, just a few changes needed for production readiness!

`🕒 Time: <t:${log.timestamp.toString()}>`,
};

await axios.post(DISCORD_WEBHOOK_URL, message);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks solid overall. One thing to consider: If the Discord webhook fails (for example, due to rate limits or network errors), the current implementation throws and returns a 500 error, which causes the notification to be lost. For critical alerts, could you add simple retry logic (e.g., 2–3 attempts with backoff) to reduce the risk of missing important events?

let attempts = 0;
const maxAttempts = 3;

while (attempts < maxAttempts) {
  try {
    await axios.post(DISCORD_WEBHOOK_URL, message);
    break; // Success
  } catch (err) {
    attempts++;
    if (attempts === maxAttempts) {
      logger.error("Discord webhook failed after retries", { err, message });
      throw err;
    }

    // Exponential backoff
    await new Promise(res => setTimeout(res, 500 * attempts));
  }
}

At minimum, please log the full error details so failed notifications can be diagnosed or resent. Thanks!

Nice work overall!

Copy link
Author

Choose a reason for hiding this comment

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

Hello, thanks for feedback, will do right away

@mauridev777 mauridev777 requested a review from VamshiVerma July 12, 2025 23:30
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.

2 participants