diff --git a/src/structs/Api.ts b/src/structs/Api.ts index 0c3e4ec..de9dc6d 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 */ @@ -198,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); } /** @@ -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/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 8aafc6b..f0db289 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" @@ -155,6 +158,8 @@ export interface VoteCreatePayload { expiresAt: Date; /** The project that received this vote */ project: PartialProject; + /** The parsed query parameters appended to the `/:id/vote` page URL */ + query: Record; /** The user who voted for this project */ user: User; } 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: "" }, {