cusdis
cusdis copied to clipboard
discord webhook?
any way to use discord webhook url to get comments approval in discord channel?
You can make your own webhook: https://cusdis.com/doc#/advanced/webhook
But we didn't provide an official webhook service yet
I copied the discord webhook url in cusdis, but it doesn't work. Do you have any instructions on how to do it?
I copied the discord webhook url in cusdis, but it doesn't work. Do you have any instructions on how to do it?
What webhook url? We only provide Telegram webhook for now.
I managed to set up Discord webhooks by modifying the service/webhook.service.ts
file. Comment out the axios.post
and create a new one following Discord's format. I used Discohook to help build the embed fields.
diff --git a/service/webhook.service.ts b/service/webhook.service.ts
index 3a77b29..d3b245f 100644
--- a/service/webhook.service.ts
+++ b/service/webhook.service.ts
@@ -64,6 +64,7 @@ export class WebhookService extends RequestScopeService {
})
try {
+ /*
axios.post(project.webhook, {
type: HookType.NewComment,
data: {
@@ -76,6 +77,21 @@ export class WebhookService extends RequestScopeService {
approve_link: approveLink,
},
} as HookBody<NewCommentHookData>)
+ */
+
+ axios.post(project.webhook, {
+ "content": comment.content.substr(0, 1500),
+ "username": comment.by_nickname,
+ "embeds": [
+ {
+ "color": null,
+ "fields": [
+ { "name": "Post", "value": fullComment.page.title },
+ { "name": "Links", "value": `[Approve](${approveLink})` }
+ ]
+ }
+ ]
+ });
} catch (e) {
}