-
Notifications
You must be signed in to change notification settings - Fork 142
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
base: main
Are you sure you want to change the base?
Smart contract discord notifications #93
Conversation
….com/mauridev777/example-hub into smart-contract-discord-notifications
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.
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); |
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.
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!
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.
Hello, thanks for feedback, will do right away
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.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
Checklist: