Skip to content

feat: add gateway webhooks - #106

Merged
RedStar071 merged 1 commit into
feat/channelsfrom
feat/webhooks
Sep 25, 2026
Merged

RedStar071 merged 1 commit into
feat/channelsfrom
feat/webhooks

Conversation

@RedStar071

Copy link
Copy Markdown
Member

Stacked on #105.

🔗 Linked issue

Related to #54 (phase 8b of the roadmap).

🧭 Context

There was no way to manage webhooks or post through one. The only webhook-related piece was the webhooksUpdate event.

📚 Description

Webhooks follow discord.js:

  • Webhook has every field, url and avatarURL, the isIncoming/isChannelFollower/isApplicationCreated checks, and send, edit, delete, fetchMessage, editMessage and deleteMessage.
  • client.webhooks is a new WebhookManager behind all of that, and client.fetchWebhook(id, token?) matches discord.js.
  • Text, announcement, voice, stage, forum and media channels get fetchWebhooks and createWebhook from a new ChannelWebhooksMixin. Guilds get fetchWebhooks, and announcement channels get addFollower.

Choices worth a look:

  • Token calls skip the bot's authorization (auth: false), like discord.js's WebhookClient, so they also work for other applications' webhooks. webhook.edit uses the token when there is one, except to move the webhook to another channel. Discord only allows that with the bot's authorization.
  • send waits for the message (?wait=true) and adds it through client.messages._add. It lands in the cache, and since it has a webhook_id, its author is not cached as a user (feat: resolve gateway structure relations through the cache with _add #102). threadId targets a thread of the webhook's channel (forum posts and threads).
  • Webhooks are not cached. The gateway only says that a channel's webhooks changed, so a cache would go stale unnoticed.

Key changes

Area Change
Structures Webhook; ChannelWebhooksMixin on six channel types; AnnouncementChannel#addFollower; Guild#fetchWebhooks
Managers WebhookManager (client.webhooks), client.fetchWebhook

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Workflow / CI change

Pre-flight Checklist

  • I have read the Contributing Guidelines (if applicable)
  • My code follows the code style of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly
  • I added a changeset with pnpm changeset (or pnpm changeset add --empty if no release is needed). See .changeset/README.md.

🤖 AI disclosure: Wolfstar Agent Kit modified this description. My AI open-source policy.

@coldtea-pr-lens

coldtea-pr-lens Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

◈ PR Lens

PR Lens paused analysis for this repository — the fair-use limit was reached. It resumes automatically at 2026-09-25T18:00:00.000Z.

@pkg-pr-new

pkg-pr-new Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@wolfstar/plugin-api

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-api@106

@wolfstar/plugin-cache

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-cache@106

@wolfstar/plugin-gateway

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-gateway@106

@wolfstar/plugin-i18next

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-i18next@106

@wolfstar/plugin-logger

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-logger@106

@wolfstar/plugin-subcommands-advanced

pnpm add https://pkg.pr.new/wolfstar-project/plugins/@wolfstar/plugin-subcommands-advanced@106

commit: 089378e

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No blocking issues found.

Reviewed changes

Reviewed the full diff of feat/webhooks (base feat/channels): a new Webhook structure, WebhookManager (client.webhooks), a ChannelWebhooksMixin applied to the six channel types that support webhooks, Guild#fetchWebhooks, AnnouncementChannel#addFollower, and the accompanying tests/docs/changeset.

  • Webhook structure — discord.js-parity fields (isIncoming/isChannelFollower/isApplicationCreated, url, avatarURL) plus send/edit/delete/fetchMessage/editMessage/deleteMessage, following the codebase's established this[kPatch](x.toJSON()) edit pattern.
  • WebhookManager — deliberately not a CachedManager (webhooks aren't cached, since the gateway only signals webhooksUpdate). Token-authenticated calls correctly skip bot authorization (auth: false), mirroring discord.js's WebhookClient. send/fetchMessage/editMessage route through MessageManager._add, which already skips caching a webhook's author as a user.
  • ChannelWebhooksMixin — fetchWebhooks/createWebhook on text, announcement, voice, stage, forum, and media channels, matching which channel types actually expose the webhook routes on Discord's side.
  • Guild#fetchWebhooks, AnnouncementChannel#addFollower — straightforward REST wrappers; addFollower's return value matches RESTPostAPIChannelFollowersResult's webhook_id field.

I traced the token vs. bot-auth branching between Webhook.edit()/delete() and WebhookManager's REST calls, the Routes.webhook/Routes.webhookMessage signatures, and the guild_id/channel_id/application_id nullability against discord-api-types' APIWebhook — all consistent with the PR description and Discord's actual API contracts. No correctness issues found.

ℹ️ Nitpicks

  • packages/plugin-gateway/tests/webhooks.test.ts covers create/fetch-channel, send+cache, edit (token vs. channel-move), the no-token throw, client.fetchWebhook with a token, and addFollower — but not WebhookManager.delete(), fetchMessage(), editMessage(), deleteMessage(), or Guild#fetchWebhooks(). Worth adding coverage for those before merge, since it's roughly half of the new public surface.
  • WebhookManager.delete(webhookId, { token, reason }) bundles token inside an options object, while sibling fetch(webhookId, token?) and edit(webhookId, options, token?) take it as a trailing positional parameter — a small inconsistency within the same file.
  • Webhook#sourceGuild/sourceChannel (packages/plugin-gateway/src/structures/Webhook.ts) lack explicit return-type annotations, unlike every other getter in the file.

Pullfrog  | View workflow run | Using Claude Sonnet | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

The new commit (6d70ef2) is a merge of feat/channels into feat/webhooks bringing in 3 unrelated files (ChannelManager.ts, util/channels.ts, channels.test.ts — base-branch changes, not part of this PR's webhook surface). The webhook-related diff is byte-identical to what was already reviewed in the prior review; nothing new to evaluate here.

Pullfrog  | View workflow run | Using Claude Sonnet | 𝕏

@pullfrog

pullfrog Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an ANTHROPIC_API_KEY repo secret — Pullfrog routes around an exhausted subscription automatically when one is present.

Add repo secret → · Model settings → · Setup docs → · Ask in Discord →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using Claude Sonnet | 𝕏

@pullfrog

pullfrog Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Your Claude subscription has hit its usage limit. It resets at 7:20pm (UTC). Re-trigger Pullfrog after the reset, or add an ANTHROPIC_API_KEY repo secret — Pullfrog routes around an exhausted subscription automatically when one is present.

Add repo secret → · Model settings → · Setup docs → · Ask in Discord →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using Claude Sonnet | 𝕏

@RedStar071
RedStar071 merged commit 6659e67 into main Sep 25, 2026
18 of 25 checks passed
@RedStar071
RedStar071 deleted the feat/webhooks branch September 25, 2026 18:02
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.

1 participant