Star
Packages ยท Chat

@notifkit/provider-discord

The Discord transport. Posts to channels through incoming webhooks, with custom display names, avatars and embeds, and prunes dead webhooks automatically.

npm install @notifkit/provider-discord
import { NotifkitServer } from "notifkit";
import { DiscordTransport } from "@notifkit/provider-discord";

const server = new NotifkitServer({
  services: ["all"],
  providers: [new DiscordTransport()],
});

Getting a Webhook URL

In Discord: Edit Channel → Integrations → Webhooks → New Webhook, then copy the URL and store it as the recipient's contact target:

await notifkit.addContact("channel_ops", {
  channel: "discord",
  target: "https://discord.com/api/webhooks/123456789012345678/abcdef...",
});

Template keys & Rich Embeds

Template keyLands as
text or bodyMessage content text.
usernameOverride the webhook's sender display name per template.
avatarUrlOverride the webhook's avatar image URL per template.
embedsArray of Discord embed objects (title, description, color, fields, timestamp).
await notifkit.syncTemplates({
  templates: [
    {
      id: "build-status",
      channel: "discord",
      content: {
        username: "DeployBot",
        avatarUrl: "https://example.com/deploybot.png",
        text: "Build finished for **{{repo}}**",
        embeds: [
          {
            title: "Build #{{buildId}} Passed",
            color: 0x22c55e,
            fields: [
              { name: "Branch", value: "{{branch}}", inline: true },
              { name: "Duration", value: "{{duration}}", inline: true },
            ],
          },
        ],
      },
    },
  ],
});
Dead webhook detection

If Discord returns 404 or 401 because a webhook was deleted or changed, notifkit marks the target invalid and stops delivering to that URL.