Skip to content

fix(channel): start a thread in a forum without throwing - #14

Merged
mikield merged 1 commit into
masterfrom
fix/start-thread-in-forum-channel
Sep 2, 2026
Merged

mikield merged 1 commit into
masterfrom
fix/start-thread-in-forum-channel

Conversation

@mikield

@mikield mikield commented Sep 2, 2026

Copy link
Copy Markdown
Member

startThreadInForumChannel() has never worked. Any call dies before it reaches the network:

Too few arguments to function Tempcord\Discord\Rest\HttpResource::__construct(),
0 passed in src/Rest/Channel.php on line 709 and exactly 3 expected

The method built its return type as an anonymous class:

$forumChannelWithMessage = new class () extends Channel {
    public Message $message;
};

Inside Rest\Channel, the bare name Channel is that class itself — Parts\Channel is imported under the alias PartsChannel. So the anonymous class extended the REST resource, whose constructor takes three arguments, and instantiating it threw immediately.

No test referenced the method, which is how it stayed broken. There is one now.

Parts\ForumThread

The type it was reaching for is now a real part rather than an anonymous class. This is the only call where Discord answers with a channel that carries a message, and that message is what reactions and edits on the post address — so it is worth a name. It also means a caller can be typed against it: an anonymous class cannot be referenced from outside the method, so static analysis flagged every use of ->message as an undefined property and the only way through was a cast.

Found while porting a bot whose petitions are forum posts that members vote on with reactions.

🤖 Generated with Claude Code

startThreadInForumChannel() has never worked. It built its return type
as an anonymous class extending Channel — but inside Rest\Channel the
bare name is that class itself, since Parts\Channel is imported under an
alias. So it extended the REST resource, whose constructor takes three
arguments, and every call died on "Too few arguments" before reaching
the network.

The type it wanted is now a real part. Discord answers this one call
with the opening message attached, which is what reactions and edits on
the post address, so it is worth a name rather than a cast — and a
caller can now be typed against it, which an anonymous class never
allowed.

No test referenced the method, which is how it stayed broken.
@mikield
mikield merged commit 6bae9fc into master Sep 2, 2026
4 checks passed
@mikield
mikield deleted the fix/start-thread-in-forum-channel branch September 2, 2026 02:23
github-actions Bot pushed a commit that referenced this pull request Sep 2, 2026
## [1.3.1](v1.3.0...v1.3.1) (2026-09-02)

### Bug Fixes

* **channel:** start a thread in a forum without throwing ([#14](#14)) ([6bae9fc](6bae9fc))
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.3.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant