diff --git a/src/Parts/ForumThread.php b/src/Parts/ForumThread.php new file mode 100644 index 0000000..aeda9bc --- /dev/null +++ b/src/Parts/ForumThread.php @@ -0,0 +1,20 @@ + includes $message property + * @return PromiseInterface<\Tempcord\Discord\Parts\ForumThread> the post, with + * the opening message Discord answers with attached */ public function startThreadInForumChannel( string $channelId, MultipartBody|array $params, ?string $reason = null ): PromiseInterface { - $forumChannelWithMessage = new class () extends Channel { - public Message $message; - }; - return $this->mapPromise( $this->http->post( Endpoint::bind(Endpoint::CHANNEL_THREADS, $channelId), $params, $this->getAuditLogReasonHeader($reason), ), - $forumChannelWithMessage::class, + ForumThread::class, ); } diff --git a/tests/Rest/ChannelTest.php b/tests/Rest/ChannelTest.php index f0bce73..457151b 100644 --- a/tests/Rest/ChannelTest.php +++ b/tests/Rest/ChannelTest.php @@ -5,6 +5,7 @@ namespace Tests\Tempcord\Discord\Rest; use Tempcord\Discord\Parts\ArchivedThreads; +use Tempcord\Discord\Parts\ForumThread; use Tempcord\Discord\Parts\Channel as PartsChannel; use Tempcord\Discord\Parts\Invite; use Tempcord\Discord\Parts\Message; @@ -204,6 +205,20 @@ public static function httpBindingsProvider(): array 'returnType' => PartsChannel::class, ] ], + 'Start thread in forum channel' => [ + 'method' => 'startThreadInForumChannel', + 'args' => ['::channel id::', ['name' => '::post::', 'message' => ['content' => '::text::']]], + 'mockOptions' => [ + 'method' => 'post', + 'return' => (object) [ + 'id' => '::thread id::', + 'message' => (object) ['id' => '::message id::'], + ], + ], + 'validationOptions' => [ + 'returnType' => ForumThread::class, + ] + ], 'Delete channel' => [ 'method' => 'delete', 'args' => ['::channel id::'],