Repository navigation
feat(plugin-gateway): add Message#threadable - #248
Merged
Merged
Conversation
|
Architecture Data flow ReviewNothing flagged · reviewed Tip Click the link under each diagram to open it on a canvas you can zoom, pan and step through 🪧 More tips
Thanks for using PR Lens! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: the full diff of the single commit adding Message#threadable.
Message#threadable: built likecrosspostable(cache-only,CacheRead<boolean>, sameChannelUncached/GuildUncachedMe/GuildUncachedbehaviour),falseforHasThreador non-guild messages, and limited to text and announcement channels withViewChannelandCreatePublicThreads.- Variadic
hasCachedPermission: now true only when the bot has every listed permission. The existing single-permission callers behave as before. - Tests, type check, README, changeset: sync and async-cache cases, the administrator divergence from discord.js, and a minor changeset.
The one pending item is already in the PR description: discord.js#11500 is still a draft, so re-check it before merging.
claude-sonnet-5-5 | 𝕏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🔗 Linked issue
Closes #184
🧭 Context
Messagein@wolfstar/plugin-gatewayports discord.js's permission getters (editable,deletable,bulkDeletable,pinnable,crosspostable) but has nothreadable, the one that tells whether the bot can start a thread from a message. Upstream is discord.js#11500, which is still a draft with changes requested.📚 Description
Adds
Message#threadable, built likecrosspostable: it reads the cache only, so it is a plain boolean with a synchronous cache and a promise with an asynchronous one. It isfalsefor a message that already has a thread (HasThreadflag) or that is outside a guild. Otherwise it needs the channel in the cache (ChannelUncachedon a miss), of type text or announcement, and the bot must haveViewChannelandCreatePublicThreadsthere (GuildUncachedMe/GuildUncachedon a miss, as for the sibling getters).Decisions, following the maintainer's go-ahead on Pullfrog's plan:
checkAdmin = false, so an administrator without an explicitCreatePublicThreadsis not threadable. Here the defaultpermissions.has("CreatePublicThreads")is used, because the API lets administrators create threads and the getter answers "can the client start a thread here". The TSDoc, the changeset and a test say so.viewablegetter:ViewChannelis checked inline throughhasCachedPermission.fetchThreadable()twin (the existingfetch*twins are@deprecated, so a new one would add deprecated API). The async-cache test asserts the values directly.hasCachedPermissionnow takes several permissions (true when the bot has all of them), soViewChannelandCreatePublicThreadscost one member and permission read instead of two.Before merging: discord.js#11500 is a draft. Re-check it for shape or semantics changes, and hold this PR if they change.
Key changes
packages/plugin-gateway/src/structures/messages/Message.ts: newthreadablegetter;hasCachedPermissionaccepts several permissions.packages/plugin-gateway/tests/sync-getters.test.ts: DM,HasThread, thread channel, voice channel, text and announcement with and withoutCreatePublicThreads, administrator bot,ChannelUncached,GuildUncachedMe, and the asynchronous-cache promise form.packages/plugin-gateway/tests/types/sync-getters.ts:message.threadableinmessageChecks.packages/plugin-gateway/README.md:threadableadded to the list of discord.js getters..changeset/gateway-message-threadable.md: minor bump for@wolfstar/plugin-gateway.Verification (run locally):
pnpm build,pnpm typecheckandpnpm test(121 files, 1721 tests) pass.pnpm lintpassesoxlint(pre-existing warnings only);oxfmt --checkreports every file on my Windows checkout because the working tree has CRLF line endings, unrelated to this change. The files I touched were formatted by theoxfmtpre-commit hook.Type of Change
Pre-flight Checklist
pnpm changeset(orpnpm changeset add --emptyif no release is needed). See .changeset/README.md.