From 41e4c5e5a83f5ca84929becc2dcd84832a708d2c Mon Sep 17 00:00:00 2001 From: xNickyDev Date: Wed, 27 May 2026 17:09:25 +0200 Subject: [PATCH 1/4] Added category for posting announcements --- src/structs/Api.ts | 17 ++++++++++------- src/typings.ts | 3 +++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/structs/Api.ts b/src/structs/Api.ts index 0c3e4ec..8f336df 100644 --- a/src/structs/Api.ts +++ b/src/structs/Api.ts @@ -4,16 +4,17 @@ import { EventEmitter } from "events"; import { STATUS_CODES } from "http"; import type { - APIOptions, - Snowflake, - UserSource, - Project, - PartialVote, - PaginatedVotes, Announcement, + AnnouncementType, + APIOptions, Method, MetricsPayload, + PaginatedVotes, + PartialVote, + Project, ProjectPayload, + Snowflake, + UserSource, } from "../typings.js"; /** The API version to use */ @@ -222,16 +223,18 @@ export class Api extends EventEmitter { * * @param {string} title The announcement title. Must be between 3 and 100 characters. * @param {string} content The announcement body text. Must be between 10 and 2,000 characters. + * @param {AnnouncementType} category The category to publish the announcement under. Defaults to `announcement` when omitted. * @returns {Promise} The created announcement. */ public async postAnnouncement( title: string, content: string, + category?: AnnouncementType, ): Promise { const announcement = await this._request( "POST", "/projects/@me/announcements", - { title, content }, + { title, content, category }, ); return { diff --git a/src/typings.ts b/src/typings.ts index 8aafc6b..278c7f5 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -19,6 +19,9 @@ export type Platform = "discord" | "roblox"; /** A project's type */ export type ProjectType = "bot" | "server" | "game"; +/** An announcement's type */ +export type AnnouncementType = "announcement" | "event" | "new_feature"; + /** A locale for a project's payload */ export type Locale = | "en" From 0cad1974c31db3339cd8f903e5027fdc5cfa553b Mon Sep 17 00:00:00 2001 From: xNickyDev Date: Thu, 28 May 2026 20:39:53 +0200 Subject: [PATCH 2/4] Add query to payload, update postCommands method --- src/structs/Api.ts | 2 +- src/typings.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/structs/Api.ts b/src/structs/Api.ts index 8f336df..de9dc6d 100644 --- a/src/structs/Api.ts +++ b/src/structs/Api.ts @@ -199,7 +199,7 @@ export class Api extends EventEmitter { * @returns {Promise} */ public async postCommands(commands: APIApplicationCommand[]): Promise { - await this._request("POST", "/projects/@me/commands", commands); + await this._request("PUT", "/projects/@me/commands", commands); } /** diff --git a/src/typings.ts b/src/typings.ts index 278c7f5..b88996d 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -158,6 +158,8 @@ export interface VoteCreatePayload { expiresAt: Date; /** The project that received this vote */ project: PartialProject; + /** The parsed query parameters appended to the page URL */ + query: Record; /** The user who voted for this project */ user: User; } From 4ba8d115f4fb91270fe09ddae84d55899a63637f Mon Sep 17 00:00:00 2001 From: xNickyDev Date: Thu, 28 May 2026 20:53:03 +0200 Subject: [PATCH 3/4] Include query when formatting incoming data --- src/structs/Webhook.ts | 1 + src/typings.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/structs/Webhook.ts b/src/structs/Webhook.ts index a027f68..4b3aa7d 100644 --- a/src/structs/Webhook.ts +++ b/src/structs/Webhook.ts @@ -128,6 +128,7 @@ export class Webhook { votedAt: new Date(body.data.created_at), expiresAt: new Date(body.data.expires_at), project: this._formatPartialProject(body.data.project), + query: body.data.query, user: this._formatUser(body.data.user), } as VoteCreatePayload; diff --git a/src/typings.ts b/src/typings.ts index b88996d..f0db289 100644 --- a/src/typings.ts +++ b/src/typings.ts @@ -158,7 +158,7 @@ export interface VoteCreatePayload { expiresAt: Date; /** The project that received this vote */ project: PartialProject; - /** The parsed query parameters appended to the page URL */ + /** The parsed query parameters appended to the `/:id/vote` page URL */ query: Record; /** The user who voted for this project */ user: User; From ce9cc50f31b86883eae2389b5c3da1c145248258 Mon Sep 17 00:00:00 2001 From: xNickyDev Date: Thu, 28 May 2026 20:58:10 +0200 Subject: [PATCH 4/4] Update tests --- tests/mocks/data.ts | 4 ++++ tests/mocks/endpoints.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/mocks/data.ts b/tests/mocks/data.ts index 9e07920..e306bd7 100644 --- a/tests/mocks/data.ts +++ b/tests/mocks/data.ts @@ -195,6 +195,10 @@ export const VOTE_CREATE_PAYLOAD = { platform: "discord", platform_id: "160105994217586689" }, + query: { + key1: "value", + key2: "value2" + }, user: { id: "160105994217586689", platform_id: "160105994217586689", diff --git a/tests/mocks/endpoints.ts b/tests/mocks/endpoints.ts index e51e555..42ca401 100644 --- a/tests/mocks/endpoints.ts +++ b/tests/mocks/endpoints.ts @@ -47,7 +47,7 @@ export const endpoints: MockEndpoint[] = [ }, { pattern: "/api/v1/projects/@me/commands", - method: "POST", + method: "PUT", data: "" }, {