Discord webhooks - #69
Conversation
CreedsCode
commented
Feb 20, 2024


|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| embeds: [embed], | ||
| }; | ||
|
|
||
| fetch(webhookDetails?.discordWebhook, { |
There was a problem hiding this comment.
it would be good to seperate the preparation of the content and the fetch to not duplicate the whole part here and add some more strict typing
| // }, | ||
| }; | ||
|
|
||
| const payload = { |
| cover String? | ||
| customDomain String? @unique | ||
| icon String? | ||
| discordWebhook String? @default("") |
There was a problem hiding this comment.
You also need to generate your db migration
| }; | ||
|
|
||
|
|
||
| export const getDiscordWebhookDetailsByBuilderPlaceId = async (id: string) => { |
There was a problem hiding this comment.
for maintanability, i think it's good to not create a new get function everytime we want some info on a BP. We can use a single getById that returns all the datas
| let errorMessage; | ||
| try { | ||
|
|
||
| if (builderPlace.discordWebhook != "" && builderPlace.discordWebhook != undefined) { |
There was a problem hiding this comment.
2 things here:
- both conditon are falsy, so just do: if (builderPlace.discordWebhook)
- it's better to move this check logical inside your function, else you have to duplicate it everywhere we need to use it
|
|
||
|
|
||
| export const sendNewServiceNotification = async (builderPlaceId: string, serviceId: string, cid: string) => { | ||
| const service: { title: string, about: string, keywords: string, rateToken: string, rateAmount: string } = await readFromIPFS(cid); |
There was a problem hiding this comment.
in term of architecture, we now make any create service API post success depending on an IPFS call, and discord call. This is not good for maintability. Would be better to imagine something non bloquant with a message broker by example. Any suggestion?
| }, | ||
| { | ||
| name: "Budget", | ||
| value: `${(Number(service.rateAmount) / Math.pow(10, token.decimals)).toString()} ${token.symbol}`, |
There was a problem hiding this comment.
i could not find one, i tried searching the code base for "Math.pow" and nothing come up.