Skip to content

Add Discord webhook adapter#196

Merged
orangecoding merged 5 commits intoorangecoding:masterfrom
maribowman:feature/initial-discord-adapter
Sep 27, 2025
Merged

Add Discord webhook adapter#196
orangecoding merged 5 commits intoorangecoding:masterfrom
maribowman:feature/initial-discord-adapter

Conversation

@maribowman
Copy link
Copy Markdown
Contributor

@maribowman maribowman commented Sep 26, 2025

  • Add Discord webhook
    • Send multiple Discord messages with up to 10 embeds* (listings) per message
    • Set embed color codes based on jobKey
  • Add Discord webhook markdown

*Discord only allows up to 10 embeds per message

image

Comment thread lib/notification/adapter/discord_webhook.js Outdated
const fields = [
{
name: 'Price',
value: listing.price,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

if for some reasons the values ever be null, discord will start spitting fire. We can make this safe by doing something like this:
String(listing.price ?? 'n/a')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f2bc27d

Comment thread lib/notification/adapter/discord_webhook.js
*/
const buildEmbed = (jobKey, listing) => {
const maxTitleLength = 252; // Max embed title length is 256 characters
let title = listing.title;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

In all your calls you're assuming that the values are actually there. That is however not for granted. E.g. listing.title can be null if some page changed their structure. This would lead to nullpointers in here,.

use this please:
let title = listing.title || 'N/A';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 32a1408

},
{
name: 'Size',
value: listing.size.replace(/2m/g, 'm²'),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

also size can be null..
listing?.size?.replace(/2m/g, 'm²') ?? 'N/A'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 32a1408

@orangecoding
Copy link
Copy Markdown
Owner

Thanks!

@orangecoding orangecoding merged commit d79f8d2 into orangecoding:master Sep 27, 2025
1 of 2 checks passed
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