From 520793ec383a0bca646acbe6d52292bc20d85097 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Fri, 10 May 2024 19:18:17 -0700 Subject: [PATCH] implement forum search --- src/forum/index.ts | 10 ++++++++++ src/forum/types.ts | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/forum/index.ts b/src/forum/index.ts index a997263..1d38966 100644 --- a/src/forum/index.ts +++ b/src/forum/index.ts @@ -56,4 +56,14 @@ export class ForumModule extends Module { } ); } + + public async search(query: string) { + return await this.client._call( + TCResponse, + "forum.search", + { + query, + } + ); + } } diff --git a/src/forum/types.ts b/src/forum/types.ts index 05f713f..923cc12 100644 --- a/src/forum/types.ts +++ b/src/forum/types.ts @@ -17,6 +17,16 @@ export class ViewPostsResponse extends TCResponse { } } +export class ForumSearchResponse extends TCResponse { + results: SearchResult[]; + + public constructor(response: TCResponseRaw) { + super(response); + + this.results = response["results"]; + } +} + export interface Post { readonly id: number; readonly user: string; @@ -32,3 +42,12 @@ export interface Thread { // TODO: add category //readonly category } + +export interface SearchResult { + readonly id: number; + readonly author: string; + readonly text: string; + readonly time: number; + readonly category: string; + readonly thread: number; +}