diff --git a/.changeset/violet-fireants-brake.md b/.changeset/violet-fireants-brake.md new file mode 100644 index 00000000..e4fd6d39 --- /dev/null +++ b/.changeset/violet-fireants-brake.md @@ -0,0 +1,5 @@ +--- +"@guildedjs/guilded-api-typings": major +--- + +feat: start migration to using openapi schemas diff --git a/.config/.eslintignore b/.config/.eslintignore index 7def504f..a85fde41 100644 --- a/.config/.eslintignore +++ b/.config/.eslintignore @@ -7,4 +7,6 @@ *.d.ts packages/**/*.js +packages/guilded-api-typings/lib/v1/rest.ts +packages/guilded-api-typings/lib/v1/ws.ts apps/**/*.js diff --git a/.config/.eslintrc.js b/.config/.eslintrc.js index a9f1e0a0..b40f8c4d 100644 --- a/.config/.eslintrc.js +++ b/.config/.eslintrc.js @@ -11,8 +11,11 @@ module.exports = { "@typescript-eslint/no-var-requires": "off", "@typescript-eslint/explicit-function-return-type": "error", "@typescript-eslint/explicit-member-accessibility": "off", - "@typescript-eslint/promise-function-async": "off", "@typescript-eslint/no-invalid-this": "off", + "@typescript-eslint/promise-function-async": "off", + "jsdoc/multiline-blocks": "off", + "jsdoc/newline-after-description": "off", + "typescript-sort-keys/interface": "off", "@typescript-eslint/lines-between-class-members": [ "warn", "always", @@ -31,6 +34,7 @@ module.exports = { "no-restricted-globals": "off", "n/prefer-global/process": "off", "no-promise-executor-return": "off", + "jsdoc/no-undefined-types": "off", }, overrides: [ { diff --git a/packages/gil/lib/BotClient.ts b/packages/gil/lib/BotClient.ts index fb1bca08..325cb17f 100644 --- a/packages/gil/lib/BotClient.ts +++ b/packages/gil/lib/BotClient.ts @@ -12,435 +12,476 @@ import type Task from "./structures/Task"; import { walk } from "./utils/walk"; export class BotClient extends Client { - /** - * All your bot's monitors will be available here - */ - monitors = new Collection(); - - /** - * All your bot's commands will be available here - */ - commands = new Collection(); - - /** - * All your bot's arguments will be available here - */ - arguments = new Collection(); - - /** - * All your bot's inhibitors will be available here - */ - inhibitors = new Collection(); - - /** - * All your bot's tasks will be available here - */ - tasks = new Collection(); - - /** - * The bot's prefixes per server. - */ - prefixes = new Map(); - - /** - * The message collectors that are pending. - */ - messageCollectors = new Collection(); - - /** - * The path that the end users commands,monitors, inhibitors and others will be located. - */ - sourceFolderPath = this.options.sourceFolderPath ?? path.join(process.cwd(), "src/"); - - constructor(public options: BotClientOptions, autoInit = true) { - super(options); - if (autoInit) void this.init(); - } - - /** - * Get the default client prefix. - */ - get prefix(): string { - return this.options.prefix; - } - - /** - * Get the bot's mention. Guilded api does not provide a way to dynamically detect this so for now its manual. - */ - get botMention(): string | undefined { - return this.options.botMention; - } - - async loadFile(result: any, dir: string, collection: Collection): Promise { - const [filename, file] = result; - const { name } = path.parse(filename); - const piece = file.default ? new file.default(this, name) : new file(this, name); - - let cmd: Command | undefined; - if (dir === "commands" && piece.parentCommand) { - const subcommandNames = piece.parentCommand.split("-"); - for (const subname of subcommandNames) { - // LOOK FOR MAIN COMMAND - if (!cmd) { - const mainCmd = collection.get(subname); - if (mainCmd) { - cmd = mainCmd as Command; - continue; - } else { - throw new Error( - `You tried to create a subcommand named ${piece.name}. However, the parent command, ${subname}, was not found.`, - ); - } - } - - const subcmd = cmd?.subcommands?.get(subname) as Command; - if (subcmd) { - cmd = subcmd; - } else { - throw new Error( - `You tried to create a subcommand named ${piece.name} inside the main command ${cmd.name}. However, the parent command, ${subname}, was not found.`, - ); - } - } + /** + * All your bot's monitors will be available here + */ + monitors = new Collection(); + + /** + * All your bot's commands will be available here + */ + commands = new Collection(); + + /** + * All your bot's arguments will be available here + */ + arguments = new Collection(); + + /** + * All your bot's inhibitors will be available here + */ + inhibitors = new Collection(); + + /** + * All your bot's tasks will be available here + */ + tasks = new Collection(); + + /** + * The bot's prefixes per server. + */ + prefixes = new Map(); + + /** + * The message collectors that are pending. + */ + messageCollectors = new Collection(); + + /** + * The path that the end users commands,monitors, inhibitors and others will be located. + */ + sourceFolderPath = + this.options.sourceFolderPath ?? path.join(process.cwd(), "src/"); + + constructor(public options: BotClientOptions, autoInit = true) { + super(options); + if (autoInit) void this.init(); + } + + /** + * Get the default client prefix. + */ + get prefix(): string { + return this.options.prefix; + } + + /** + * Get the bot's mention. Guilded api does not provide a way to dynamically detect this so for now its manual. + */ + get botMention(): string | undefined { + return this.options.botMention; + } + + async loadFile( + result: any, + dir: string, + collection: Collection + ): Promise { + const [filename, file] = result; + const { name } = path.parse(filename); + const piece = file.default + ? new file.default(this, name) + : new file(this, name); + + let cmd: Command | undefined; + if (dir === "commands" && piece.parentCommand) { + const subcommandNames = piece.parentCommand.split("-"); + for (const subname of subcommandNames) { + // LOOK FOR MAIN COMMAND + if (!cmd) { + const mainCmd = collection.get(subname); + if (mainCmd) { + cmd = mainCmd as Command; + continue; + } else { + throw new Error( + `You tried to create a subcommand named ${piece.name}. However, the parent command, ${subname}, was not found.` + ); + } } - if (cmd) { - if (!cmd.subcommands) cmd.subcommands = new Collection(); - cmd.subcommands.set(piece.name ?? name, piece); + const subcmd = cmd?.subcommands?.get(subname) as Command; + if (subcmd) { + cmd = subcmd; } else { - collection.set(piece.name ?? name, piece); + throw new Error( + `You tried to create a subcommand named ${piece.name} inside the main command ${cmd.name}. However, the parent command, ${subname}, was not found.` + ); } - - if (piece.init) await piece.init(); + } } - /** - * Prepares the bot to run. Ideally used for loading files to the bot. - */ - async init(): Promise { - await Promise.allSettled( - [ - ["monitors", this.monitors] as const, - ["commands", this.commands] as const, - ["arguments", this.arguments] as const, - ["inhibitors", this.inhibitors] as const, - ["tasks", this.tasks] as const, - ].map(async ([dir, collection]) => { - try { - for await (const result of walk(path.join(__dirname, dir))) { - await this.loadFile(result, dir, collection); - } - } catch (error) { - console.log(error); - } - }), - ).catch(() => null); - - // Load all end user files - await Promise.allSettled( - [ - ["monitors", this.monitors] as const, - ["commands", this.commands] as const, - ["arguments", this.arguments] as const, - ["inhibitors", this.inhibitors] as const, - ["tasks", this.tasks] as const, - ].map(async ([dir, collection]) => { - try { - for await (const result of walk(this.options.monitorDirPath ?? path.join(this.sourceFolderPath, dir))) { - await this.loadFile(result, dir, collection); - } - } catch (error) { - console.log(error); - } - }), - ).catch(() => null); - - this.initializeMessageListener(); - this.initializeTasks(); + if (cmd) { + if (!cmd.subcommands) cmd.subcommands = new Collection(); + cmd.subcommands.set(piece.name ?? name, piece); + } else { + collection.set(piece.name ?? name, piece); } - /** - * Allows users to override and customize the addition of a event listener - */ - initializeMessageListener(): void { - this.on("messageCreated", (message) => this.processMonitors(message)); - } - - /** - * Allows users to override and customize the initialization of scheduled task intervals. - */ - initializeTasks(): void { - this.tasks.forEach(async (task) => { - // TASKS THAT NEED TO RUN IMMEDIATELY ARE EXECUTED FIRST - if (task.runOnStartup) await this.executeTask(task); - - // SET TIMEOUT WILL DETERMINE THE RIGHT TIME TO RUN THE TASK FIRST TIME AFTER STARTUP - setTimeout(async () => { - await this.executeTask(task); - - setInterval(async () => { - await this.executeTask(task); - }, task.millisecondsInterval); - }, Date.now() % task.millisecondsInterval); - }); - } - - /** - * Handler to execute a task when it is time. - */ - async executeTask(task: Task): Promise { - // IF TASK REQUIRES BOT BEING FULLY READY EXIT OUT IF BOT ISN'T READY - if (task.requireReady && !this.readyTimestamp) return; - - console.log(`${bgBlue(`[${this.getTime()}]`)} [TASK: ${bgYellow(black(task.name))}] started.`); - const started = Date.now(); + if (piece.init) await piece.init(); + } + + /** + * Prepares the bot to run. Ideally used for loading files to the bot. + */ + async init(): Promise { + await Promise.allSettled( + [ + ["monitors", this.monitors] as const, + ["commands", this.commands] as const, + ["arguments", this.arguments] as const, + ["inhibitors", this.inhibitors] as const, + ["tasks", this.tasks] as const, + ].map(async ([dir, collection]) => { try { - await task.execute(); - console.log( - `${bgBlue(`[${this.getTime()}]`)} [TASK: ${bgGreen(black(task.name))}] executed in ${this.humanizeMilliseconds( - Date.now() - started, - )}.`, - ); + for await (const result of walk(path.join(__dirname, dir))) { + await this.loadFile(result, dir, collection); + } } catch (error) { - console.log(error); - } - } - - /** - * Handler that is run on messages and can - */ - processMonitors(message: Message): void { - for (const [id, monitor] of this.monitors) { - if (monitor.ignoreBots && (message.createdByBotId ?? message.createdByWebhookId)) continue; - if (monitor.ignoreOthers && message.createdByBotId !== this.user?.botId) continue; - if (monitor.ignoreEdits && message.updatedAt && message.updatedAt !== message.createdAt) continue; - // TODO: When the api supports using dm channels - // if (monitor.ignoreDM && !message.serverId) return; - void monitor.execute(message); + console.log(error); } - } - - /** - * Converts a number of milliseconds to a easy to read format(1d2h3m). - */ - humanizeMilliseconds(milliseconds: number): string { - // Gets ms into seconds - const time = milliseconds / 1_000; - if (time < 1) return "1s"; - - const days = Math.floor(time / 86_400); - const hours = Math.floor((time % 86_400) / 3_600); - const minutes = Math.floor(((time % 86_400) % 3_600) / 60); - const seconds = Math.floor(((time % 86_400) % 3_600) % 60); - - const dayString = days ? `${days}d ` : ""; - const hourString = hours ? `${hours}h ` : ""; - const minuteString = minutes ? `${minutes}m ` : ""; - const secondString = seconds ? `${seconds}s ` : ""; - - return `${dayString}${hourString}${minuteString}${secondString}`; - } - - /** - * Converts a text form(1d2h3m) of time to a number in milliseconds. - */ - stringToMilliseconds(text: string): number | undefined { - const matches = text.match(/(\d+[dhmsw|])/g); - if (!matches) return; - - let total = 0; - - for (const match of matches) { - // Finds the first of these letters - const validMatch = /([dhmsw])/.exec(match); - // if none of them were found cancel - if (!validMatch) return; - // Get the number which should be before the index of that match - const number = match.slice(0, Math.max(0, validMatch.index)); - // Get the letter that was found - const [letter] = validMatch; - if (!number ?? !letter) return; - - let multiplier = 1_000; - switch (letter.toLowerCase()) { - case `w`: - multiplier = 1_000 * 60 * 60 * 24 * 7; - break; - case `d`: - multiplier = 1_000 * 60 * 60 * 24; - break; - case `h`: - multiplier = 1_000 * 60 * 60; - break; - case `m`: - multiplier = 1_000 * 60; - break; - } - - const amount = number ? Number.parseInt(number, 10) : undefined; - if (!amount && amount !== 0) return; - - total += amount * multiplier; + }) + ).catch(() => null); + + // Load all end user files + await Promise.allSettled( + [ + ["monitors", this.monitors] as const, + ["commands", this.commands] as const, + ["arguments", this.arguments] as const, + ["inhibitors", this.inhibitors] as const, + ["tasks", this.tasks] as const, + ].map(async ([dir, collection]) => { + try { + for await (const result of walk( + this.options.monitorDirPath ?? path.join(this.sourceFolderPath, dir) + )) { + await this.loadFile(result, dir, collection); + } + } catch (error) { + console.log(error); } - - return total; + }) + ).catch(() => null); + + this.initializeMessageListener(); + this.initializeTasks(); + } + + /** + * Allows users to override and customize the addition of a event listener + */ + initializeMessageListener(): void { + this.on("messageCreated", (message) => this.processMonitors(message)); + } + + /** + * Allows users to override and customize the initialization of scheduled task intervals. + */ + initializeTasks(): void { + this.tasks.forEach(async (task) => { + // TASKS THAT NEED TO RUN IMMEDIATELY ARE EXECUTED FIRST + if (task.runOnStartup) await this.executeTask(task); + + // SET TIMEOUT WILL DETERMINE THE RIGHT TIME TO RUN THE TASK FIRST TIME AFTER STARTUP + setTimeout(async () => { + await this.executeTask(task); + + setInterval(async () => { + await this.executeTask(task); + }, task.millisecondsInterval); + }, Date.now() % task.millisecondsInterval); + }); + } + + /** + * Handler to execute a task when it is time. + */ + async executeTask(task: Task): Promise { + // IF TASK REQUIRES BOT BEING FULLY READY EXIT OUT IF BOT ISN'T READY + if (task.requireReady && !this.readyTimestamp) return; + + console.log( + `${bgBlue(`[${this.getTime()}]`)} [TASK: ${bgYellow( + black(task.name) + )}] started.` + ); + const started = Date.now(); + try { + await task.execute(); + console.log( + `${bgBlue(`[${this.getTime()}]`)} [TASK: ${bgGreen( + black(task.name) + )}] executed in ${this.humanizeMilliseconds(Date.now() - started)}.` + ); + } catch (error) { + console.log(error); } - - /** - * Request some message(s) from a user in a channel. - */ - async needMessage(userId: string, channelId: string, options?: MessageCollectorOptions & { amount?: 1 }): Promise; - async needMessage(userId: string, channelId: string, options: MessageCollectorOptions & { amount?: number }): Promise; - async needMessage(userId: string, channelId: string, options?: MessageCollectorOptions): Promise { - const messages = await this.collectMessages({ - key: userId, - channelId, - createdAt: Date.now(), - filter: options?.filter ?? ((msg): boolean => userId === msg.createdById), - amount: options?.amount ?? 1, - // DEFAULTS TO 5 MINUTES - duration: options?.duration ?? 300_000, - }); - - return (options?.amount ?? 1) > 1 ? messages : messages[0]; + } + + /** + * Handler that is run on messages and can + */ + processMonitors(message: Message): void { + for (const [id, monitor] of this.monitors) { + if (monitor.ignoreBots && message.createdByWebhookId) continue; + if (monitor.ignoreOthers && message.authorId !== this.user?.botId) + continue; + if ( + monitor.ignoreEdits && + message.updatedAt && + message.updatedAt !== message.createdAt + ) + continue; + // TODO: When the api supports using dm channels + // if (monitor.ignoreDM && !message.serverId) return; + void monitor.execute(message); } - - /** - * Handler that will create a collecetor internally. Users should be using needMessage. - */ - async collectMessages(options: CollectMessagesOptions): Promise { - return new Promise((resolve, reject) => { - this.messageCollectors.get(options.key)?.reject("A new collector began before the user responded to the previous one."); - - this.messageCollectors.set(options.key, { - ...options, - messages: [], - resolve, - reject, - }); - }); + } + + /** + * Converts a number of milliseconds to a easy to read format(1d2h3m). + */ + humanizeMilliseconds(milliseconds: number): string { + // Gets ms into seconds + const time = milliseconds / 1_000; + if (time < 1) return "1s"; + + const days = Math.floor(time / 86_400); + const hours = Math.floor((time % 86_400) / 3_600); + const minutes = Math.floor(((time % 86_400) % 3_600) / 60); + const seconds = Math.floor(((time % 86_400) % 3_600) % 60); + + const dayString = days ? `${days}d ` : ""; + const hourString = hours ? `${hours}h ` : ""; + const minuteString = minutes ? `${minutes}m ` : ""; + const secondString = seconds ? `${seconds}s ` : ""; + + return `${dayString}${hourString}${minuteString}${secondString}`; + } + + /** + * Converts a text form(1d2h3m) of time to a number in milliseconds. + */ + stringToMilliseconds(text: string): number | undefined { + const matches = text.match(/(\d+[dhmsw|])/g); + if (!matches) return; + + let total = 0; + + for (const match of matches) { + // Finds the first of these letters + const validMatch = /([dhmsw])/.exec(match); + // if none of them were found cancel + if (!validMatch) return; + // Get the number which should be before the index of that match + const number = match.slice(0, Math.max(0, validMatch.index)); + // Get the letter that was found + const [letter] = validMatch; + if (!number ?? !letter) return; + + let multiplier = 1_000; + switch (letter.toLowerCase()) { + case `w`: + multiplier = 1_000 * 60 * 60 * 24 * 7; + break; + case `d`: + multiplier = 1_000 * 60 * 60 * 24; + break; + case `h`: + multiplier = 1_000 * 60 * 60; + break; + case `m`: + multiplier = 1_000 * 60; + break; + } + + const amount = number ? Number.parseInt(number, 10) : undefined; + if (!amount && amount !== 0) return; + + total += amount * multiplier; } - /** - * Get a clean string form of the current time. For example: 12:00PM - */ - getTime(): string { - const now = new Date(); - const hours = now.getHours(); - const minute = now.getMinutes(); - - let hour = hours; - let amOrPm = `AM`; - if (hour > 12) { - amOrPm = `PM`; - hour -= 12; - } + return total; + } + + /** + * Request some message(s) from a user in a channel. + */ + async needMessage( + userId: string, + channelId: string, + options?: MessageCollectorOptions & { amount?: 1 } + ): Promise; + async needMessage( + userId: string, + channelId: string, + options: MessageCollectorOptions & { amount?: number } + ): Promise; + async needMessage( + userId: string, + channelId: string, + options?: MessageCollectorOptions + ): Promise { + const messages = await this.collectMessages({ + key: userId, + channelId, + createdAt: Date.now(), + filter: options?.filter ?? ((msg): boolean => userId === msg.createdById), + amount: options?.amount ?? 1, + // DEFAULTS TO 5 MINUTES + duration: options?.duration ?? 300_000, + }); + + return (options?.amount ?? 1) > 1 ? messages : messages[0]; + } + + /** + * Handler that will create a collecetor internally. Users should be using needMessage. + */ + async collectMessages(options: CollectMessagesOptions): Promise { + return new Promise((resolve, reject) => { + this.messageCollectors + .get(options.key) + ?.reject( + "A new collector began before the user responded to the previous one." + ); - return `${hour >= 10 ? hour : `0${hour}`}:${minute >= 10 ? minute : `0${minute}`} ${amOrPm}`; + this.messageCollectors.set(options.key, { + ...options, + messages: [], + resolve, + reject, + }); + }); + } + + /** + * Get a clean string form of the current time. For example: 12:00PM + */ + getTime(): string { + const now = new Date(); + const hours = now.getHours(); + const minute = now.getMinutes(); + + let hour = hours; + let amOrPm = `AM`; + if (hour > 12) { + amOrPm = `PM`; + hour -= 12; } - /** - * Handler that is executed when a user is using a command too fast and goes into cooldown. Override this to customize the behavior. - */ - async cooldownReached(message: Message, command: Command, options: RespondToCooldownOption): Promise { - return message.reply( - `You must wait **${this.humanizeMilliseconds(options.cooldown.timestamp - options.now)}** before using the *${ - command.fullName - }* command again.`, - ); - } + return `${hour >= 10 ? hour : `0${hour}`}:${ + minute >= 10 ? minute : `0${minute}` + } ${amOrPm}`; + } + + /** + * Handler that is executed when a user is using a command too fast and goes into cooldown. Override this to customize the behavior. + */ + async cooldownReached( + message: Message, + command: Command, + options: RespondToCooldownOption + ): Promise { + return message.reply( + `You must wait **${this.humanizeMilliseconds( + options.cooldown.timestamp - options.now + )}** before using the *${command.fullName}* command again.` + ); + } } // export interface BotClientOptions extends ClientOptions { export type BotClientOptions = { - /** - * The bot mention. Most likely @botname This is required as Guilded does not currently give any way to dynamically detect the mention. - */ - botMention?: string; - /** - * The path to a custom dir where commands are located. - */ - commandDirPath?: string; - /** - * The path to a custom dir where the inhibitors are located - */ - inhibitorDirPath?: string; - /** - * The path to a custom dir where the monitors are located - */ - monitorDirPath?: string; - /** - * The prefix that will be used to determine if a message is executing a command. - */ - prefix: string; - /** - * The path that the end users commands, monitors, inhibitors and others will be located. - */ - sourceFolderPath?: string; - // TODO: THESE ARE REMOVED WHEN EXTENDS IS fixed - token: string; + /** + * The bot mention. Most likely @botname This is required as Guilded does not currently give any way to dynamically detect the mention. + */ + botMention?: string; + /** + * The path to a custom dir where commands are located. + */ + commandDirPath?: string; + /** + * The path to a custom dir where the inhibitors are located + */ + inhibitorDirPath?: string; + /** + * The path to a custom dir where the monitors are located + */ + monitorDirPath?: string; + /** + * The prefix that will be used to determine if a message is executing a command. + */ + prefix: string; + /** + * The path that the end users commands, monitors, inhibitors and others will be located. + */ + sourceFolderPath?: string; + // TODO: THESE ARE REMOVED WHEN EXTENDS IS fixed + token: string; }; export type MessageCollectorOptions = { - /** - * The amount of messages to collect before resolving. Defaults to 1 - */ - amount?: number; - /** - * The amount of milliseconds this should collect for before expiring. Defaults to 5 minutes. - */ - duration?: number; - /** - * Function that will filter messages to determine whether to collect this message. Defaults to making sure the message is sent by the same member. - */ - filter?(message: Message): boolean; + /** + * The amount of messages to collect before resolving. Defaults to 1 + */ + amount?: number; + /** + * The amount of milliseconds this should collect for before expiring. Defaults to 5 minutes. + */ + duration?: number; + /** + * Function that will filter messages to determine whether to collect this message. Defaults to making sure the message is sent by the same member. + */ + filter?(message: Message): boolean; }; export type CollectMessagesOptions = { - /** - * The amount of messages to collect before resolving. - */ - amount: number; - /** - * The channel Id where this is listening to - */ - channelId: string; - /** - * The timestamp when this collector was created - */ - createdAt: number; - /** - * The duration in milliseconds how long this collector should last. - */ - duration: number; - /** - * Function that will filter messages to determine whether to collect this message - */ - filter(message: Message): boolean; - /** - * The unique key that will be used to get responses for this. Ideally, meant to be for member id. - */ - key: string; + /** + * The amount of messages to collect before resolving. + */ + amount: number; + /** + * The channel Id where this is listening to + */ + channelId: string; + /** + * The timestamp when this collector was created + */ + createdAt: number; + /** + * The duration in milliseconds how long this collector should last. + */ + duration: number; + /** + * Function that will filter messages to determine whether to collect this message + */ + filter(message: Message): boolean; + /** + * The unique key that will be used to get responses for this. Ideally, meant to be for member id. + */ + key: string; }; export type GilMessageCollector = CollectMessagesOptions & { - /** - * Where the messages are stored if the amount to collect is more than 1. - */ - messages: Message[]; - reject(reason?: any): void; - resolve(value: Message[] | PromiseLike): void; + /** + * Where the messages are stored if the amount to collect is more than 1. + */ + messages: Message[]; + reject(reason?: any): void; + resolve(value: Message[] | PromiseLike): void; }; export default BotClient; export type RespondToCooldownOption = { - /** - * The cooldown details - */ - cooldown: Cooldown; - /** - * The timestamp right when the user used the command. - */ - now: number; + /** + * The cooldown details + */ + cooldown: Cooldown; + /** + * The timestamp right when the user used the command. + */ + now: number; }; diff --git a/packages/guilded-api-typings/lib/index.ts b/packages/guilded-api-typings/lib/index.ts index c16a04f1..d25985f1 100644 --- a/packages/guilded-api-typings/lib/index.ts +++ b/packages/guilded-api-typings/lib/index.ts @@ -1 +1,26 @@ +import type { rest, SkeletonWSPayload, ws } from "./v1"; + export * from "./v1"; + +export type JSONContent = { "application/json": Record }; +export type JSON = T["application/json"]; +export type Schema = + rest.components["schemas"][T]; + +export type RestContent = { content: JSONContent }; +export type RestPath = rest.paths[T]; +export type RestBody = + K["requestBody"]["content"]["application/json"]; +export type RestQuery< + K extends { parameters: { query: Record } } +> = K["parameters"]["query"]; +export type RestPayload< + K extends { responses: Record }, + S extends 200 | 201 | 204 +> = K["responses"][S]["content"]["application/json"]; + +export type WSContent = RestContent; +export type WSPayload = + ws.components["responses"][T]["content"]["application/json"]; +export type WSPacket = + SkeletonWSPayload & { d: WSPayload }; diff --git a/packages/guilded-api-typings/lib/v1/events.ts b/packages/guilded-api-typings/lib/v1/events.ts new file mode 100644 index 00000000..b7fc3319 --- /dev/null +++ b/packages/guilded-api-typings/lib/v1/events.ts @@ -0,0 +1,62 @@ +export enum WSOpCodes { + SUCCESS, + WELCOME, + RESUME, + ERROR = 8, + PING, + PONG, +} + +export const WebSocketEvents = { + CalendarEventCreated: "CalendarEventCreated", + CalendarEventUpdated: "CalendarEventUpdated", + CalendarEventDeleted: "CalendarEventDeleted", + CalendarEventRsvpUpdated: "CalendarEventRsvpUpdated", + CalendarEventRsvpManyUpdated: "CalendarEventRsvpManyUpdated", + CalendarEventRsvpDeleted: "CalendarEventRsvpDeleted", + ChatMessageCreated: "ChatMessageCreated", + ChatMessageUpdated: "ChatMessageUpdated", + ChatMessageDeleted: "ChatMessageDeleted", + ServerMemberJoined: "ServerMemberJoined", + ServerMemberRemoved: "ServerMemberRemoved", + ServerMemberUpdated: "ServerMemberUpdated", + ServerMemberBanned: "ServerMemberBanned", + ServerMemberUnbanned: "ServerMemberUnbanned", + ServerMemberSocialLinkCreated: "ServerMemberSocialLinkCreated", + ServerMemberSocialLinkUpdated: "ServerMemberSocialLinkUpdated", + ServerMemberSocialLinkDeleted: "ServerMemberSocialLinkDeleted", + BotServerMembershipCreated: "BotServerMembershipCreated", + BotServerMembershipDeleted: "BotServerMembershipDeleted", + ServerRolesUpdated: "ServerRolesUpdated", + ServerWebhookCreated: "ServerWebhookCreated", + ServerWebhookUpdated: "ServerWebhookUpdated", + ListItemCompleted: "ListItemCompleted", + ListItemUncompleted: "ListItemUncompleted", + ListItemCreated: "ListItemCreated", + ListItemUpdated: "ListItemUpdated", + ListItemDeleted: "ListItemDeleted", + ServerChannelCreated: "ServerChannelCreated", + ServerChannelUpdated: "ServerChannelUpdated", + ServerChannelDeleted: "ServerChannelDeleted", + DocCreated: "DocCreated", + DocUpdated: "DocUpdated", + DocDeleted: "DocDeleted", + ChannelMessageReactionCreated: "ChannelMessageReactionCreated", + ChannelMessageReactionDeleted: "ChannelMessageReactionDeleted", + ForumTopicCreated: "ForumTopicCreated", + ForumTopicUpdated: "ForumTopicUpdated", + ForumTopicDeleted: "ForumTopicDeleted", + ForumTopicPinned: "ForumTopicPinned", + ForumTopicUnpinned: "ForumTopicUnpinned", + ForumTopicLocked: "ForumTopicLocked", + ForumTopicUnlocked: "ForumTopicUnlocked", +} as const; +export type WSEvent = typeof WebSocketEvents; +export type WSEventNames = keyof WSEvent; + +export type SkeletonWSPayload = { + d: unknown; + op: WSOpCodes; + s?: string; + t: keyof WSEvent; +}; \ No newline at end of file diff --git a/packages/guilded-api-typings/lib/v1/index.ts b/packages/guilded-api-typings/lib/v1/index.ts index 2ef3357c..7c7242ee 100644 --- a/packages/guilded-api-typings/lib/v1/index.ts +++ b/packages/guilded-api-typings/lib/v1/index.ts @@ -1,3 +1,5 @@ -export * from "./rest"; +export * as rest from "./rest"; +export * as ws from "./ws"; +export * from "./events"; export * from "./structs"; -export * from "./ws"; +export * from "./webhook"; \ No newline at end of file diff --git a/packages/guilded-api-typings/lib/v1/rest.ts b/packages/guilded-api-typings/lib/v1/rest.ts new file mode 100644 index 00000000..0cc6ae06 --- /dev/null +++ b/packages/guilded-api-typings/lib/v1/rest.ts @@ -0,0 +1,5920 @@ +/** + * This file was auto-generated by openapi-typescript. + * Do not make direct changes to the file. + */ + +/** WithRequired type helpers */ +type WithRequired = T & { [P in K]-?: T[P] }; + +export interface paths { + "/channels/{channelId}/messages": { + /** + * Get channel messages + * @description Results returned will be ordered ascending by the message's `createdAt`. `before` and `after` will filter based on the message's `createdAt` + */ + get: operations["ChannelMessageReadMany"]; + /** Create a channel message */ + post: operations["ChannelMessageCreate"]; + }; + "/channels/{channelId}/messages/{messageId}": { + /** + * Get a channel message + * @description Get details for a specific chat message from a chat channel. + */ + get: operations["ChannelMessageRead"]; + /** Update a channel message */ + put: operations["ChannelMessageUpdate"]; + /** Delete a channel message */ + delete: operations["ChannelMessageDelete"]; + }; + "/channels/{channelId}/content/{contentId}/emotes/{emoteId}": { + /** + * [deprecated] Create reaction + * @description [deprecated] Please use [this route](/docs/api/reactions/ChannelMessageReactionCreate) instead + */ + put: operations["ContentReactionCreate"]; + /** + * [deprecated] Delete reaction + * @description [deprecated] Please use [this route](/docs/api/reactions/ChannelMessageReactionDelete) instead + */ + delete: operations["ContentReactionDelete"]; + }; + "/groups/{groupId}/members/{userId}": { + /** Add member to group */ + put: operations["GroupMembershipCreate"]; + /** Remove member from group */ + delete: operations["GroupMembershipDelete"]; + }; + "/servers/{serverId}/members/{userId}/xp": { + /** Set a member's XP */ + put: operations["ServerXpForUserUpdate"]; + /** Award XP to a member */ + post: operations["ServerXpForUserCreate"]; + }; + "/servers/{serverId}/roles/{roleId}/xp": { + /** + * Award XP to role + * @description Award XP to all members with a particular role. + */ + post: operations["ServerXpForRoleCreate"]; + }; + "/servers/{serverId}/members/{userId}/roles/{roleId}": { + /** Assign role to member */ + put: operations["RoleMembershipCreate"]; + /** Remove role from member */ + delete: operations["RoleMembershipDelete"]; + }; + "/servers/{serverId}/members/{userId}/roles": { + /** + * Get member roles + * @description Get a list of the roles assigned to a member + */ + get: operations["RoleMembershipReadMany"]; + }; + "/channels/{channelId}/topics": { + /** Get forum topics */ + get: operations["ForumTopicReadMany"]; + /** Create a topic in a forum */ + post: operations["ForumTopicCreate"]; + }; + "/channels/{channelId}/topics/{forumTopicId}": { + /** Get a forum topic */ + get: operations["ForumTopicRead"]; + /** Delete a forum topic */ + delete: operations["ForumTopicDelete"]; + /** Update a forum topic */ + patch: operations["ForumTopicUpdate"]; + }; + "/channels/{channelId}/topics/{forumTopicId}/pin": { + /** Pin a forum topic */ + put: operations["ForumTopicPin"]; + /** Unpin a forum topic */ + delete: operations["ForumTopicUnpin"]; + }; + "/channels/{channelId}/topics/{forumTopicId}/emotes/{emoteId}": { + /** Create forum topic reaction */ + put: operations["ForumTopicReactionCreate"]; + /** Delete forum topic reaction */ + delete: operations["ForumTopicReactionDelete"]; + }; + "/channels/{channelId}/topics/{forumTopicId}/lock": { + /** Lock a forum topic */ + put: operations["ForumTopicLock"]; + /** Unlock a forum topic */ + delete: operations["ForumTopicUnlock"]; + }; + "/channels/{channelId}/topics/{forumTopicId}/comments": { + /** Get a forum topic's comments */ + get: operations["ForumTopicCommentReadMany"]; + /** Create a forum topic comment */ + post: operations["ForumTopicCommentCreate"]; + }; + "/channels/{channelId}/topics/{forumTopicId}/comments/{forumTopicCommentId}": { + /** Get a comment on a forum topic */ + get: operations["ForumTopicCommentRead"]; + /** Delete a forum topic comment */ + delete: operations["ForumTopicCommentDelete"]; + /** Update a forum topic comment */ + patch: operations["ForumTopicCommentUpdate"]; + }; + "/channels/{channelId}/items": { + /** Get list items within a channel */ + get: operations["ListItemReadMany"]; + /** Create a list item */ + post: operations["ListItemCreate"]; + }; + "/channels/{channelId}/items/{listItemId}": { + /** Get a list item */ + get: operations["ListItemRead"]; + /** + * [deprecated] Update a list item + * @description Deprecating this route in favor of the *patch* route + */ + put: operations["ListItemUpdateDeprecated"]; + /** Delete a list item */ + delete: operations["ListItemDelete"]; + /** Update a list item */ + patch: operations["ListItemUpdate"]; + }; + "/channels/{channelId}/items/{listItemId}/complete": { + /** Complete a list item */ + post: operations["ListItemCompleteCreate"]; + /** Uncomplete a list item */ + delete: operations["ListItemCompleteDelete"]; + }; + "/servers/{serverId}/members/{userId}/social-links/{socialLinkType}": { + /** Retrieves a member's public social links */ + get: operations["MemberSocialLinkRead"]; + }; + "/servers/{serverId}/members/{userId}/nickname": { + /** Update a member's nickname */ + put: operations["MemberNicknameUpdate"]; + /** Delete a member's nickname */ + delete: operations["MemberNicknameDelete"]; + }; + "/channels": { + /** + * Create a channel + * @description Only server channels are supported at this time (coming soon™: DM Channels!) + */ + post: operations["ChannelCreate"]; + }; + "/channels/{channelId}": { + /** + * Get a channel + * @description Only server channels are supported at this time (coming soon™: DM Channels!) + */ + get: operations["ChannelRead"]; + /** + * Delete a channel + * @description Only server channels are supported at this time (coming soon™: DM Channels!) + */ + delete: operations["ChannelDelete"]; + /** + * Update a channel + * @description Only server channels are supported at this time (coming soon™: DM Channels!) + */ + patch: operations["ChannelUpdate"]; + }; + "/channels/{channelId}/docs": { + /** + * Get docs + * @description Results returned will be ordered descending by the doc's `updatedAt`. `before` will filter based on the doc's `updatedAt` + */ + get: operations["DocReadMany"]; + /** Create a doc */ + post: operations["DocCreate"]; + }; + "/channels/{channelId}/docs/{docId}": { + /** Get a doc */ + get: operations["DocRead"]; + /** Update a doc */ + put: operations["DocUpdate"]; + /** Delete a doc */ + delete: operations["DocDelete"]; + }; + "/servers/{serverId}/members/{userId}": { + /** Get a server member */ + get: operations["ServerMemberRead"]; + /** + * Kick a server member + * @description This route can be used to leave servers by passing in your own user ID or `@me` for `userId` + */ + delete: operations["ServerMemberDelete"]; + }; + "/servers/{serverId}/members": { + /** + * Get members of a server + * @description Results returned will be ordered ascending by the member's `joinedAt` + */ + get: operations["ServerMemberReadMany"]; + }; + "/servers/{serverId}/bans/{userId}": { + /** Get a server ban */ + get: operations["ServerMemberBanRead"]; + /** + * Create a server ban + * @description Also known as banning a server member + */ + post: operations["ServerMemberBanCreate"]; + /** + * Delete a server ban + * @description Also known as unbanning a server member + */ + delete: operations["ServerMemberBanDelete"]; + }; + "/servers/{serverId}/bans": { + /** Get server bans */ + get: operations["ServerMemberBanReadMany"]; + }; + "/servers/{serverId}/webhooks": { + /** + * Get a server's webhooks + * @description Get a list of webhooks from a server. + */ + get: operations["WebhookReadMany"]; + /** Create a webhook */ + post: operations["WebhookCreate"]; + }; + "/servers/{serverId}/webhooks/{webhookId}": { + /** Get a server's webhook */ + get: operations["WebhookRead"]; + /** Update a webhook */ + put: operations["WebhookUpdate"]; + /** Delete a server webhook */ + delete: operations["WebhookDelete"]; + }; + "/servers/{serverId}": { + /** + * Get a server + * @description Fetch various information about a given server. Currently, the bot must be a member of the server in order to fetch its information. + */ + get: operations["ServerRead"]; + }; + "/channels/{channelId}/events": { + /** + * Get calendar events + * @description Results returned will be ordered ascending by the event's `startsAt`. `before` and `after` will filter based on the event's `startsAt` + */ + get: operations["CalendarEventReadMany"]; + /** + * Create a calendar event + * @description We currently do not have a way to surface the `repeatInfo` after event series are updated. Stay tuned! + */ + post: operations["CalendarEventCreate"]; + }; + "/channels/{channelId}/events/{calendarEventId}": { + /** Get a calendar event */ + get: operations["CalendarEventRead"]; + /** Delete a calendar event */ + delete: operations["CalendarEventDelete"]; + /** + * Update a calendar event + * @description We currently do not have a way to surface the `repeatInfo` after event series are updated. Stay tuned! + */ + patch: operations["CalendarEventUpdate"]; + }; + "/channels/{channelId}/events/{calendarEventId}/rsvps/{userId}": { + /** Get a calendar event RSVP */ + get: operations["CalendarEventRsvpRead"]; + /** Create or update a calendar event RSVP */ + put: operations["CalendarEventRsvpUpdate"]; + /** Delete a calendar event RSVP */ + delete: operations["CalendarEventRsvpDelete"]; + }; + "/channels/{channelId}/events/{calendarEventId}/rsvps": { + /** Get calendar event RSVPs */ + get: operations["CalendarEventRsvpReadMany"]; + /** Create or update a calendar event RSVP for multiple users */ + put: operations["CalendarEventRsvpUpdateMany"]; + }; + "/users/{userId}": { + /** + * Get a user + * @description **Note** - at this time, you can only retrieve your own user + */ + get: operations["UserRead"]; + }; + "/channels/{channelId}/topics/{forumTopicId}/comments/{forumTopicCommentId}/emotes/{emoteId}": { + /** Create forum topic comment reaction */ + put: operations["ForumTopicCommentReactionCreate"]; + /** Delete forum topic comment reaction */ + delete: operations["ForumTopicCommentReactionDelete"]; + }; + "/channels/{channelId}/events/{calendarEventId}/comments": { + /** Get a calendar event's comments */ + get: operations["CalendarEventCommentReadMany"]; + /** Create a comment on an event */ + post: operations["CalendarEventCommentCreate"]; + }; + "/channels/{channelId}/events/{calendarEventId}/comments/{calendarEventCommentId}": { + /** Get a comment on the calendar event */ + get: operations["CalendarEventCommentRead"]; + /** Delete a calendar event comment */ + delete: operations["CalendarEventCommentDelete"]; + /** Update a calendar event comment */ + patch: operations["CalendarEventCommentUpdate"]; + }; + "/channels/{channelId}/events/{calendarEventId}/emotes/{emoteId}": { + /** Create calendar event reaction */ + put: operations["CalendarEventReactionCreate"]; + /** Delete calendar event reaction */ + delete: operations["CalendarEventReactionDelete"]; + }; + "/channels/{channelId}/events/{calendarEventId}/comments/{calendarEventCommentId}/emotes/{emoteId}": { + /** Create calendar event comment reaction */ + put: operations["CalendarEventCommentReactionCreate"]; + /** Delete calendar event comment reaction */ + delete: operations["CalendarEventCommentReactionDelete"]; + }; + "/channels/{channelId}/docs/{docId}/comments": { + /** Get a doc's comments */ + get: operations["DocCommentReadMany"]; + /** Create a comment on a doc */ + post: operations["DocCommentCreate"]; + }; + "/channels/{channelId}/docs/{docId}/comments/{docCommentId}": { + /** Get a comment on a doc */ + get: operations["DocCommentRead"]; + /** Delete a doc comment */ + delete: operations["DocCommentDelete"]; + /** Update a doc comment */ + patch: operations["DocCommentUpdate"]; + }; + "/channels/{channelId}/docs/{docId}/emotes/{emoteId}": { + /** Create doc reaction */ + put: operations["DocReactionCreate"]; + /** Delete doc reaction */ + delete: operations["DocReactionDelete"]; + }; + "/channels/{channelId}/docs/{docId}/comments/{docCommentId}/emotes/{emoteId}": { + /** Create doc comment reaction */ + put: operations["DocCommentReactionCreate"]; + /** Delete doc comment reaction */ + delete: operations["DocCommentReactionDelete"]; + }; + "/channels/{channelId}/event_series/{calendarEventSeriesId}": { + /** Delete a calendar event series */ + delete: operations["CalendarEventSeriesDelete"]; + /** Update a calendar event series */ + patch: operations["CalendarEventSeriesUpdate"]; + }; + "/channels/{channelId}/announcements": { + /** + * Get announcements + * @description Results returned will be ordered ascending by the announcement's `createdAt`. `before` will filter based on the announcement's `createdAt` + */ + get: operations["AnnouncementReadMany"]; + /** Create an announcement */ + post: operations["AnnouncementCreate"]; + }; + "/channels/{channelId}/announcements/{announcementId}": { + /** Read an announcement */ + get: operations["AnnouncementRead"]; + /** Delete an announcement */ + delete: operations["AnnouncementDelete"]; + /** Update an announcement */ + patch: operations["AnnouncementUpdate"]; + }; + "/users/{userId}/servers": { + /** + * Get a users servers + * @description **Note** - at this time, you can only retrieve your own servers + */ + get: operations["UserServerReadMany"]; + }; + "/channels/{channelId}/announcements/{announcementId}/emotes/{emoteId}": { + /** Create announcement reaction */ + put: operations["AnnouncementReactionCreate"]; + /** Delete announcement reaction */ + delete: operations["AnnouncementReactionDelete"]; + }; + "/channels/{channelId}/announcements/{announcementId}/comments": { + /** Get an announcement's comments */ + get: operations["AnnouncementCommentReadMany"]; + /** Create a comment on an announcement */ + post: operations["AnnouncementCommentCreate"]; + }; + "/channels/{channelId}/announcements/{announcementId}/comments/{announcementCommentId}": { + /** Get a comment on the announcement */ + get: operations["AnnouncementCommentRead"]; + /** Delete an announcement comment */ + delete: operations["AnnouncementCommentDelete"]; + /** Update an announcement comment */ + patch: operations["AnnouncementCommentUpdate"]; + }; + "/channels/{channelId}/announcements/{announcementId}/comments/{announcementCommentId}/emotes/{emoteId}": { + /** Create an announcement comment reaction */ + put: operations["AnnouncementCommentReactionCreate"]; + /** Delete an announcement comment reaction */ + delete: operations["AnnouncementCommentReactionDelete"]; + }; + "/channels/{channelId}/messages/{messageId}/emotes/{emoteId}": { + /** Create a message reaction */ + put: operations["ChannelMessageReactionCreate"]; + /** Delete a message reaction */ + delete: operations["ChannelMessageReactionDelete"]; + }; + "/channels/{channelId}/messages/{messageId}/emotes": { + /** Bulk delete a message's reactions */ + delete: operations["ChannelMessageReactionDeleteMany"]; + }; +} + +export type webhooks = Record; + +export interface components { + schemas: { + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "type": "default", + * "serverId": "wlVr3Ggl", + * "groupId": "ZVzBo83p", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "content": "Hello **world**!", + * "embeds": [ + * { + * "title": "embed title", + * "description": "embeds support a **different** __subset__ *of* markdown than other markdown fields. <@Ann6LewA>\n\n [links](https://www.guilded.gg) ```\ncheck this code out```\n\n:pizza: time!! ttyl", + * "url": "https://www.guilded.gg", + * "color": 6118369, + * "timestamp": "2022-04-12T22:14:36.737Z", + * "footer": { + * "icon_url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png", + * "text": "footer text" + * }, + * "thumbnail": { + * "url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png" + * }, + * "image": { + * "url": "https://www.guilded.gg/asset/Logos/logomark_wordmark/Color/Guilded_Logomark_Wordmark_Color.png" + * }, + * "author": { + * "name": "Gil", + * "url": "https://www.guilded.gg", + * "icon_url": "https://www.guilded.gg/asset/Default/Gil-md.png" + * }, + * "fields": [ + * { + * "name": "hello", + * "value": "these are fields" + * }, + * { + * "name": "~~help i have been crossed out~~", + * "value": "~~oh noes~~", + * "inline": true + * }, + * { + * "name": "another inline", + * "value": "field", + * "inline": true + * } + * ] + * } + * ], + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + ChatMessage: { + /** + * Message ID + * Format: uuid + * @description The ID of the message + */ + id: string; + /** + * Type + * @description The type of chat message. "system" messages are generated by Guilded, while "default" messages are user or bot-generated. + * @enum {string} + */ + type: "default" | "system"; + /** + * Server ID + * @description The ID of the server + */ + serverId?: string; + /** + * Group ID + * @description The ID of the group + */ + groupId?: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Content + * Format: markdown + * @description The content of the message + */ + content?: string; + embeds?: components["schemas"]["ChatEmbed"][]; + /** @description Message IDs that were replied to */ + replyMessageIds?: string[]; + /** + * Is private + * @description If set, this message will only be seen by those mentioned or replied to + */ + isPrivate?: boolean; + /** + * Is silent + * @description If set, this message did not notify mention or reply recipients + * @default false + */ + isSilent?: boolean; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the message was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this message (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Created by Webhook ID + * @description The ID of the webhook who created this message, if it was created by a webhook + */ + createdByWebhookId?: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the message was updated at, if relevant + */ + updatedAt?: string; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "messageId": "00000000-0000-0000-0000-000000000000" + * } + */ + ChatMessageReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Message ID + * Format: uuid + * @description The ID of the message + */ + messageId: string; + }; + /** + * @description Rich content sections optionally associated with chat messages. Properties with "webhook-markdown" support allow for the following: link, italic, bold, strikethrough, underline, inline code, block code, reaction, and mention. + * @example { + * "title": "embed title", + * "description": "embeds support a **different** __subset__ *of* markdown than other markdown fields. <@Ann6LewA>\n\n [links](https://www.guilded.gg) ```\ncheck this code out```\n\n:pizza: time!! ttyl", + * "url": "https://www.guilded.gg", + * "color": 6118369, + * "timestamp": "2022-04-12T22:14:36.737Z", + * "footer": { + * "icon_url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png", + * "text": "footer text" + * }, + * "thumbnail": { + * "url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png" + * }, + * "image": { + * "url": "https://www.guilded.gg/asset/Logos/logomark_wordmark/Color/Guilded_Logomark_Wordmark_Color.png" + * }, + * "author": { + * "name": "Gil", + * "url": "https://www.guilded.gg", + * "icon_url": "https://www.guilded.gg/asset/Default/Gil-md.png" + * }, + * "fields": [ + * { + * "name": "hello", + * "value": "these are fields" + * }, + * { + * "name": "~~help i have been crossed out~~", + * "value": "~~oh noes~~", + * "inline": true + * }, + * { + * "name": "another inline", + * "value": "field", + * "inline": true + * } + * ] + * } + */ + ChatEmbed: { + /** + * Format: webhook-markdown + * @description Main header of the embed + */ + title?: string; + /** + * Format: webhook-markdown + * @description Subtext of the embed + */ + description?: string; + /** + * Format: uri + * @description URL to linkify the `title` field with + */ + url?: string; + /** @description Decimal value of the color that the left border should be */ + color?: number; + /** @description A small section at the bottom of the embed */ + footer?: { + /** + * Format: media-uri + * @description URL of a small image to put in the footer + */ + icon_url?: string; + /** @description Text of the footer */ + text: string; + }; + /** + * Format: date-time + * @description A timestamp to put in the footer + */ + timestamp?: string; + /** @description An image to the right of the embed's content */ + thumbnail?: { + /** + * Format: media-uri + * @description URL of the image + */ + url?: string; + }; + /** @description The main picture to associate with the embed */ + image?: { + /** + * Format: media-uri + * @description URL of the image + */ + url?: string; + }; + /** @description A small section above the title of the embed */ + author?: { + /** @description Name of the author */ + name?: string; + /** + * Format: uri + * @description URL to linkify the author's `name` field + */ + url?: string; + /** + * Format: media-uri + * @description URL of a small image to display to the left of the author's `name` + */ + icon_url?: string; + }; + /** @description Table-like cells to add to the embed */ + fields?: { + /** + * Format: webhook-markdown + * @description Header of the table-like cell + */ + name: string; + /** + * Format: webhook-markdown + * @description Subtext of the table-like cell + */ + value: string; + /** + * @description If the field should wrap or not + * @default false + */ + inline?: boolean; + }[]; + }; + /** + * @example { + * "type": "roblox", + * "userId": "Ann6LewA", + * "handle": "builderman", + * "serviceId": "156", + * "createdAt": "2006-03-08T20:15:00.706Z" + * } + */ + SocialLink: { + /** + * Social link type + * @description The type of social link that Guilded supports. Depending on this value, `handle` or `serviceId` may or may not be present + * @enum {string} + */ + type: + | "twitch" + | "bnet" + | "psn" + | "xbox" + | "steam" + | "origin" + | "youtube" + | "twitter" + | "facebook" + | "switch" + | "patreon" + | "roblox" + | "epic"; + /** + * User ID + * @description The ID of the user that the social link is associated with + */ + userId: string; + /** @description The handle of the user within the external service */ + handle?: string; + /** @description The unique ID that represents this member's social link within the external service */ + serviceId?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the social link was created at + */ + createdAt: string; + }; + /** + * @description Metadata of who or what is mentioned in content + * @example { + * "users": [ + * { + * "id": "Ann6LewA" + * } + * ], + * "channels": [ + * { + * "id": "00000000-0000-0000-0000-000000000000" + * } + * ], + * "roles": [ + * { + * "id": 591232 + * } + * ], + * "everyone": true, + * "here": true + * } + */ + Mentions: { + /** + * Users + * @description Info on mentioned users + */ + users?: { + /** + * User ID + * @description The ID of the user + */ + id: string; + }[]; + /** + * Channels + * @description Info on mentioned channels + */ + channels?: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + id: string; + }[]; + /** + * Roles + * @description Info on mentioned roles + */ + roles?: { + /** + * Role ID + * @description The ID of the role + */ + id: number; + }[]; + /** + * Everyone + * @description If @everyone was mentioned + */ + everyone?: boolean; + /** + * Here + * @description If @here was mentioned + */ + here?: boolean; + }; + /** + * @example { + * "id": 1234567890, + * "content": "Great idea!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "forumTopicId": 2036274747, + * "createdBy": "Ann6LewA" + * } + */ + ForumTopicComment: { + /** @description The ID of the forum topic comment */ + id: number; + /** + * Content + * Format: markdown + * @description The content of the forum topic comment + */ + content: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic comment was created at + */ + createdAt: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic comment was updated at, if relevant + */ + updatedAt?: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** @description The ID of the forum topic */ + forumTopicId: number; + /** + * Created by + * @description The ID of the user who created this forum topic comment (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "forumTopicId": 123456 + * } + */ + ForumTopicReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** @description The ID of the forum topic */ + forumTopicId: number; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "forumTopicId": 123456, + * "forumTopicCommentId": 1234567890 + * } + */ + ForumTopicCommentReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** @description The ID of the forum topic */ + forumTopicId: number; + /** @description The ID of the forum topic comment */ + forumTopicCommentId: number; + }; + /** + * @example { + * "id": 123456, + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "title": "Welcome new members!!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "content": "Please introduce yourself in this topic!!!" + * } + */ + ForumTopic: { + /** @description The ID of the forum topic */ + id: number; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Title + * @description The title of the forum topic + */ + title: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this forum topic (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was updated at, if relevant + */ + updatedAt?: string; + /** + * Bumped at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was bumped at. This timestamp is updated whenever there is any activity on the posts within the forum topic. + */ + bumpedAt?: string; + /** + * Is pinned + * @default false + */ + isPinned?: boolean; + /** + * Is locked + * @default false + */ + isLocked?: boolean; + /** + * Content + * Format: markdown + * @description The content of the forum topic + */ + content: string; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "id": 123456, + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "title": "Welcome new members!!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + ForumTopicSummary: { + /** @description The ID of the forum topic */ + id: number; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Title + * @description The title of the forum topic + */ + title: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this forum topic (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was updated at, if relevant + */ + updatedAt?: string; + /** + * Bumped at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was bumped at. This timestamp is updated whenever there is any activity on the posts within the forum topic. + */ + bumpedAt?: string; + /** + * Is pinned + * @default false + */ + isPinned?: boolean; + /** + * Is locked + * @default false + */ + isLocked?: boolean; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "message": "Remember to say hello **world**!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "note": { + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "content": "Duly noted" + * } + * } + */ + ListItem: { + /** + * Format: uuid + * @description The ID of the list item + */ + id: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Message + * Format: markdown + * @description The message of the list item + */ + message: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this list item (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Created by Webhook ID + * @description The ID of the webhook who created this list item, if it was created by a webhook + */ + createdByWebhookId?: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this list item + */ + updatedBy?: string; + /** + * Format: uuid + * @description The ID of the parent list item if this list item is nested + */ + parentListItemId?: string; + /** + * Completed at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was completed at + */ + completedAt?: string; + /** + * Completed by + * @description The ID of the user who completed this list item + */ + completedBy?: string; + note?: { + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the note was created at. If this field is populated, then there's a note associated with the list item + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this note + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the note was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this note + */ + updatedBy?: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Note + * Format: markdown + * @description The note of the list item + */ + content: string; + }; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "message": "Remember to say hello **world**!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "note": { + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + * } + */ + ListItemSummary: { + /** + * Format: uuid + * @description The ID of the list item + */ + id: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Message + * Format: markdown + * @description The message of the list item + */ + message: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this list item (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Created by Webhook ID + * @description The ID of the webhook who created this list item, if it was created by a webhook + */ + createdByWebhookId?: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this list item + */ + updatedBy?: string; + /** + * Format: uuid + * @description The ID of the parent list item if this list item is nested + */ + parentListItemId?: string; + /** + * Completed at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was completed at + */ + completedAt?: string; + /** + * Completed by + * @description The ID of the user who completed this list item + */ + completedBy?: string; + note?: { + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the note was created at. If this field is populated, then there's a note associated with the list item + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this note + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the note was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this note + */ + updatedBy?: string; + }; + }; + /** + * @example { + * "id": 0, + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "title": "HOW-TO: Smoke These Meats with Sweet Baby Ray's", + * "content": "Spicy jalapeno bacon ipsum dolor amet sirloin ground round short loin, meatball brisket capicola tri-tip ham pork belly biltong corned beef chuck. Chicken ham brisket shank rump buffalo t-bone. Short loin sausage buffalo porchetta pork belly rump tri-tip frankfurter tail pork chop cow sirloin. Pancetta porchetta tail ball tip chislic beef ribs. Buffalo andouille leberkas jerky. Fatback shankle andouille beef. Cow kielbasa buffalo pork loin chislic meatloaf short loin rump meatball prosciutto.", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "updatedAt": "2021-07-15T22:20:00.706Z", + * "updatedBy": "Ann6LewA" + * } + */ + Doc: { + /** + * Doc ID + * @description The ID of the doc + */ + id: number; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Title + * @description The title of the doc + */ + title: string; + /** + * Content + * Format: markdown + * @description The content of the doc + */ + content: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the doc was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this doc + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the doc was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this doc + */ + updatedBy?: string; + }; + /** + * @example { + * "id": 123456, + * "content": "Wow, cool document!!!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "docId": 0, + * "createdBy": "Ann6LewA" + * } + */ + DocComment: { + /** + * Doc comment ID + * @description The ID of the doc comment + */ + id: number; + /** + * Content + * Format: markdown + * @description The content of the doc comment + */ + content: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the doc comment was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this doc comment (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the doc comment was updated at, if relevant + */ + updatedAt?: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Doc ID + * @description The ID of the doc + */ + docId: number; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "docId": 0 + * } + */ + DocReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Doc ID + * @description The ID of the doc + */ + docId: number; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "docId": 0, + * "docCommentId": 123456 + * } + */ + DocCommentReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Doc ID + * @description The ID of the doc + */ + docId: number; + /** + * Doc comment ID + * @description The ID of the doc comment + */ + docCommentId: number; + }; + /** + * @example { + * "user": { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch", + * "createdAt": "2021-06-15T20:15:00.706Z" + * }, + * "roleIds": [], + * "nickname": "Professor Chaos", + * "joinedAt": "2021-07-15T20:15:00.706Z" + * } + */ + ServerMember: { + user: components["schemas"]["User"]; + /** Role IDs */ + roleIds: number[]; + /** Nickname */ + nickname?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the member was created at + */ + joinedAt: string; + /** + * Is owner + * @default false + */ + isOwner?: boolean; + }; + /** + * @example { + * "user": { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch" + * }, + * "roleIds": [] + * } + */ + ServerMemberSummary: { + user: components["schemas"]["UserSummary"]; + /** Role IDs */ + roleIds: number[]; + }; + /** + * @example { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch", + * "createdAt": "2021-06-15T20:15:00.706Z" + * } + */ + User: { + /** + * User ID + * @description The ID of the user + */ + id: string; + /** + * User type + * @description The type of user. If this property is absent, it can assumed to be of type `user` + * @enum {string} + */ + type?: "bot" | "user"; + /** + * User name + * @description The user's name + */ + name: string; + /** + * Avatar + * Format: media-uri + * @description The avatar image associated with the user + */ + avatar?: string; + /** + * Banner + * Format: media-uri + * @description The banner image associated with the user + */ + banner?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the user was created at + */ + createdAt: string; + }; + /** + * @example { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch" + * } + */ + UserSummary: { + /** + * User ID + * @description The ID of the user + */ + id: string; + /** + * User type + * @description The type of user. If this property is absent, it can assumed to be of type `user` + * @enum {string} + */ + type?: "bot" | "user"; + /** + * User name + * @description The user's name + */ + name: string; + /** + * Avatar + * Format: media-uri + * @description The avatar image associated with the user + */ + avatar?: string; + }; + /** + * @example { + * "user": { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch" + * }, + * "reason": "More toxic than a poison Pokémon", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + ServerMemberBan: { + user: components["schemas"]["UserSummary"]; + /** + * Reason + * @description The reason for the ban as submitted by the banner + */ + reason?: string; + /** + * Created by + * @description The ID of the user who created this server member ban + */ + createdBy: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the server member ban was created at + */ + createdAt: string; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "type": "chat", + * "name": "The Dank Cellar", + * "topic": "Dank memes ONLY", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "serverId": "wlVr3Ggl", + * "groupId": "ZVzBo83p" + * } + */ + ServerChannel: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + id: string; + /** + * @description The type of channel. This will determine what routes to use for creating content in a channel. For example, if this "chat", then one must use the routes for creating channel messages + * @enum {string} + */ + type: + | "announcements" + | "chat" + | "calendar" + | "forums" + | "media" + | "docs" + | "voice" + | "list" + | "scheduling" + | "stream"; + /** @description The name of the channel */ + name: string; + /** @description The topic of the channel */ + topic?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the channel was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this channel + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the channel was updated at, if relevant + */ + updatedAt?: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description ID of the parent channel or parent thread, if present. Only relevant for server channels + */ + parentId?: string; + /** @description Only relevant for server channels */ + categoryId?: number; + /** + * Group ID + * @description The ID of the group + */ + groupId: string; + /** + * Is public + * @description Whether the channel can be accessed from users who are not member of the server + * @default false + */ + isPublic?: boolean; + /** + * Archived by + * @description The ID of the user who archived this channel + */ + archivedBy?: string; + /** + * Archived at + * Format: date-time + * @description The ISO 8601 timestamp that the channel was archived at, if relevant + */ + archivedAt?: string; + }; + /** + * @example { + * "id": "wlVr3Ggl", + * "type": "community", + * "name": "Guilded", + * "url": "Guilded-Official", + * "about": "The Official Guilded Server! For devs, friends, and fans alike!", + * "ownerId": "Ann6LewA", + * "createdAt": "2018-10-05T20:15:00.706Z", + * "isVerified": true, + * "timezone": "America/Los Angeles (PST/PDT)" + * } + */ + Server: { + /** + * Server ID + * @description The ID of the server + */ + id: string; + /** + * Created by + * @description The ID of the user who created this server + */ + ownerId: string; + /** + * Server type + * @description The type of server designated from the server's settings page + * @enum {string} + */ + type?: + | "team" + | "organization" + | "community" + | "clan" + | "guild" + | "friends" + | "streaming" + | "other"; + /** + * Server name + * @description The name given to the server + */ + name: string; + /** + * Server URL + * @description The URL that the server can be accessible from. For example, a value of "Guilded-Official" means the server can be accessible from https://www.guilded.gg/Guilded-Official + */ + url?: string; + /** + * Description + * @description The description associated with the server + */ + about?: string; + /** + * Avatar + * Format: media-uri + * @description The avatar image associated with the server + */ + avatar?: string; + /** + * Banner + * Format: media-uri + * @description The banner image associated with the server + */ + banner?: string; + /** + * Timezone + * @description The timezone associated with the server + */ + timezone?: string; + /** + * Is verified + * @description The verified status of the server + */ + isVerified?: boolean; + /** + * Channel ID + * Format: uuid + * @description The channel ID of the default channel of the server. This channel is defined as the first chat or voice channel in the left sidebar of a server in our UI. This channel is useful for sending welcome messages, though note that a bot may not have permissions to interact with this channel depending on how the server is configured. + */ + defaultChannelId?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the server was created at + */ + createdAt: string; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "name": "E-102 Gamma", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + Webhook: { + /** + * Webhook ID + * Format: uuid + * @description The ID of the webhook + */ + id: string; + /** + * Name + * @description The name of the webhook + */ + name: string; + /** + * Avatar + * Format: media-uri + * @description The avatar image associated with the webhook + */ + avatar?: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the webhook was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this webhook + */ + createdBy: string; + /** + * Deleted at + * Format: date-time + * @description The ISO 8601 timestamp that the webhook was deleted at + */ + deletedAt?: string; + /** + * Token + * @description The token of the webhook + */ + token?: string; + }; + /** + * @example { + * "id": 1, + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "name": "Surprise LAN party for my wife 🤫", + * "description": "**Don't say anything to her!** She's gonna love playing Call of Duty all night", + * "location": "My house!", + * "url": "https://www.surprisepartygame.com/", + * "duration": 60, + * "color": 16106496, + * "startsAt": "2022-06-16T00:00:00.000Z", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + CalendarEvent: { + /** + * Calendar event ID + * @description The ID of the calendar event + */ + id: number; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Name + * @description The name of the event + */ + name: string; + /** + * Description + * Format: markdown + * @description The description of the event + */ + description?: string; + /** + * Location + * @description The location of the event + */ + location?: string; + /** + * Format: uri + * @description A URL to associate with the event + */ + url?: string; + /** @description The color of the event when viewing in the calendar */ + color?: number; + /** @description Is this event a repeating event */ + repeats?: boolean; + /** + * Calendar event series ID + * Format: uuid + * @description The ID of the calendar event series. Only shows if the event is repeating + */ + seriesId?: string; + /** + * Role IDs + * @description The role IDs to restrict the event to + */ + roleIds?: number[]; + /** + * RSVP disabled + * @description When disabled, users will not be able to RSVP to the event + */ + rsvpDisabled?: boolean; + /** + * Is all day + * @description Does the event last all day + */ + isAllDay?: boolean; + /** @description The number of RSVPs to allow before waitlisting RSVPs */ + rsvpLimit?: number; + /** @description When `rsvpLimit` is set, users from the waitlist will be added as space becomes available in the event */ + autofillWaitlist?: boolean; + /** + * Starts at + * Format: date-time + * @description The ISO 8601 timestamp that the event starts at + */ + startsAt: string; + /** + * Duration + * @description The duration of the event _**in minutes**_ + */ + duration?: number; + /** Is private */ + isPrivate?: boolean; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the event was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this event + */ + createdBy: string; + cancellation?: { + /** + * Description + * Format: markdown + * @description The description of event cancellation + */ + description?: string; + /** + * Created by + * @description The ID of the user who created this event cancellation + */ + createdBy: string; + }; + }; + /** + * @example { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * } + */ + Emote: { + /** + * Emote ID + * @description The ID of the emote + */ + id: number; + /** + * Name + * @description The name of the emote + */ + name: string; + /** + * Emote URL + * Format: media-uri + * @description The URL of the emote image + */ + url: string; + /** + * Server ID + * @description The ID of the server the emote was created on + */ + serverId?: string; + }; + /** + * @example { + * "calendarEventId": 1, + * "channelId": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "userId": "Ann6LewA", + * "status": "going", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + CalendarEventRsvp: { + /** + * Calendar event ID + * @description The ID of the calendar event + */ + calendarEventId: number; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * User ID + * @description The ID of the user + */ + userId: string; + /** + * Status + * @description The status of the RSVP + * @enum {string} + */ + status: + | "going" + | "maybe" + | "declined" + | "invited" + | "waitlisted" + | "not responded"; + /** + * Created by + * @description The ID of the user who created this RSVP + */ + createdBy: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the RSVP was created at + */ + createdAt: string; + /** + * Updated by + * @description The ID of the user who updated this RSVP + */ + updatedBy?: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the RSVP was updated at, if relevant + */ + updatedAt?: string; + }; + /** + * @example { + * "id": 1234567890, + * "content": "I will be there!!", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdAt": "2022-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "calendarEventId": 987654321 + * } + */ + CalendarEventComment: { + /** + * Calendar event comment ID + * @description The ID of the calendar event comment + */ + id: number; + /** + * Content + * Format: markdown + * @description The content of the calendar event comment + */ + content: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the calendar event comment was created at + */ + createdAt: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the calendar event comment was updated at, if relevant + */ + updatedAt?: string; + /** + * Calendar event ID + * @description The ID of the calendar event + */ + calendarEventId: number; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Created by + * @description The ID of the user who created this calendar event comment (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "calendarEventId": 1 + * } + */ + CalendarEventReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Calendar event ID + * @description The ID of the calendar event + */ + calendarEventId: number; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "calendarEventId": 1, + * "calendarEventCommentId": 1234567890 + * } + */ + CalendarEventCommentReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Calendar event ID + * @description The ID of the calendar event + */ + calendarEventId: number; + /** + * Calendar event comment ID + * @description The ID of the calendar event comment + */ + calendarEventCommentId: number; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000" + * } + */ + CalendarEventSeries: { + /** + * Calendar event series ID + * Format: uuid + * @description The ID of the calendar event series + */ + id: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + }; + /** + * @example { + * "id": "9RVMoDZy", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "title": "Pizza Party, don't be tardy!", + * "content": "Grab a slice, don't be slow, At our pizza party, it's the way to go! Toppings galore, cheesy delight, Come join us, it'll be out of sight!" + * } + */ + Announcement: { + /** + * Announcement ID + * @description The ID of the announcement + */ + id: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the announcement was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this announcement + */ + createdBy: string; + /** + * Content + * Format: markdown + * @description The content of the announcement + */ + content: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Title + * @description The title of the announcement + */ + title: string; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "announcementId": "9RVMoDZy" + * } + */ + AnnouncementReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Announcement ID + * @description The ID of the announcement + */ + announcementId: string; + }; + /** + * @example { + * "id": 123456, + * "content": "Now THAT is one awesome announcement!!!", + * "createdAt": "2023-04-07T16:19:00.000Z", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "announcementId": "9RVMoDZy", + * "createdBy": "Ann6LewA" + * } + */ + AnnouncementComment: { + /** + * Announcement comment ID + * @description The ID of the announcement comment + */ + id: number; + /** + * Content + * Format: markdown + * @description The content of the announcement comment + */ + content: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the announcement comment was created at + */ + createdAt: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the announcement comment was updated at, if relevant + */ + updatedAt?: string; + /** + * Created by + * @description The ID of the user who created this announcement comment (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Announcement ID + * @description The ID of the announcement + */ + announcementId: string; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "announcementId": "9RVMoDZy", + * "announcementCommentId": 123456 + * } + */ + AnnouncementCommentReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Announcement ID + * @description The ID of the announcement + */ + announcementId: string; + /** + * Announcement comment ID + * @description The ID of the announcement comment + */ + announcementCommentId: number; + }; + }; + responses: never; + parameters: never; + requestBodies: never; + headers: never; + pathItems: never; +} + +export type external = Record; + +export interface operations { + /** + * Get channel messages + * @description Results returned will be ordered ascending by the message's `createdAt`. `before` and `after` will filter based on the message's `createdAt` + */ + ChannelMessageReadMany: { + parameters: { + query: { + /** @example 2021-06-15T20:15:00.706Z */ + before?: string; + /** + * @description An ISO 8601 timestamp that will be used to filter out results for the current page. Order will be reversed when compared to `before` or when omitting this parameter altogether + * @example 2021-06-15T20:15:00.706Z + */ + after?: string; + /** @example 25 */ + limit?: number; + /** @description Whether to include private messages between all users in response */ + includePrivate?: boolean; + }; + path: { + /** + * @description ID of the channel that the messages exist in + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + messages: components["schemas"]["ChatMessage"][]; + }; + }; + }; + }; + }; + /** Create a channel message */ + ChannelMessageCreate: { + parameters: { + path: { + /** + * @description Channel ID to create the message in + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "Hello **world**!", + * "embeds": [ + * { + * "title": "embed title", + * "description": "embeds support a **different** __subset__ *of* markdown than other markdown fields. <@Ann6LewA>\n\n [links](https://www.guilded.gg) ```\ncheck this code out```\n\n:pizza: time!! ttyl", + * "url": "https://www.guilded.gg", + * "color": 6118369, + * "timestamp": "2022-04-12T22:14:36.737Z", + * "footer": { + * "icon_url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png", + * "text": "footer text" + * }, + * "thumbnail": { + * "url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png" + * }, + * "image": { + * "url": "https://www.guilded.gg/asset/Logos/logomark_wordmark/Color/Guilded_Logomark_Wordmark_Color.png" + * }, + * "author": { + * "name": "Gil", + * "url": "https://www.guilded.gg", + * "icon_url": "https://www.guilded.gg/asset/Default/Gil-md.png" + * }, + * "fields": [ + * { + * "name": "hello", + * "value": "these are fields" + * }, + * { + * "name": "~~help i have been crossed out~~", + * "value": "~~oh noes~~", + * "inline": true + * }, + * { + * "name": "another inline", + * "value": "field", + * "inline": true + * } + * ] + * } + * ] + * } + */ + "application/json": { + /** + * Is private + * @description If set, this message will only be seen by those mentioned or replied to + */ + isPrivate?: boolean; + /** + * Is silent + * @description If set, this message will not notify any mentioned users or roles + * @default false + */ + isSilent?: boolean; + /** @description Message IDs to reply to */ + replyMessageIds?: string[]; + /** + * Content + * @description The content of the message + */ + content?: Record | string; + /** @description At this time, only one embed is supported per message, and attachments are not supported. If you need to send more than one embed or upload attachments, consider creating the message via a webhook. */ + embeds?: components["schemas"]["ChatEmbed"][]; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + message: components["schemas"]["ChatMessage"]; + }; + }; + }; + }; + }; + /** + * Get a channel message + * @description Get details for a specific chat message from a chat channel. + */ + ChannelMessageRead: { + parameters: { + path: { + /** + * @description ID of the channel that the message exists in + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + messageId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + message: components["schemas"]["ChatMessage"]; + }; + }; + }; + }; + }; + /** Update a channel message */ + ChannelMessageUpdate: { + parameters: { + path: { + /** + * @description ID of the channel that the message to be updated exists in + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + messageId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "Hello **world**!", + * "embeds": [ + * { + * "title": "embed title", + * "description": "embeds support a **different** __subset__ *of* markdown than other markdown fields. <@Ann6LewA>\n\n [links](https://www.guilded.gg) ```\ncheck this code out```\n\n:pizza: time!! ttyl", + * "url": "https://www.guilded.gg", + * "color": 6118369, + * "timestamp": "2022-04-12T22:14:36.737Z", + * "footer": { + * "icon_url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png", + * "text": "footer text" + * }, + * "thumbnail": { + * "url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png" + * }, + * "image": { + * "url": "https://www.guilded.gg/asset/Logos/logomark_wordmark/Color/Guilded_Logomark_Wordmark_Color.png" + * }, + * "author": { + * "name": "Gil", + * "url": "https://www.guilded.gg", + * "icon_url": "https://www.guilded.gg/asset/Default/Gil-md.png" + * }, + * "fields": [ + * { + * "name": "hello", + * "value": "these are fields" + * }, + * { + * "name": "~~help i have been crossed out~~", + * "value": "~~oh noes~~", + * "inline": true + * }, + * { + * "name": "another inline", + * "value": "field", + * "inline": true + * } + * ] + * } + * ] + * } + */ + "application/json": { + /** + * Content + * @description The content of the message + */ + content?: Record | string; + /** @description At this time, only one embed is supported per message, and attachments are not supported. If you need to send more than one embed or upload attachments, consider creating the message via a webhook. */ + embeds?: components["schemas"]["ChatEmbed"][]; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + message: WithRequired< + { + /** + * Message ID + * Format: uuid + * @description The ID of the message + */ + id?: string; + /** + * Type + * @description The type of chat message. "system" messages are generated by Guilded, while "default" messages are user or bot-generated. + * @enum {string} + */ + type?: "default" | "system"; + /** + * Server ID + * @description The ID of the server + */ + serverId?: string; + /** + * Group ID + * @description The ID of the group + */ + groupId?: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId?: string; + /** + * Content + * Format: markdown + * @description The content of the message + */ + content?: string; + embeds?: components["schemas"]["ChatEmbed"][]; + /** @description Message IDs that were replied to */ + replyMessageIds?: string[]; + /** + * Is private + * @description If set, this message will only be seen by those mentioned or replied to + */ + isPrivate?: boolean; + /** + * Is silent + * @description If set, this message did not notify mention or reply recipients + * @default false + */ + isSilent?: boolean; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the message was created at + */ + createdAt?: string; + /** + * Created by + * @description The ID of the user who created this message (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy?: string; + /** + * Created by Webhook ID + * @description The ID of the webhook who created this message, if it was created by a webhook + */ + createdByWebhookId?: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the message was updated at, if relevant + */ + updatedAt: string; + } & components["schemas"]["ChatMessage"], + "updatedAt" + >; + }; + }; + }; + }; + }; + /** Delete a channel message */ + ChannelMessageDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + messageId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * [deprecated] Create reaction + * @description [deprecated] Please use [this route](/docs/api/reactions/ChannelMessageReactionCreate) instead + */ + ContentReactionCreate: { + parameters: { + path: { + /** + * @description Channel ID where the content exists + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + /** + * @description Content ID of the content + * @example 00000000-0000-0000-0000-000000000000 + */ + contentId: string; + /** + * @description Emote ID to apply + * @example 90000000 + */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * [deprecated] Delete reaction + * @description [deprecated] Please use [this route](/docs/api/reactions/ChannelMessageReactionDelete) instead + */ + ContentReactionDelete: { + parameters: { + path: { + /** + * @description Channel ID where the content exists + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + /** + * @description Content ID of the content + * @example 00000000-0000-0000-0000-000000000000 + */ + contentId: string; + /** + * @description Emote ID to remove + * @example 90000000 + */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Add member to group */ + GroupMembershipCreate: { + parameters: { + path: { + /** + * @description Group ID to add the member to + * @example AAAAAAA + */ + groupId: string; + /** + * @description Member ID to add to the group + * @example Ann6LewA + */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Remove member from group */ + GroupMembershipDelete: { + parameters: { + path: { + /** + * @description Group ID to remove the member from + * @example AAAAAAA + */ + groupId: string; + /** + * @description Member ID to remove from the group + * @example Ann6LewA + */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Set a member's XP */ + ServerXpForUserUpdate: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description Member ID to set XP to + * @example Ann6LewA + */ + userId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "total": 42 + * } + */ + "application/json": { + /** @description The total XP to set on the user */ + total: number; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + /** @description The total XP after this operation */ + total: number; + }; + }; + }; + }; + }; + /** Award XP to a member */ + ServerXpForUserCreate: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description Member ID to award XP to + * @example Ann6LewA + */ + userId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "amount": 42 + * } + */ + "application/json": { + /** + * Amount + * @description The amount of XP to award + */ + amount: number; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + /** @description The total XP after this operation */ + total: number; + }; + }; + }; + }; + }; + /** + * Award XP to role + * @description Award XP to all members with a particular role. + */ + ServerXpForRoleCreate: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description Role ID to award XP to + * @example 1 + */ + roleId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "amount": 42 + * } + */ + "application/json": { + /** + * Amount + * @description The amount of XP to award + */ + amount: number; + }; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Assign role to member */ + RoleMembershipCreate: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description The ID of the member that the role should be assigned to + * @example Ann6LewA + */ + userId: string; + /** + * @description The role ID to apply to the user + * @example 1 + */ + roleId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Remove role from member */ + RoleMembershipDelete: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description The ID of the member that the role should be removed from + * @example Ann6LewA + */ + userId: string; + /** + * @description The role ID to remove from the user + * @example 1 + */ + roleId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * Get member roles + * @description Get a list of the roles assigned to a member + */ + RoleMembershipReadMany: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description The ID of the member to obtain roles from + * @example Ann6LewA + */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + /** + * Role IDs + * @description The IDs of the roles that the member currently has + */ + roleIds: number[]; + }; + }; + }; + }; + }; + /** Get forum topics */ + ForumTopicReadMany: { + parameters: { + query: { + /** @example 2021-06-15T20:15:00.706Z */ + before?: string; + /** @example 25 */ + limit?: number; + }; + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + forumTopics: components["schemas"]["ForumTopicSummary"][]; + }; + }; + }; + }; + }; + /** Create a topic in a forum */ + ForumTopicCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "title": "Welcome new members!!", + * "content": "Please introduce yourself in this topic!!!" + * } + */ + "application/json": { + /** + * Title + * @description The title of the forum topic + */ + title: string; + /** + * Content + * @description The content of the forum topic + */ + content: Record | string; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + }; + }; + /** Get a forum topic */ + ForumTopicRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + }; + }; + /** Delete a forum topic */ + ForumTopicDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Update a forum topic */ + ForumTopicUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "title": "Welcome new members!!", + * "content": "Please introduce yourself in this topic!!!" + * } + */ + "application/json": { + /** + * Title + * @description The title of the forum topic + */ + title?: string; + /** + * Content + * Format: markdown + * @description The content of the forum topic + */ + content?: string; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + }; + }; + /** Pin a forum topic */ + ForumTopicPin: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Unpin a forum topic */ + ForumTopicUnpin: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Create forum topic reaction */ + ForumTopicReactionCreate: { + parameters: { + path: { + /** + * @description Channel ID where the forum topic exists + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + /** @description Forum Topic ID */ + forumTopicId: number; + /** + * @description Emote ID to apply + * @example 90000000 + */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete forum topic reaction */ + ForumTopicReactionDelete: { + parameters: { + path: { + /** + * @description Channel ID where the forum topic exists + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + /** @description Forum Topic ID */ + forumTopicId: number; + /** + * @description Emote ID to remove + * @example 90000000 + */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Lock a forum topic */ + ForumTopicLock: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Unlock a forum topic */ + ForumTopicUnlock: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Get a forum topic's comments */ + ForumTopicCommentReadMany: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + forumTopicComments: components["schemas"]["ForumTopicComment"][]; + }; + }; + }; + }; + }; + /** Create a forum topic comment */ + ForumTopicCommentCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "Great idea!" + * } + */ + "application/json": { + /** + * Content + * Format: markdown + * @description The content of the forum topic comment + */ + content: string; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + forumTopicComment: components["schemas"]["ForumTopicComment"]; + }; + }; + }; + }; + }; + /** Get a comment on a forum topic */ + ForumTopicCommentRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + forumTopicCommentId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + forumTopicComment: components["schemas"]["ForumTopicComment"]; + }; + }; + }; + }; + }; + /** Delete a forum topic comment */ + ForumTopicCommentDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + forumTopicCommentId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Update a forum topic comment */ + ForumTopicCommentUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + forumTopicId: number; + forumTopicCommentId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "Please introduce yourself in this topic!!!" + * } + */ + "application/json": { + /** + * Content + * Format: markdown + * @description The content of the forum topic + */ + content?: string; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + forumTopicComment: components["schemas"]["ForumTopicComment"]; + }; + }; + }; + }; + }; + /** Get list items within a channel */ + ListItemReadMany: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + listItems: components["schemas"]["ListItemSummary"][]; + }; + }; + }; + }; + }; + /** Create a list item */ + ListItemCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "message": "Create TODO list", + * "note": { + * "content": "I really need to stop putting this off" + * } + * } + */ + "application/json": { + /** + * Message + * @description The message of the list item + */ + message: string; + note?: { + /** + * Note + * @description The note of the list item + */ + content: string; + }; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + listItem: components["schemas"]["ListItem"]; + }; + }; + }; + }; + }; + /** Get a list item */ + ListItemRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + listItemId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + listItem: components["schemas"]["ListItem"]; + }; + }; + }; + }; + }; + /** + * [deprecated] Update a list item + * @description Deprecating this route in favor of the *patch* route + */ + ListItemUpdateDeprecated: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + listItemId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "message": "Create TODO list", + * "note": { + * "content": "I really need to stop putting this off" + * } + * } + */ + "application/json": { + /** + * Message + * Format: markdown + * @description The message of the list item + */ + message: string; + note?: { + /** + * Note + * Format: markdown + * @description The note of the list item + */ + content: string; + } | null; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + listItem: components["schemas"]["ListItem"]; + }; + }; + }; + }; + }; + /** Delete a list item */ + ListItemDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + listItemId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Update a list item */ + ListItemUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + listItemId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "message": "Create TODO list", + * "note": { + * "content": "I really need to stop putting this off" + * } + * } + */ + "application/json": { + /** + * Message + * Format: markdown + * @description The message of the list item + */ + message?: string; + note?: { + /** + * Note + * Format: markdown + * @description The note of the list item + */ + content: string; + } | null; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + listItem: components["schemas"]["ListItem"]; + }; + }; + }; + }; + }; + /** Complete a list item */ + ListItemCompleteCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + listItemId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Uncomplete a list item */ + ListItemCompleteDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + listItemId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Retrieves a member's public social links */ + MemberSocialLinkRead: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** @example Ann6LewA */ + userId: string; + /** @description The type of social link to retrieve */ + socialLinkType: + | "twitch" + | "bnet" + | "psn" + | "xbox" + | "steam" + | "origin" + | "youtube" + | "twitter" + | "facebook" + | "switch" + | "patreon" + | "roblox" + | "epic"; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + socialLink: components["schemas"]["SocialLink"]; + }; + }; + }; + }; + }; + /** Update a member's nickname */ + MemberNicknameUpdate: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description The ID of the user to update nickname for + * @example Ann6LewA + */ + userId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "nickname": "Professor Chaos" + * } + */ + "application/json": { + /** + * Nickname + * @description The nickname to assign to the member + */ + nickname: string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + /** + * Nickname + * @description The nickname that was assigned to the member + */ + nickname: string; + }; + }; + }; + }; + }; + /** Delete a member's nickname */ + MemberNicknameDelete: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description The ID of the user to remove nickname from + * @example Ann6LewA + */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * Create a channel + * @description Only server channels are supported at this time (coming soon™: DM Channels!) + */ + ChannelCreate: { + requestBody: { + content: { + /** + * @example { + * "name": "The Dank Cellar", + * "type": "chat" + * } + */ + "application/json": { + /** @description The name of the channel */ + name: string; + /** @description The topic of the channel */ + topic?: string; + /** + * Is public + * @description Whether the channel can be accessed from users who are not member of the server + * @default false + */ + isPublic?: boolean; + /** + * @description The type of channel to create + * @enum {string} + */ + type: + | "announcements" + | "chat" + | "calendar" + | "forums" + | "media" + | "docs" + | "voice" + | "list" + | "scheduling" + | "stream"; + /** + * Server ID + * @description The server that the channel should be created in. Optional if providing a `groupId` or `categoryId` + */ + serverId?: string; + /** + * Group ID + * @description The group that the channel should be created in. If not provided, channel will be created in the "Server home" group from `serverId` _or_ in the group that corresponds to the `categoryId` parameter + */ + groupId?: string; + /** @description The category the channel should go in. If not provided, channel will be a top-level channel */ + categoryId?: number; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + channel: components["schemas"]["ServerChannel"]; + }; + }; + }; + }; + }; + /** + * Get a channel + * @description Only server channels are supported at this time (coming soon™: DM Channels!) + */ + ChannelRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + channel: components["schemas"]["ServerChannel"]; + }; + }; + }; + }; + }; + /** + * Delete a channel + * @description Only server channels are supported at this time (coming soon™: DM Channels!) + */ + ChannelDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * Update a channel + * @description Only server channels are supported at this time (coming soon™: DM Channels!) + */ + ChannelUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "name": "The Even Danker Cellar", + * "topic": "Only the dankest of memes please", + * "isPublic": true + * } + */ + "application/json": { + /** @description The name of the channel or thread */ + name?: string; + /** @description The topic of the channel. Not applicable to threads */ + topic?: string | null; + /** + * Is public + * @description Whether the channel can be accessed from users who are not member of the server. Not applicable to threads + */ + isPublic?: boolean; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + channel: components["schemas"]["ServerChannel"]; + }; + }; + }; + }; + }; + /** + * Get docs + * @description Results returned will be ordered descending by the doc's `updatedAt`. `before` will filter based on the doc's `updatedAt` + */ + DocReadMany: { + parameters: { + query: { + /** @example 2021-06-15T20:15:00.706Z */ + before?: string; + /** @example 25 */ + limit?: number; + }; + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + docs: components["schemas"]["Doc"][]; + }; + }; + }; + }; + }; + /** Create a doc */ + DocCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "title": "HOW-TO: Smoke These Meats with Sweet Baby Ray's", + * "content": "Spicy jalapeno bacon ipsum dolor amet sirloin ground round short loin, meatball brisket capicola tri-tip ham pork belly biltong corned beef chuck. Chicken ham brisket shank rump buffalo t-bone. Short loin sausage buffalo porchetta pork belly rump tri-tip frankfurter tail pork chop cow sirloin. Pancetta porchetta tail ball tip chislic beef ribs. Buffalo andouille leberkas jerky. Fatback shankle andouille beef. Cow kielbasa buffalo pork loin chislic meatloaf short loin rump meatball prosciutto." + * } + */ + "application/json": { + /** + * Title + * @description The title of the doc + */ + title: string; + /** + * Content + * @description The content of the doc + */ + content: Record | string; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + doc: components["schemas"]["Doc"]; + }; + }; + }; + }; + }; + /** Get a doc */ + DocRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + doc: components["schemas"]["Doc"]; + }; + }; + }; + }; + }; + /** Update a doc */ + DocUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "title": "HOW-TO: Smoke These Meats with Sweet Baby Ray's", + * "content": "Spicy jalapeno bacon ipsum dolor amet sirloin ground round short loin, meatball brisket capicola tri-tip ham pork belly biltong corned beef chuck. Chicken ham brisket shank rump buffalo t-bone. Short loin sausage buffalo porchetta pork belly rump tri-tip frankfurter tail pork chop cow sirloin. Pancetta porchetta tail ball tip chislic beef ribs. Buffalo andouille leberkas jerky. Fatback shankle andouille beef. Cow kielbasa buffalo pork loin chislic meatloaf short loin rump meatball prosciutto." + * } + */ + "application/json": { + /** + * Title + * @description The title of the doc + */ + title: string; + /** + * Content + * Format: markdown + * @description The content of the doc + */ + content: string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + doc: components["schemas"]["Doc"]; + }; + }; + }; + }; + }; + /** Delete a doc */ + DocDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Get a server member */ + ServerMemberRead: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** @example Ann6LewA */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + member: components["schemas"]["ServerMember"]; + }; + }; + }; + }; + }; + /** + * Kick a server member + * @description This route can be used to leave servers by passing in your own user ID or `@me` for `userId` + */ + ServerMemberDelete: { + parameters: { + path: { + /** + * @description The ID of the server to kick the user from + * @example wlVr3Ggl + */ + serverId: string; + /** + * @description The ID of the user to kick. If the value provided here is your own user's ID, the request will attempt to make you leave the server + * @example Ann6LewA + */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * Get members of a server + * @description Results returned will be ordered ascending by the member's `joinedAt` + */ + ServerMemberReadMany: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + members: components["schemas"]["ServerMemberSummary"][]; + }; + }; + }; + }; + }; + /** Get a server ban */ + ServerMemberBanRead: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description The ID of the user to get a server ban for + * @example Ann6LewA + */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + serverMemberBan: components["schemas"]["ServerMemberBan"]; + }; + }; + }; + }; + }; + /** + * Create a server ban + * @description Also known as banning a server member + */ + ServerMemberBanCreate: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description The ID of the user to ban from this server + * @example Ann6LewA + */ + userId: string; + }; + }; + requestBody?: { + content: { + /** + * @example { + * "reason": "More toxic than a poison Pokémon" + * } + */ + "application/json": { + /** + * Reason + * @description The reason for the ban + */ + reason?: string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + serverMemberBan: components["schemas"]["ServerMemberBan"]; + }; + }; + }; + }; + }; + /** + * Delete a server ban + * @description Also known as unbanning a server member + */ + ServerMemberBanDelete: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** + * @description The ID of the user to unban from this server + * @example Ann6LewA + */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Get server bans */ + ServerMemberBanReadMany: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + serverMemberBans: components["schemas"]["ServerMemberBan"][]; + }; + }; + }; + }; + }; + /** + * Get a server's webhooks + * @description Get a list of webhooks from a server. + */ + WebhookReadMany: { + parameters: { + query: { + /** + * @description ID of the channel you want to filter for webhooks + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + }; + path: { + /** @example wlVr3Ggl */ + serverId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + webhooks: components["schemas"]["Webhook"][]; + }; + }; + }; + }; + }; + /** Create a webhook */ + WebhookCreate: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "name": "Game patch webhook" + * } + */ + "application/json": { + /** + * Name + * @description The name of the webhook + */ + name: string; + /** + * Channel ID + * Format: uuid + * @description Channel ID to create the webhook in + */ + channelId: string; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + webhook: components["schemas"]["Webhook"]; + }; + }; + }; + }; + }; + /** Get a server's webhook */ + WebhookRead: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + webhookId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + webhook: components["schemas"]["Webhook"]; + }; + }; + }; + }; + }; + /** Update a webhook */ + WebhookUpdate: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + webhookId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "name": "Better name webhook" + * } + */ + "application/json": { + /** + * Name + * @description The name of the webhook + */ + name: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId?: string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + webhook: components["schemas"]["Webhook"]; + }; + }; + }; + }; + }; + /** Delete a server webhook */ + WebhookDelete: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + webhookId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * Get a server + * @description Fetch various information about a given server. Currently, the bot must be a member of the server in order to fetch its information. + */ + ServerRead: { + parameters: { + path: { + /** @example wlVr3Ggl */ + serverId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + server: components["schemas"]["Server"]; + }; + }; + }; + }; + }; + /** + * Get calendar events + * @description Results returned will be ordered ascending by the event's `startsAt`. `before` and `after` will filter based on the event's `startsAt` + */ + CalendarEventReadMany: { + parameters: { + query: { + /** @example 2021-06-15T20:15:00.706Z */ + before?: string; + /** @example 2021-06-15T20:15:00.706Z */ + after?: string; + /** @example 25 */ + limit?: number; + }; + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEvents: components["schemas"]["CalendarEvent"][]; + }; + }; + }; + }; + }; + /** + * Create a calendar event + * @description We currently do not have a way to surface the `repeatInfo` after event series are updated. Stay tuned! + */ + CalendarEventCreate: { + parameters: { + path: { + /** + * @description The calendar to create the event in + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "name": "Surprise LAN party for my wife 🤫", + * "description": "**Don't say anything to her!** She's gonna love playing Call of Duty all night", + * "location": "My house!", + * "url": "https://www.surprisepartygame.com/", + * "color": 16106496, + * "startsAt": "2022-06-16T00:00:00.000Z", + * "duration": 60 + * } + */ + "application/json": { + /** + * Name + * @description The name of the event + */ + name: string; + /** + * Description + * Format: markdown + * @description The description of the event + */ + description?: string; + /** + * Location + * @description The location of the event + */ + location?: string; + /** + * Starts at + * Format: date-time + * @description The ISO 8601 timestamp that the event starts at + */ + startsAt?: string; + /** + * Format: uri + * @description A URL to associate with the event + */ + url?: string; + /** @description The color of the event when viewing in the calendar */ + color?: number; + /** + * Is all day + * @description Does the event last all day? If passed with `duration`, `duration` will only be applied if it is an interval of minutes represented in days (e.g., `duration: 2880`) + */ + isAllDay?: boolean; + /** + * RSVP disabled + * @description When disabled, users will not be able to RSVP to the event + */ + rsvpDisabled?: boolean; + /** @description The number of RSVPs to allow before waitlisting RSVPs */ + rsvpLimit?: number; + /** @description When `rsvpLimit` is set, users from the waitlist will be added as space becomes available in the event */ + autofillWaitlist?: boolean; + /** + * Duration + * @description The duration of the event _**in minutes**_ + */ + duration?: number; + /** Is private */ + isPrivate?: boolean; + /** + * Role IDs + * @description The role IDs to restrict the event to + */ + roleIds?: number[]; + repeatInfo?: { + /** + * Repeat Type + * @description How often you want your event to repeat (important note: this will repeat for the next 180 days unless custom is defined) + * @default once + * @enum {string} + */ + type: "once" | "everyDay" | "everyWeek" | "everyMonth" | "custom"; + /** @description Apply further clarification to your events. This **must** have `type` set to `custom` */ + every?: { + /** + * Count + * @description How often between your interval the event should repeat. For example, 1 would be every interval, 2 would be every second occurrence of the interval + */ + count: number; + /** + * Interval + * @description Coupled with `count`, this indicates the time range you are repeating your event over + * @enum {string} + */ + interval: "day" | "month" | "year" | "week"; + }; + /** + * Occurrences + * @description Used to control the end date of the event repeat (only used when `type` is `custom`; if used with `endDate`, the earliest resultant date of the two will be used) + */ + endsAfterOccurrences?: number; + /** + * Ends at + * Format: date-time + * @description The ISO 8601 timestamp that the event ends at. Used to control the end date of the event repeat (only used when `type` is `custom`; if used with `endsAfterOccurrences`, the earliest resultant date of the two will be used) + */ + endDate?: string; + /** @description Used to control the day of the week that the event should repeat on (only used when `type` is `custom` and when `every.interval` is `week`) */ + on?: ( + | "sunday" + | "monday" + | "tuesday" + | "wednesday" + | "thursday" + | "friday" + | "saturday" + )[]; + }; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEvent: components["schemas"]["CalendarEvent"]; + }; + }; + }; + }; + }; + /** Get a calendar event */ + CalendarEventRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEvent: components["schemas"]["CalendarEvent"]; + }; + }; + }; + }; + }; + /** Delete a calendar event */ + CalendarEventDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * Update a calendar event + * @description We currently do not have a way to surface the `repeatInfo` after event series are updated. Stay tuned! + */ + CalendarEventUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "name": "Surprise LAN party for my wife 🤫", + * "description": "**Don't say anything to her!** She's gonna love playing Call of Duty all night", + * "location": "My house!", + * "url": "https://www.surprisepartygame.com/", + * "color": 16106496, + * "startsAt": "2022-06-16T00:00:00.000Z", + * "duration": 60 + * } + */ + "application/json": { + /** + * Name + * @description The name of the event + */ + name?: string; + /** + * Description + * Format: markdown + * @description The description of the event + */ + description?: string; + /** + * Location + * @description The location of the event + */ + location?: string; + /** + * Starts at + * Format: date-time + * @description The ISO 8601 timestamp that the event starts at + */ + startsAt?: string; + /** + * Format: uri + * @description A URL to associate with the event + */ + url?: string; + /** @description The color of the event when viewing in the calendar */ + color?: number; + /** + * Is all day + * @description Does the event last all day? If passed with `duration`, `duration` will only be applied if it is an interval of minutes represented in days (e.g., `duration: 2880`) + */ + isAllDay?: boolean; + /** + * RSVP disabled + * @description When disabled, users will not be able to RSVP to the event + */ + rsvpDisabled?: boolean; + /** @description The number of RSVPs to allow before waitlisting RSVPs */ + rsvpLimit?: number; + /** @description When `rsvpLimit` is set, users from the waitlist will be added as space becomes available in the event */ + autofillWaitlist?: boolean; + /** + * Duration + * @description The duration of the event _**in minutes**_ + */ + duration?: number; + /** Is private */ + isPrivate?: boolean; + /** + * Role IDs + * @description The role IDs to restrict the event to. Passing an empty array will clear the role IDs on the event + */ + roleIds?: number[]; + cancellation?: { + /** + * Description + * Format: markdown + * @description The description of event cancellation + */ + description?: string; + }; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEvent: components["schemas"]["CalendarEvent"]; + }; + }; + }; + }; + }; + /** Get a calendar event RSVP */ + CalendarEventRsvpRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example Ann6LewA */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEventRsvp: components["schemas"]["CalendarEventRsvp"]; + }; + }; + }; + }; + }; + /** Create or update a calendar event RSVP */ + CalendarEventRsvpUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example Ann6LewA */ + userId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "status": "going" + * } + */ + "application/json": { + /** + * Status + * @description The status of the RSVP + * @enum {string} + */ + status: "going" | "maybe" | "declined" | "invited"; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEventRsvp: components["schemas"]["CalendarEventRsvp"]; + }; + }; + }; + }; + }; + /** Delete a calendar event RSVP */ + CalendarEventRsvpDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example Ann6LewA */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Get calendar event RSVPs */ + CalendarEventRsvpReadMany: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEventRsvps: components["schemas"]["CalendarEventRsvp"][]; + }; + }; + }; + }; + }; + /** Create or update a calendar event RSVP for multiple users */ + CalendarEventRsvpUpdateMany: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + }; + }; + requestBody: { + content: { + "application/json": { + /** User IDs */ + userIds: string[]; + /** + * Status + * @description The status of the RSVP + * @enum {string} + */ + status: "going" | "maybe" | "declined" | "invited"; + }; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * Get a user + * @description **Note** - at this time, you can only retrieve your own user + */ + UserRead: { + parameters: { + path: { + /** @example Ann6LewA */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + user: components["schemas"]["User"]; + }; + }; + }; + }; + }; + /** Create forum topic comment reaction */ + ForumTopicCommentReactionCreate: { + parameters: { + path: { + /** + * @description Channel ID where the forum topic exists + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + forumTopicId: number; + forumTopicCommentId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete forum topic comment reaction */ + ForumTopicCommentReactionDelete: { + parameters: { + path: { + /** + * @description Channel ID where the forum topic exists + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + forumTopicId: number; + forumTopicCommentId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Get a calendar event's comments */ + CalendarEventCommentReadMany: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEventComments: components["schemas"]["CalendarEventComment"][]; + }; + }; + }; + }; + }; + /** Create a comment on an event */ + CalendarEventCommentCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "I will be there!!" + * } + */ + "application/json": { + /** + * Content + * Format: markdown + * @description The content of the calendar event comment + */ + content: string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEventComment: components["schemas"]["CalendarEventComment"]; + }; + }; + }; + }; + }; + /** Get a comment on the calendar event */ + CalendarEventCommentRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example 1 */ + calendarEventCommentId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEventComment: components["schemas"]["CalendarEventComment"]; + }; + }; + }; + }; + }; + /** Delete a calendar event comment */ + CalendarEventCommentDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example 1 */ + calendarEventCommentId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Update a calendar event comment */ + CalendarEventCommentUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example 1 */ + calendarEventCommentId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "I will be there!!" + * } + */ + "application/json": { + /** + * Content + * Format: markdown + * @description The content of the calendar event comment + */ + content: string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + calendarEventComment: components["schemas"]["CalendarEventComment"]; + }; + }; + }; + }; + }; + /** Create calendar event reaction */ + CalendarEventReactionCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete calendar event reaction */ + CalendarEventReactionDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Create calendar event comment reaction */ + CalendarEventCommentReactionCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example 1 */ + calendarEventCommentId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete calendar event comment reaction */ + CalendarEventCommentReactionDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + calendarEventId: number; + /** @example 1 */ + calendarEventCommentId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Get a doc's comments */ + DocCommentReadMany: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + docComments: components["schemas"]["DocComment"][]; + }; + }; + }; + }; + }; + /** Create a comment on a doc */ + DocCommentCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "Wow, cool document!!!" + * } + */ + "application/json": { + /** + * Content + * Format: markdown + * @description The content of the doc comment + */ + content: string; + }; + }; + }; + responses: { + /** @description Success */ + 201: { + content: { + "application/json": { + docComment: components["schemas"]["DocComment"]; + }; + }; + }; + }; + }; + /** Get a comment on a doc */ + DocCommentRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + /** @example 1 */ + docCommentId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + docComment: components["schemas"]["DocComment"]; + }; + }; + }; + }; + }; + /** Delete a doc comment */ + DocCommentDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + /** @example 1 */ + docCommentId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Update a doc comment */ + DocCommentUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + /** @example 1 */ + docCommentId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "Wow, cool document!!!" + * } + */ + "application/json": { + /** + * Content + * Format: markdown + * @description The content of the doc comment + */ + content: string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + docComment: components["schemas"]["DocComment"]; + }; + }; + }; + }; + }; + /** Create doc reaction */ + DocReactionCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete doc reaction */ + DocReactionDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Create doc comment reaction */ + DocCommentReactionCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + /** @example 1 */ + docCommentId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete doc comment reaction */ + DocCommentReactionDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 1 */ + docId: number; + /** @example 1 */ + docCommentId: number; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete a calendar event series */ + CalendarEventSeriesDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + calendarEventSeriesId: string; + }; + }; + requestBody?: { + content: { + "application/json": { + /** + * Calendar event ID + * @description Control the deletion of the series from the `calendarEventId` forward. If not defined, it will delete all events + */ + calendarEventId?: number; + }; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Update a calendar event series */ + CalendarEventSeriesUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + calendarEventSeriesId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "name": "Surprise LAN party for my wife 🤫", + * "description": "**Don't say anything to her!** She's gonna love playing Call of Duty all night", + * "location": "My house!", + * "url": "https://www.surprisepartygame.com/", + * "color": 16106496, + * "startsAt": "2022-06-16T00:00:00.000Z", + * "duration": 60 + * } + */ + "application/json": { + /** + * Name + * @description The name of the event + */ + name?: string; + /** + * Description + * Format: markdown + * @description The description of the event + */ + description?: string; + /** + * Location + * @description The location of the event + */ + location?: string; + /** + * Starts at + * Format: date-time + * @description The ISO 8601 timestamp that the event starts at + */ + startsAt?: string; + /** + * Format: uri + * @description A URL to associate with the event + */ + url?: string; + /** @description The color of the event when viewing in the calendar */ + color?: number; + /** + * Is all day + * @description Does the event last all day? If passed with `duration`, `duration` will only be applied if it is an interval of minutes represented in days (e.g., `duration: 2880`) + */ + isAllDay?: boolean; + /** + * RSVP disabled + * @description When disabled, users will not be able to RSVP to the event + */ + rsvpDisabled?: boolean; + /** @description The number of RSVPs to allow before waitlisting RSVPs */ + rsvpLimit?: number; + /** @description When `rsvpLimit` is set, users from the waitlist will be added as space becomes available in the event */ + autofillWaitlist?: boolean; + /** + * Duration + * @description The duration of the event _**in minutes**_ + */ + duration?: number; + /** Is private */ + isPrivate?: boolean; + /** + * Role IDs + * @description The role IDs to restrict the event to. Passing an empty array will clear the role IDs on the event + */ + roleIds?: number[]; + repeatInfo?: { + /** + * Repeat Type + * @description How often you want your event to repeat (important note: this will repeat for the next 180 days unless custom is defined) + * @default once + * @enum {string} + */ + type: "once" | "everyDay" | "everyWeek" | "everyMonth" | "custom"; + /** @description Apply further clarification to your events. This **must** have `type` set to `custom` */ + every?: { + /** + * Count + * @description How often between your interval the event should repeat. For example, 1 would be every interval, 2 would be every second occurrence of the interval + */ + count: number; + /** + * Interval + * @description Coupled with `count`, this indicates the time range you are repeating your event over + * @enum {string} + */ + interval: "day" | "month" | "year" | "week"; + }; + /** + * Occurrences + * @description Used to control the end date of the event repeat (only used when `type` is `custom`; if used with `endDate`, the earliest resultant date of the two will be used) + */ + endsAfterOccurrences?: number; + /** + * Ends at + * Format: date-time + * @description The ISO 8601 timestamp that the event ends at. Used to control the end date of the event repeat (only used when `type` is `custom`; if used with `endsAfterOccurrences`, the earliest resultant date of the two will be used) + */ + endDate?: string; + /** @description Used to control the day of the week that the event should repeat on (only used when `type` is `custom` and when `every.interval` is `week`) */ + on?: ( + | "sunday" + | "monday" + | "tuesday" + | "wednesday" + | "thursday" + | "friday" + | "saturday" + )[]; + }; + /** + * Calendar event ID + * @description Control the updating of the series from the `calendarEventId` forward. If not defined, it will edit all events + */ + calendarEventId?: number; + }; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** + * Get announcements + * @description Results returned will be ordered ascending by the announcement's `createdAt`. `before` will filter based on the announcement's `createdAt` + */ + AnnouncementReadMany: { + parameters: { + query: { + /** @example 2021-06-15T20:15:00.706Z */ + before?: string; + /** @example 25 */ + limit?: number; + }; + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + announcements: components["schemas"]["Announcement"][]; + }; + }; + }; + }; + }; + /** Create an announcement */ + AnnouncementCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "title": "Pizza Party, don't be tardy!", + * "content": "Grab a slice, don't be slow, At our pizza party, it's the way to go! Toppings galore, cheesy delight, Come join us, it'll be out of sight!" + * } + */ + "application/json": { + /** + * Title + * @description The title of the announcement + */ + title: string; + /** + * Content + * @description The content of the announcement + */ + content: Record | string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + announcement: components["schemas"]["Announcement"]; + }; + }; + }; + }; + }; + /** Read an announcement */ + AnnouncementRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + announcement: components["schemas"]["Announcement"]; + }; + }; + }; + }; + }; + /** Delete an announcement */ + AnnouncementDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Update an announcement */ + AnnouncementUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "title": "Pizza Party, don't be tardy!", + * "content": "Grab a slice, don't be slow, At our pizza party, it's the way to go! Toppings galore, cheesy delight, Come join us, it'll be out of sight!" + * } + */ + "application/json": { + /** + * Title + * @description The title of the announcement + */ + title?: string; + /** + * Content + * @description The content of the announcement + */ + content?: Record | string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + announcement: components["schemas"]["Announcement"]; + }; + }; + }; + }; + }; + /** + * Get a users servers + * @description **Note** - at this time, you can only retrieve your own servers + */ + UserServerReadMany: { + parameters: { + path: { + /** @example Ann6LewA */ + userId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + servers: components["schemas"]["Server"][]; + }; + }; + }; + }; + }; + /** Create announcement reaction */ + AnnouncementReactionCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + /** + * @description Emote ID to apply + * @example 90000000 + */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete announcement reaction */ + AnnouncementReactionDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + /** + * @description Emote ID to apply + * @example 90000000 + */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Get an announcement's comments */ + AnnouncementCommentReadMany: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + announcementComments: components["schemas"]["AnnouncementComment"][]; + }; + }; + }; + }; + }; + /** Create a comment on an announcement */ + AnnouncementCommentCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "Now THAT is one awesome announcement!!!" + * } + */ + "application/json": { + /** + * Content + * Format: markdown + * @description The content of the announcement comment + */ + content: string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + announcementComment: components["schemas"]["AnnouncementComment"]; + }; + }; + }; + }; + }; + /** Get a comment on the announcement */ + AnnouncementCommentRead: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + /** @example 1 */ + announcementCommentId: number; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + announcementComment: components["schemas"]["AnnouncementComment"]; + }; + }; + }; + }; + }; + /** Delete an announcement comment */ + AnnouncementCommentDelete: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + /** @example 1 */ + announcementCommentId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Update an announcement comment */ + AnnouncementCommentUpdate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + /** @example 1 */ + announcementCommentId: number; + }; + }; + requestBody: { + content: { + /** + * @example { + * "content": "Now THAT is one awesome announcement!!!" + * } + */ + "application/json": { + /** + * Content + * Format: markdown + * @description The content of the announcement comment + */ + content: string; + }; + }; + }; + responses: { + /** @description Success */ + 200: { + content: { + "application/json": { + announcementComment: components["schemas"]["AnnouncementComment"]; + }; + }; + }; + }; + }; + /** Create an announcement comment reaction */ + AnnouncementCommentReactionCreate: { + parameters: { + path: { + /** + * @description Channel ID where the announcement comment exists + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + /** @example 1 */ + announcementCommentId: number; + /** + * @description Emote ID to apply + * @example 90000000 + */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete an announcement comment reaction */ + AnnouncementCommentReactionDelete: { + parameters: { + path: { + /** + * @description Channel ID where the announcement comment exists + * @example 00000000-0000-0000-0000-000000000000 + */ + channelId: string; + /** @example AAAAAAA */ + announcementId: string; + /** @example 1 */ + announcementCommentId: number; + /** + * @description Emote ID to apply + * @example 90000000 + */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Create a message reaction */ + ChannelMessageReactionCreate: { + parameters: { + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + messageId: string; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Delete a message reaction */ + ChannelMessageReactionDelete: { + parameters: { + query: { + /** @example Ann6LewA */ + userId?: string; + }; + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + messageId: string; + /** @example 90000000 */ + emoteId: number; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; + /** Bulk delete a message's reactions */ + ChannelMessageReactionDeleteMany: { + parameters: { + query: { + /** @example 90000000 */ + emoteId?: number; + }; + path: { + /** @example 00000000-0000-0000-0000-000000000000 */ + channelId: string; + /** @example 00000000-0000-0000-0000-000000000000 */ + messageId: string; + }; + }; + responses: { + /** @description Success */ + 204: never; + }; + }; +} diff --git a/packages/guilded-api-typings/lib/v1/rest/CalendarEvent.ts b/packages/guilded-api-typings/lib/v1/rest/CalendarEvent.ts deleted file mode 100644 index b1ef680c..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/CalendarEvent.ts +++ /dev/null @@ -1,110 +0,0 @@ -import type { - CalendarEventPayload, - CalendarEventRsvpPayload, -} from "../structs/CalendarEvent"; - -/** - * POST - * /channels/:channelId/events - */ -export type RESTPostCalendarEventBody = { - color?: number; - description?: string; - duration?: number; - isPrivate?: boolean; - location?: string; - name: string; - rsvpLimit?: number; - startsAt?: string; - url?: string; -}; -export type RESTPostCalendarEventResult = { - calendarEvent: CalendarEventPayload; -}; - -/** - * GET - * /channels/:channelId/events - */ -export type RESTGetCalendarEventsBody = { - after?: string; - before?: string; - limit?: number; -}; -export type RESTGetCalendarEventsResult = { - calendarEvents: CalendarEventPayload[]; -}; - -/** - * GET - * /channels/:channelId/events/:calendarEventId - */ -export type RESTGetCalendarEventResult = { - calendarEvent: CalendarEventPayload; -}; - -/** - * PATCH - * /channels/:channelId/events/:calendarEventsId - */ -export type RESTPatchCalendarEventBody = { - color?: number; - description?: string; - duration?: number; - isPrivate?: boolean; - location?: string; - name?: string; - startsAt?: string; - url?: string; -}; -export type RESTPatchCalendarEventResult = { - calendarEvent: CalendarEventPayload; -}; - -/** - * DELETE - * /channels/:channelId/events/:calendarEventId - */ -export type RESTDeleteCalendarEventResult = never; - -/** - * GET - * /channels/:channelId/events/:calendarEventId/rsvps - */ -export type RESTGetCalendarEventRsvpsResult = { - calendarEventRsvps: CalendarEventRsvpPayload[]; -}; - -/** - * GET - * /channels/:channelId/events/:calendarEventId/rsvps/:userId - */ -export type RESTGetCalendarEventRsvpResult = { - calendarEventRsvp: CalendarEventRsvpPayload; -}; - -/** - * PATCH - * /channels/:channelId/events/:calendarEventId/rsvps/:userId - */ -export type RESTPatchCalendarEventRsvpBody = { - status: string; -}; -export type RESTPatchCalendarEventRsvpResult = { - calendarEventRsvp: CalendarEventRsvpPayload; -}; - -/** - * PATCH - * /channels/:channelId/events/:calendarEventId/rsvps - */ -export type RESTPatchCalendarEventRsvpManyBody = { - status: string; - userIds: string[]; -}; -export type RESTPatchCalendarEventRsvpManyResult = never; -/** - * DELETE - * /channels/:channelId/events/:calendarEventId/rsvps/:userId - */ -export type RESTDeleteCalendarEventRsvpResult = never; diff --git a/packages/guilded-api-typings/lib/v1/rest/Channel.ts b/packages/guilded-api-typings/lib/v1/rest/Channel.ts deleted file mode 100644 index 1fb2433c..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Channel.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { ChannelType, ServerChannelPayload } from "../structs/Channel"; - -export type RESTPostChannelsBody = { - categoryId?: number; - groupId?: string; - isPublic?: boolean; - name: string; - serverId: string; - topic?: string; - type: ChannelType; -}; - -export type RESTPostChannelsResult = { - channel: ServerChannelPayload; -}; - -export type RESTPatchChannelBody = Pick & { name?: string }; - -export type RESTGetChannelResult = RESTPostChannelsResult; -export type RESTPatchChannelResult = RESTPostChannelsResult; -export type RESTDeleteChannelResult = never; diff --git a/packages/guilded-api-typings/lib/v1/rest/Doc.ts b/packages/guilded-api-typings/lib/v1/rest/Doc.ts deleted file mode 100644 index f86a1dea..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Doc.ts +++ /dev/null @@ -1,47 +0,0 @@ -import type { DocPayload } from "../structs/Doc"; - -/** - * POST - * /channels/:channelId/docs - */ -export type RESTPostDocsResult = { - doc: DocPayload; -}; -export type RESTPostDocsBody = { - content: string; - title: string; -}; - -/** - * GET - * /channels/:channelId/docs - */ -export type RESTGetDocsResult = { - docs: DocPayload[]; -}; - -/** - * GET - * /channels/:channelId/docs/:docId - */ -export type RESTGetDocResult = { - doc: DocPayload; -}; - -/** - * PUT - * /channels/:channelId/docs/:docId - */ -export type RESTPutDocResult = { - doc: DocPayload; -}; -export type RESTPutDocBody = { - content: string; - title: string; -}; - -/** - * DELETE - * /channels/:channelId/docs/:docId - */ -export type RESTDeleteDocResult = never; diff --git a/packages/guilded-api-typings/lib/v1/rest/Forum.ts b/packages/guilded-api-typings/lib/v1/rest/Forum.ts deleted file mode 100644 index eabb9f8d..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Forum.ts +++ /dev/null @@ -1,87 +0,0 @@ -import type { ForumTopicPayload, ForumTopicSummaryPayload } from "../structs/Forum"; - -/** - * POST - * /channels/:channelId/topics - */ -export type RESTPostForumTopicResult = { - forumTopic: ForumTopicPayload; -}; -export type RESTPostForumTopicBody = { - content: string; - title: string; -}; - -/** - * PUT - * /channels/:channelId/topics/:forumTopicId/pin - */ -export type RESTPutForumTopicPinResult = never; - -/** - * DELETE - * /channels/:channelId/topics/:forumTopicId/pin - */ -export type RESTDeleteForumTopicPinResult = never; - -/** - * PUT - * /channels/:channelId/topics/:forumTopicId/lock - */ -export type RESTPutForumTopicLockResult = never; - -/** - * DELETE - * /channels/:channelId/topics/:forumTopicId/lock - */ -export type RESTDeleteForumTopicLockResult = never; - -/** - * POST - * /channels/:channelId/topics - */ -export type RESTPostForumTopicsBody = { - content: string; - title: string; -}; -export type RESTPostForumTopicsResult = { - forumTopic: ForumTopicPayload; -}; - -/** - * GET - * /channels/:channelId/topics - */ -export type RESTGetForumTopicsQuery = { - before?: string; - limit?: number; -}; -export type RESTGetForumTopicsResult = { - forumTopics: ForumTopicSummaryPayload[]; -}; - -/** - * GET - * /channels/:channelId/topics/:forumTopicId - */ -export type RESTGetForumTopicResult = { - forumTopic: ForumTopicPayload; -}; - -/** - * PATCH - * /channels/:channelId/topics/:forumTopicId - */ -export type RESTPatchForumTopicBody = { - content: string; - title: string; -}; -export type RESTPatchForumTopicResult = { - forumTopic: ForumTopicPayload; -}; - -/** - * DELETE - * /channels/:channelId/topics/:forumTopicId - */ -export type RESTDeleteForumTopicResult = never; diff --git a/packages/guilded-api-typings/lib/v1/rest/Group.ts b/packages/guilded-api-typings/lib/v1/rest/Group.ts deleted file mode 100644 index d1b744d0..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Group.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * PUT - * /groups/:groupId/members/:userId - */ -export type RESTPutGroupMemberResult = never; - -/** - * DELETE - * /groups/:groupId/members/:userId - */ -export type RESTDeleteGroupMemberResult = never; diff --git a/packages/guilded-api-typings/lib/v1/rest/List.ts b/packages/guilded-api-typings/lib/v1/rest/List.ts deleted file mode 100644 index e76e5823..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/List.ts +++ /dev/null @@ -1,59 +0,0 @@ -import type { ListItemPayload, ListItemSummaryPayload } from "../structs/List"; - -/** - * GET - * /channels/:channelId/items - */ -export type RESTGetListItemsResult = { - listItems: ListItemSummaryPayload[]; -}; - -/** - * GET - * /channels/:channelId/items/:listItemId - */ -export type RESTGetListItemResult = { - listItem: ListItemPayload; -}; - -/** - * PUT - * /channels/:channelId/items/:listItemId - */ -export type RESTPutListItemBody = { - message: string; - note?: string; -}; -export type RESTPutListItemResult = { - listItem: ListItemPayload; -}; - -/** - * DELETE - * /channels/:channelId/items/:listItemId - */ -export type RESTDeleteListItemResult = never; - -/** - * POST - * /channels/:channelId/items - */ -export type RESTPostListItemBody = { - message: string; - note?: string; -}; -export type RESTPostListItemResult = { - listItem: ListItemPayload; -}; - -/** - * POST - * /channels/:channelId/items/:listItemId/complete - */ -export type RESTPostListItemCompleteResult = never; - -/** - * DELETE - * /channels/:channelId/items/:listItemId/complete - */ -export type RESTDeleteListItemCompleteResult = never; diff --git a/packages/guilded-api-typings/lib/v1/rest/Member.ts b/packages/guilded-api-typings/lib/v1/rest/Member.ts deleted file mode 100644 index d4eec7a0..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Member.ts +++ /dev/null @@ -1,73 +0,0 @@ -import type { ServerMemberBanPayload, ServerMemberPayload, ServerMemberSummaryPayload } from "../structs"; - -/** - * PUT - * /servers/:serverId/members/:userId/nickname - */ -export type RESTPutMemberNicknameResult = { - nickname: string; -}; -export type RESTPutMemberNicknameBody = { - nickname: string; -}; - -/** - * DELETE - * /servers/:serverId/members/:userId/nickname - */ -export type RESTDeleteMemberNicknameResult = never; - -/** - * GET - * /servers/:serverId/members/:userId - */ -export type RESTGetMemberResult = { - member: ServerMemberPayload; -}; - -/** - * GET - * /servers/:serverId/members - */ -export type RESTGetMembersResult = { - members: ServerMemberSummaryPayload[]; -}; - -/** - * DELETE - * /servers/:serverId/members/:userId - */ -export type RESTDeleteMemberResult = never; - -/** - * GET - * /servers/:serverId/bans/:userId - */ -export type RESTGetMemberBanResult = { - serverMemberBan: ServerMemberBanPayload; -}; - -/** - * POST - * /servers/:serverId/bans/:userId - */ -export type RESTPostMemberBanBody = { - reason?: string; -}; -export type RESTPostMemberBanResult = { - serverMemberBan: ServerMemberBanPayload; -}; - -/** - * DELETE - * /servers/:serverId/bans/:userId - */ -export type RESTDeleteMemberBanResult = never; - -/** - * GET - * /servers/:serverId/bans - */ -export type RESTGetMemberBansResult = { - serverMemberBans: ServerMemberBanPayload[]; -}; diff --git a/packages/guilded-api-typings/lib/v1/rest/Message.ts b/packages/guilded-api-typings/lib/v1/rest/Message.ts deleted file mode 100644 index a93e9f42..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Message.ts +++ /dev/null @@ -1,52 +0,0 @@ -import type { ChatMessagePayload } from "../structs/Message"; - -/** - * POST - * /channels/:channelId/messages - */ -export type RESTPostChannelMessagesResult = { - message: ChatMessagePayload; -}; -export type RESTPostChannelMessagesBody = Pick & { - content?: string; -}; -/** - * GET - * /channels/:channelId/messages - */ -export type RESTGetChannelMessagesResult = { - messages: ChatMessagePayload[]; -}; -export type RESTGetChannelMessagesQuery = { - /** - * Uses ISO8601 timestamp - */ - after?: string; - /** - * Uses ISO8601 timestamp - */ - before?: string; - includePrivate?: boolean; - limit?: number; -}; - -/** - * GET - * /channels/:channelId/messages/:messageId - */ -export type RESTGetChannelMessageResult = { - message: ChatMessagePayload; -}; - -/** - * PUT - * /channels/:channelId/messages/:messageId - */ -export type RESTPutChannelMessageResult = RESTGetChannelMessageResult; -export type RESTPutChannelMessageBody = Pick & { content?: string }; - -/** - * DELETE - * /channels/:channelId/messages/:messageId - */ -export type RESTDeleteChannelMessageResult = never; diff --git a/packages/guilded-api-typings/lib/v1/rest/Reaction.ts b/packages/guilded-api-typings/lib/v1/rest/Reaction.ts deleted file mode 100644 index 974ea9eb..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Reaction.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * PUT - * /channels/:channelId/content/:contentId/emotes/:emoteId - */ -export type RESTPutReactionResult = never; - -/** - * DELETE - * /channels/:channelId/content/:contentId/emotes/:emoteId - */ -export type RESTDeleteReactionResult = never; diff --git a/packages/guilded-api-typings/lib/v1/rest/Role.ts b/packages/guilded-api-typings/lib/v1/rest/Role.ts deleted file mode 100644 index 509619b4..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Role.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * PUT - * /servers/:serverId/members/:userId/roles/:roleId - */ -export type RESTPutMemberRoleResult = never; - -/** - * DELETE - * /servers/:serverId/members/:userId/roles/:roleId - */ -export type RESTDeleteMemberRoleResult = never; - -/** - * GET - * /servers/:serverId/members/:userId/roles - */ -export type RESTGetMemberRolesResult = { - roleIds: number[]; -}; diff --git a/packages/guilded-api-typings/lib/v1/rest/Server.ts b/packages/guilded-api-typings/lib/v1/rest/Server.ts deleted file mode 100644 index 9fef45e1..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Server.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { ServerPayload } from "../structs/Server"; - -/** - * GET - * /servers/:serverId - */ -export type RESTGetServerResult = { - server: ServerPayload; -}; diff --git a/packages/guilded-api-typings/lib/v1/rest/SocialLink.ts b/packages/guilded-api-typings/lib/v1/rest/SocialLink.ts deleted file mode 100644 index 0c2dab59..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/SocialLink.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { SocialLink } from "../structs/SocialLink"; - -/** - * /servers/:serverId/members/:userId/social-links/:type - */ -export type RESTGetMemberSocialLinkResult = { - socialLink: SocialLink; -}; diff --git a/packages/guilded-api-typings/lib/v1/rest/User.ts b/packages/guilded-api-typings/lib/v1/rest/User.ts deleted file mode 100644 index 2ddc5928..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/User.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { UserPayload } from "../structs"; - -/** - * GET - * /users/:userId - */ -export type RESTGetUserResult = { - user: UserPayload; -}; diff --git a/packages/guilded-api-typings/lib/v1/rest/Webhook.ts b/packages/guilded-api-typings/lib/v1/rest/Webhook.ts deleted file mode 100644 index b0f87290..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/Webhook.ts +++ /dev/null @@ -1,65 +0,0 @@ -import type { APIEmbed } from "../structs/Embed"; -import type { WebhookContentPayload, WebhookPayload } from "../structs/Webhook"; - -/** - * POST - * /servers/:serverId/webhooks - */ -export type RESTPostServerWebhooksResult = { - webhook: WebhookPayload; -}; -export type RESTPostServerWebhooksBody = { - channelId: string; - name: string; -}; - -/** - * GET - * /servers/:serverId/webhooks - */ -export type RESTGetServerWebhooksResult = { - webhooks: WebhookPayload[]; -}; -export type RESTGetServerWebhooksQuery = { - channelId: string; -}; - -/** - * GET - * /servers/:serverId/webhooks/:webhookId - */ -export type RESTGetServerWebhookResult = { - webhook: WebhookPayload; -}; - -/** - * PUT - * /servers/:serverId/webhooks/:webhookId - */ -export type RESTPutServerWebhookResult = { - webhook: WebhookPayload; -}; -export type RESTPutServerWebhookBody = { - channelId?: string; - name: string; -}; - -/** - * DELETE - * /servers/:serverId/webhooks/:webhookId - */ -export type RESTDeleteServerWebhookResult = never; - -/** - * POST - * /webhooks/:webhookId/:webhookToken - */ -export type RESTPostWebhookBody = { - avatar_url?: string; - content?: string; - embeds?: APIEmbed[]; - payload_json?: Pick; - username?: string; -}; - -export type RESTPostWebhookResult = WebhookContentPayload; diff --git a/packages/guilded-api-typings/lib/v1/rest/XP.ts b/packages/guilded-api-typings/lib/v1/rest/XP.ts deleted file mode 100644 index 9631b1a8..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/XP.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * POST - * /servers/:serverId/members/:userId/xp - */ -export type RESTPostUserXpResult = { - total: number; -}; -export type RESTPostUserXPBody = { - amount: number; -}; - -/** - * POST - * /servers/:serverId/roles/:roleId/xp - */ -export type RESTPostRoleXpResult = { - total: number; -}; -export type RESTPostRoleXPBody = { - amount: number; -}; diff --git a/packages/guilded-api-typings/lib/v1/rest/index.ts b/packages/guilded-api-typings/lib/v1/rest/index.ts deleted file mode 100644 index e0524354..00000000 --- a/packages/guilded-api-typings/lib/v1/rest/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -export * from "./CalendarEvent"; -export * from "./Channel"; -export * from "./Doc"; -export * from "./Forum"; -export * from "./Group"; -export * from "./List"; -export * from "./Member"; -export * from "./Message"; -export * from "./Reaction"; -export * from "./Role"; -export * from "./Server"; -export * from "./SocialLink"; -export * from "./Webhook"; -export * from "./XP"; -export * from "./User"; diff --git a/packages/guilded-api-typings/lib/v1/structs/CalendarEvent.ts b/packages/guilded-api-typings/lib/v1/structs/CalendarEvent.ts deleted file mode 100644 index 8fb85d6a..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/CalendarEvent.ts +++ /dev/null @@ -1,137 +0,0 @@ -import type { MentionsPayload } from "./Message"; - -export type CalendarEventCancellationPayload = { - /** - * The ID of the user who created this event cancellation - */ - createdBy?: string; - /** - * The description of event cancellation (min 1; max 140) - */ - description?: string; -}; - -export type CalendarEventPayload = { - /** - * When rsvpLimit is set, users from the waitlist will be added as space becomes available in the event - */ - autofillWaitlist?: boolean; - cancellation?: CalendarEventCancellationPayload; - /** - * The ID of the channel - */ - channelId: string; - /** - * The color of the event when viewed in the calendar (min 0; max 16777215) - */ - color?: number; - /** - * The ISO 8601 timestamp that the event was created at - */ - createdAt: string; - /** - * The ID of the user who created this event - */ - createdBy: string; - /** - * The description of the event length: (min 1; max 8000) - */ - description?: string; - /** - * The duration of the event IN MINUTES (min 1) - */ - duration?: number; - /** - * The ID of the calendar event - */ - id: number; - /** - * Whether this event lasts all day - */ - isAllDay?: boolean; - /** - * If the event has a limited view - */ - isPrivate?: boolean; - /** - * The location of the event - */ - location?: string; - mentions?: MentionsPayload; - /** - * The name of the event length: (min 1; max 60) - */ - name: string; - /** - * Whether this is a repeating event - */ - repeats?: boolean; - /** - * The role IDs to restrict the event to (min items 1; must have unique items true) - */ - roleIds?: number[]; - /** - * The number of rsvps to allow before waitlisting rsvps (min 1) - */ - rsvpLimit?: number; - /** - * Collection of fetched rsvps if cached - */ - rsvps?: CalendarEventRsvpPayload[]; - /** - * The ID of the calendar event series. Only shows if the event is repeating - */ - seriesId?: string; - /** - * The ID of the server - */ - serverId: string; - /** - * The ISO 8601 timestamp that the event starts at - */ - startsAt: string; - /** - * A URL to associate with the event - */ - url?: string; -}; - -export type CalendarEventRsvpPayload = { - /** - * The ID of the calendar event - */ - calendarEventId: number; - /** - * The ID of the channel - */ - channelId: string; - /** - * The ISO 8601 timestamp that the rsvp was created at - */ - createdAt: string; - /** - * The ID of the user who created this rsvp - */ - createdBy: string; - id: string; - /** - * The ID of the server - */ - serverId: string; - /** - * The status of the rsvp ("going", "maybe", "declined", "invited", "waitlisted", or "not responded") - */ - status: string; - /** - * The ISO 8601 timestamp that the rsvp was updated at, if relevant - */ - updatedAt?: string; - /** - * The ID of the user who updated this rsvp - */ - updatedBy?: string; - /** - * The ID of the user - */ - userId: string; -}; diff --git a/packages/guilded-api-typings/lib/v1/structs/Channel.ts b/packages/guilded-api-typings/lib/v1/structs/Channel.ts index b116e1df..437990f1 100644 --- a/packages/guilded-api-typings/lib/v1/structs/Channel.ts +++ b/packages/guilded-api-typings/lib/v1/structs/Channel.ts @@ -1,18 +1 @@ -export type ServerChannelPayload = { - archivedAt?: string; - archivedBy?: string; - categoryId?: string; - createdAt: string; - createdBy: string; - groupId: string; - id: string; - isPublic?: boolean; - name: string; - parentId?: string; - serverId: string; - topic?: string; - type: ChannelType; - updatedAt?: string; -}; - export type ChannelType = "announcements" | "calendar" | "chat" | "docs" | "forums" | "list" | "media" | "scheduling" | "stream" | "voice"; diff --git a/packages/guilded-api-typings/lib/v1/structs/Client.ts b/packages/guilded-api-typings/lib/v1/structs/Client.ts new file mode 100644 index 00000000..5aaeffe0 --- /dev/null +++ b/packages/guilded-api-typings/lib/v1/structs/Client.ts @@ -0,0 +1,6 @@ +import type { WSPayload } from "../.."; + +export type ClientUserData = WSPayload<"_WelcomeMessage">["user"] & { + createdBy: string; + botId: string; +}; diff --git a/packages/guilded-api-typings/lib/v1/structs/Doc.ts b/packages/guilded-api-typings/lib/v1/structs/Doc.ts deleted file mode 100644 index d55df586..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/Doc.ts +++ /dev/null @@ -1,38 +0,0 @@ -export type DocPayload = { - /** - * The ID of the channel this doc belongs to - */ - channelId: string; - /** - * The content of the doc - */ - content: string; - /** - * The ISO 8601 timestamp that the doc was was created at - */ - createdAt: string; - /** - * The ID of the user who created this doc - */ - createdBy: string; - /** - * The id of the doc - */ - id: number; - /** - * The ID of the server this doc belongs to - */ - serverId: string; - /** - * The title of the doc - */ - title: string; - /** - * The ISO 8601 timestamp that the doc was updated at, if relevant - */ - updatedAt?: string; - /** - * The ID of the user who updated this doc - */ - updatedBy?: string; -}; diff --git a/packages/guilded-api-typings/lib/v1/structs/Embed.ts b/packages/guilded-api-typings/lib/v1/structs/Embed.ts index 6c194b41..fa41b9b7 100644 --- a/packages/guilded-api-typings/lib/v1/structs/Embed.ts +++ b/packages/guilded-api-typings/lib/v1/structs/Embed.ts @@ -1,38 +1,70 @@ -import type { EmbedPayload } from "./Message"; +export type EmbedPayload = { + author?: EmbedAuthor; + color?: number; + description?: string; + fields?: EmbedField[]; + footer?: EmbedFooter; + image?: EmbedImage; + thumbnail?: EmbedImage; + timestamp?: string; + title?: string; + url?: string; +}; + +export type EmbedFooter = { + icon_url?: string; + text: string; +}; + +export type EmbedImage = { + url: string; +}; + +export type EmbedAuthor = { + icon_url?: string; + name: string; + url?: string; +}; + +export type EmbedField = { + inline?: boolean; + name: string; + value: string; +}; // embed struct for the client API, webhooks mainly export type APIEmbed = EmbedPayload & { - author?: APIEmbedAuthor; - footer?: APIEmbedFooter; - image?: APIEmbedImage; - provider?: APIEmbedProvider; - thumbnail?: APIEmbedThumbnail; - video?: APIEmbedVideo; + author?: APIEmbedAuthor; + footer?: APIEmbedFooter; + image?: APIEmbedImage; + provider?: APIEmbedProvider; + thumbnail?: APIEmbedThumbnail; + video?: APIEmbedVideo; }; export type APIEmbedFooter = { - icon_url?: string; - proxy_icon_url?: string; - text: string; + icon_url?: string; + proxy_icon_url?: string; + text: string; }; export type APIEmbedImage = { - height?: string; - proxy_url?: string; - url: string; - width?: string; + height?: string; + proxy_url?: string; + url: string; + width?: string; }; export type APIEmbedThumbnail = APIEmbedImage; export type APIEmbedVideo = APIEmbedImage; export type APIEmbedProvider = { - name?: string; - url?: string; + name?: string; + url?: string; }; export type APIEmbedAuthor = { - icon_url?: string; - name: string; - proxy_icon_url?: string; - url?: string; + icon_url?: string; + name: string; + proxy_icon_url?: string; + url?: string; }; diff --git a/packages/guilded-api-typings/lib/v1/structs/Emote.ts b/packages/guilded-api-typings/lib/v1/structs/Emote.ts deleted file mode 100644 index 9231f72e..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/Emote.ts +++ /dev/null @@ -1,14 +0,0 @@ -export type EmotePayload = { - /** - * The id of the emote - */ - id: number; - /** - * The name of the emote - */ - name: string; - /** - * The url of the emote image - */ - url: string; -}; diff --git a/packages/guilded-api-typings/lib/v1/structs/Forum.ts b/packages/guilded-api-typings/lib/v1/structs/Forum.ts deleted file mode 100644 index 8d96e888..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/Forum.ts +++ /dev/null @@ -1,61 +0,0 @@ -import type { MentionsPayload } from "./Message"; - -export type ForumTopicPayload = { - /** - * When, if at all, this forum topic was bumped - */ - bumpedAt?: string; - /** - * The ID of the channel this forum topic belongs to - */ - channelId: string; - /** - * The content of the forum topic - */ - content: string; - /** - * The ISO 8601 timestamp that the forum topic was created at - */ - createdAt: string; - /** - * The ID of the user who created this forum topic (Note: If this event has createdByWebhookId present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) - */ - createdBy: string; - /** - * The ID of the webhook who created this forum topic, if it was created by a webhook - */ - createdByWebhookId?: string; - /** - * The ID of the forum topic - */ - id: number; - /** - * Whether this forum topic is locked - */ - isLocked?: boolean; - /** - * Whether this forum topic is pinned - */ - isPinned?: boolean; - /** - * The mentions within this forum topic - */ - mentions?: MentionsPayload; - /** - * The ID of the server this forum topic belongs to - */ - serverId: string; - /** - * The title of the forum topic - */ - title: string; - /** - * When, if at all, this forum topic was updated - */ - updatedAt?: string; -}; - -export type ForumTopicSummaryPayload = Pick< - ForumTopicPayload, - "bumpedAt" | "channelId" | "createdAt" | "createdBy" | "createdByWebhookId" | "id" | "isPinned" | "serverId" | "title" | "updatedAt" ->; diff --git a/packages/guilded-api-typings/lib/v1/structs/List.ts b/packages/guilded-api-typings/lib/v1/structs/List.ts deleted file mode 100644 index 87b0ce70..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/List.ts +++ /dev/null @@ -1,67 +0,0 @@ -import type { MentionsPayload } from "./Message"; - -export type ListItemPayload = { - /** - * The ID of the channel this list item belongs to - */ - channelId: string; - /** - * The timestmap of when this list item was completed at - */ - completedAt?: string; - /** - * The ISO 8601 timestamp that the list item was created at - */ - createdAt: string; - /** - * The ID of the user who created this list item (Note: If this event has createdByWebhookId present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) - */ - createdBy: string; - /** - * The ID of the webhook who created this list item, if it was created by a webhook - */ - createdByWebhookId?: string; - /** - * The ID of the list item. - */ - id: string; - /** - * The mentions within the list item. - */ - mentions?: MentionsPayload; - /** - * The message of the list item. - */ - message: string; - /** - * The note of the list item. - */ - note?: ListNoteContent; - /** - * The ID of the parent list this item belongs to if nested - */ - parentListItemId?: string; - /** - * The ID of the server this list item belongs to - */ - serverId: string; - /** - * The timestamp of when this list item was updated at - */ - updatedAt?: string; - /** - * The ID of the user who updated this listt item - */ - updatedBy?: string; -}; - -export type ListItemSummaryPayload = Omit & { note?: Omit }; - -export type ListNoteContent = { - content: string; - createdAt: string; - createdBy: string; - mentions?: MentionsPayload; - updatedAt?: string; - updatedBy?: string; -}; diff --git a/packages/guilded-api-typings/lib/v1/structs/Member.ts b/packages/guilded-api-typings/lib/v1/structs/Member.ts deleted file mode 100644 index 60a4fed5..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/Member.ts +++ /dev/null @@ -1,26 +0,0 @@ -import type { UserPayload, UserSummaryPayload } from "./User"; - -export type ServerMemberPayload = { - isOwner?: boolean; - joinedAt: string; - nickname?: string; - roleIds: number[]; - user: UserPayload; -}; - -export type ServerMemberSummaryPayload = { - roleIds: number[]; - user: UserSummaryPayload; -}; - -export type ServerMemberBanPayload = { - createdAt: string; - createdBy: string; - reason?: string; - user: UserSummaryPayload; -}; - -export type ServerMemberRoleIdsPayload = { - roleIds: number[]; - userId: string; -}; diff --git a/packages/guilded-api-typings/lib/v1/structs/Message.ts b/packages/guilded-api-typings/lib/v1/structs/Message.ts deleted file mode 100644 index a6e6df52..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/Message.ts +++ /dev/null @@ -1,101 +0,0 @@ -export type ChatMessagePayload = { - /** - * The ID of the channel - */ - channelId: string; - /** - * The content of the message - */ - content: string; - /** - * The ISO 8601 timestamp that the message was created at. - */ - createdAt: string; - /** - * The ID of the user who created this message (Note: If this event has createdByBotId or createdByWebhookId present, this field will still be populated, but can be ignored. In these cases, the value of this field will always be Ann6LewA) - */ - createdBy: string; - /** - * The ID of the bot who created this message, if it was created by a bot - */ - createdByBotId?: string; - /** - * The ID of the webhook who created this message, if it was created by a webhook - */ - createdByWebhookId?: string; - /** - * The embeds within this message - */ - embeds?: EmbedPayload[]; - /** - * The id of the message - */ - id: string; - /** - * If set, this message will only be seen by those mentioned or replied to. - */ - isPrivate?: boolean; - /** - * If set, this message did not notify, mention or reply recipients. - */ - isSilent?: boolean; - /** - * The mentions within this message - */ - mentions?: MentionsPayload; - /** - * The ID of the messages that this is replying to. - */ - replyMessageIds?: string[]; - /** - * The id of the server this message belongs to - */ - serverId?: string; - /** - * The type of chat message. "system" messages are generated by Guilded, while "default" messages are user or bot-generated. - */ - type: "default" | "system"; - /** - * The ISO 8601 timestamp that the message was updated at, if relevant - */ - updatedAt?: string; -}; - -export type EmbedPayload = { - author?: EmbedAuthor; - color?: number; - description?: string; - fields?: EmbedField[]; - footer?: EmbedFooter; - image?: EmbedImage; - thumbnail?: EmbedImage; - timestamp?: string; - title?: string; - url?: string; -}; - -export type EmbedFooter = { - icon_url?: string; - text: string; -}; -export type EmbedImage = { - url: string; -}; -export type EmbedAuthor = { - icon_url?: string; - name: string; - url?: string; -}; -export type EmbedField = { - inline?: boolean; - name: string; - value: string; -}; - -export type MentionsPayload = { - channels?: { id: string }[]; - everyone?: boolean; - here?: boolean; - roles?: { id: number }[]; - users?: { id: string }[]; -}; diff --git a/packages/guilded-api-typings/lib/v1/structs/Reaction.ts b/packages/guilded-api-typings/lib/v1/structs/Reaction.ts deleted file mode 100644 index bcc37eff..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/Reaction.ts +++ /dev/null @@ -1,22 +0,0 @@ -export type ContentReactionPayload = { - /** - * The ISO 8601 timestamp that the emote was created at - */ - createdAt: string; - /** - * The ID of the user who created this list item (Note: If this event has createdByWebhookId present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) - */ - createdBy: string; - /** - * The ID of the webhook who created this list item, if it was created by a webhook - */ - createdByWebhookId?: string; - /** - * The ID of the content reaction - */ - id: number; - /** - * The ID of the server this reaction belongs to - */ - serverId: string; -}; diff --git a/packages/guilded-api-typings/lib/v1/structs/Server.ts b/packages/guilded-api-typings/lib/v1/structs/Server.ts index 7f593010..004a02a3 100644 --- a/packages/guilded-api-typings/lib/v1/structs/Server.ts +++ b/packages/guilded-api-typings/lib/v1/structs/Server.ts @@ -1,16 +1,9 @@ -export type ServerPayload = { - about?: string; - avatar?: string; - banner?: string; - createdAt: string; - defaultChannelId?: string; - id: string; - isVerified?: boolean; - name: string; - ownerId: string; - timezone?: string; - type?: ServerType; - url?: string; -}; - -export type ServerType = "clan" | "community" | "friends" | "guild" | "organization" | "other" | "streaming" | "team"; +export type ServerType = + | "clan" + | "community" + | "friends" + | "guild" + | "organization" + | "other" + | "streaming" + | "team"; diff --git a/packages/guilded-api-typings/lib/v1/structs/SocialLink.ts b/packages/guilded-api-typings/lib/v1/structs/SocialLink.ts deleted file mode 100644 index 4626937d..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/SocialLink.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * The type of social link to retrieve - */ -export type UserSocialLink = - | "bnet" - | "epic" - | "facebook" - | "origin" - | "patreon" - | "psn" - | "roblox" - | "steam" - | "switch" - | "twitch" - | "twitter" - | "xbox" - | "youtube"; - -export type SocialLink = { - createdAt: string; - handle?: string; - serviceId?: string; - type: UserSocialLink; - userId: string; -}; diff --git a/packages/guilded-api-typings/lib/v1/structs/User.ts b/packages/guilded-api-typings/lib/v1/structs/User.ts deleted file mode 100644 index ab39bf24..00000000 --- a/packages/guilded-api-typings/lib/v1/structs/User.ts +++ /dev/null @@ -1,15 +0,0 @@ -export type UserPayload = { - avatar?: string; - banner?: string; - createdAt: string; - id: string; - name: string; - type?: "bot" | "user"; -}; - -export type UserSummaryPayload = { - avatar?: string; - id: string; - name: string; - type?: string; -}; diff --git a/packages/guilded-api-typings/lib/v1/structs/index.ts b/packages/guilded-api-typings/lib/v1/structs/index.ts index 18eb6688..7619a4ee 100644 --- a/packages/guilded-api-typings/lib/v1/structs/index.ts +++ b/packages/guilded-api-typings/lib/v1/structs/index.ts @@ -1,14 +1,5 @@ -export * from "./CalendarEvent"; -export * from "./Channel"; -export * from "./Doc"; export * from "./Embed"; -export * from "./Emote"; -export * from "./Forum"; -export * from "./List"; -export * from "./Member"; -export * from "./Message"; -export * from "./Reaction"; -export * from "./Server"; -export * from "./SocialLink"; -export * from "./User"; export * from "./Webhook"; +export * from "./Channel"; +export * from "./Server"; +export * from "./Client"; diff --git a/packages/guilded-api-typings/lib/v1/webhook.ts b/packages/guilded-api-typings/lib/v1/webhook.ts new file mode 100644 index 00000000..be702665 --- /dev/null +++ b/packages/guilded-api-typings/lib/v1/webhook.ts @@ -0,0 +1,16 @@ +import type { APIEmbed } from "./structs/Embed"; +import type { WebhookContentPayload } from "./structs/Webhook"; + +/** + * POST + * /webhooks/:webhookId/:webhookToken + */ +export type RESTPostWebhookBody = { + avatar_url?: string; + content?: string; + embeds?: APIEmbed[]; + payload_json?: Pick; + username?: string; +}; + +export type RESTPostWebhookResult = WebhookContentPayload; diff --git a/packages/guilded-api-typings/lib/v1/ws.ts b/packages/guilded-api-typings/lib/v1/ws.ts new file mode 100644 index 00000000..948351a2 --- /dev/null +++ b/packages/guilded-api-typings/lib/v1/ws.ts @@ -0,0 +1,3007 @@ +/** + * This file was auto-generated by openapi-typescript. + * Do not make direct changes to the file. + */ + + +export type paths = Record; + +export type webhooks = Record; + +export interface components { + schemas: { + _SocketEventEnvelope: { + /** + * Opcode + * @description An operation code corresponding to the nature of the sent message (for example, success, failure, etc.) + * @enum {integer} + */ + op: 0 | 1 | 2 | 8 | 9; + /** + * Data + * @description Data of any form depending on the underlying event + */ + d?: Record; + /** + * Message ID + * @description Message ID used for replaying events after a disconnect + */ + s?: string; + /** + * Event name + * @description Event name for the given message + */ + t?: string; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "type": "default", + * "serverId": "wlVr3Ggl", + * "groupId": "ZVzBo83p", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "content": "Hello **world**!", + * "embeds": [ + * { + * "title": "embed title", + * "description": "embeds support a **different** __subset__ *of* markdown than other markdown fields. <@Ann6LewA>\n\n [links](https://www.guilded.gg) ```\ncheck this code out```\n\n:pizza: time!! ttyl", + * "url": "https://www.guilded.gg", + * "color": 6118369, + * "timestamp": "2022-04-12T22:14:36.737Z", + * "footer": { + * "icon_url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png", + * "text": "footer text" + * }, + * "thumbnail": { + * "url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png" + * }, + * "image": { + * "url": "https://www.guilded.gg/asset/Logos/logomark_wordmark/Color/Guilded_Logomark_Wordmark_Color.png" + * }, + * "author": { + * "name": "Gil", + * "url": "https://www.guilded.gg", + * "icon_url": "https://www.guilded.gg/asset/Default/Gil-md.png" + * }, + * "fields": [ + * { + * "name": "hello", + * "value": "these are fields" + * }, + * { + * "name": "~~help i have been crossed out~~", + * "value": "~~oh noes~~", + * "inline": true + * }, + * { + * "name": "another inline", + * "value": "field", + * "inline": true + * } + * ] + * } + * ], + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + ChatMessage: { + /** + * Message ID + * Format: uuid + * @description The ID of the message + */ + id: string; + /** + * Type + * @description The type of chat message. "system" messages are generated by Guilded, while "default" messages are user or bot-generated. + * @enum {string} + */ + type: "default" | "system"; + /** + * Server ID + * @description The ID of the server + */ + serverId?: string; + /** + * Group ID + * @description The ID of the group + */ + groupId?: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Content + * Format: markdown + * @description The content of the message + */ + content?: string; + embeds?: (components["schemas"]["ChatEmbed"])[]; + /** @description Message IDs that were replied to */ + replyMessageIds?: (string)[]; + /** + * Is private + * @description If set, this message will only be seen by those mentioned or replied to + */ + isPrivate?: boolean; + /** + * Is silent + * @description If set, this message did not notify mention or reply recipients + * @default false + */ + isSilent?: boolean; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the message was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this message (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Created by Webhook ID + * @description The ID of the webhook who created this message, if it was created by a webhook + */ + createdByWebhookId?: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the message was updated at, if relevant + */ + updatedAt?: string; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "messageId": "00000000-0000-0000-0000-000000000000" + * } + */ + ChatMessageReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Message ID + * Format: uuid + * @description The ID of the message + */ + messageId: string; + }; + /** + * @description Rich content sections optionally associated with chat messages. Properties with "webhook-markdown" support allow for the following: link, italic, bold, strikethrough, underline, inline code, block code, reaction, and mention. + * @example { + * "title": "embed title", + * "description": "embeds support a **different** __subset__ *of* markdown than other markdown fields. <@Ann6LewA>\n\n [links](https://www.guilded.gg) ```\ncheck this code out```\n\n:pizza: time!! ttyl", + * "url": "https://www.guilded.gg", + * "color": 6118369, + * "timestamp": "2022-04-12T22:14:36.737Z", + * "footer": { + * "icon_url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png", + * "text": "footer text" + * }, + * "thumbnail": { + * "url": "https://www.guilded.gg/asset/Logos/logomark/Color/Guilded_Logomark_Color.png" + * }, + * "image": { + * "url": "https://www.guilded.gg/asset/Logos/logomark_wordmark/Color/Guilded_Logomark_Wordmark_Color.png" + * }, + * "author": { + * "name": "Gil", + * "url": "https://www.guilded.gg", + * "icon_url": "https://www.guilded.gg/asset/Default/Gil-md.png" + * }, + * "fields": [ + * { + * "name": "hello", + * "value": "these are fields" + * }, + * { + * "name": "~~help i have been crossed out~~", + * "value": "~~oh noes~~", + * "inline": true + * }, + * { + * "name": "another inline", + * "value": "field", + * "inline": true + * } + * ] + * } + */ + ChatEmbed: { + /** + * Format: webhook-markdown + * @description Main header of the embed + */ + title?: string; + /** + * Format: webhook-markdown + * @description Subtext of the embed + */ + description?: string; + /** + * Format: uri + * @description URL to linkify the `title` field with + */ + url?: string; + /** @description Decimal value of the color that the left border should be */ + color?: number; + /** @description A small section at the bottom of the embed */ + footer?: { + /** + * Format: media-uri + * @description URL of a small image to put in the footer + */ + icon_url?: string; + /** @description Text of the footer */ + text: string; + }; + /** + * Format: date-time + * @description A timestamp to put in the footer + */ + timestamp?: string; + /** @description An image to the right of the embed's content */ + thumbnail?: { + /** + * Format: media-uri + * @description URL of the image + */ + url?: string; + }; + /** @description The main picture to associate with the embed */ + image?: { + /** + * Format: media-uri + * @description URL of the image + */ + url?: string; + }; + /** @description A small section above the title of the embed */ + author?: { + /** @description Name of the author */ + name?: string; + /** + * Format: uri + * @description URL to linkify the author's `name` field + */ + url?: string; + /** + * Format: media-uri + * @description URL of a small image to display to the left of the author's `name` + */ + icon_url?: string; + }; + /** @description Table-like cells to add to the embed */ + fields?: ({ + /** + * Format: webhook-markdown + * @description Header of the table-like cell + */ + name: string; + /** + * Format: webhook-markdown + * @description Subtext of the table-like cell + */ + value: string; + /** + * @description If the field should wrap or not + * @default false + */ + inline?: boolean; + })[]; + }; + /** + * @example { + * "type": "roblox", + * "userId": "Ann6LewA", + * "handle": "builderman", + * "serviceId": "156", + * "createdAt": "2006-03-08T20:15:00.706Z" + * } + */ + SocialLink: { + /** + * Social link type + * @description The type of social link that Guilded supports. Depending on this value, `handle` or `serviceId` may or may not be present + * @enum {string} + */ + type: "twitch" | "bnet" | "psn" | "xbox" | "steam" | "origin" | "youtube" | "twitter" | "facebook" | "switch" | "patreon" | "roblox" | "epic"; + /** + * User ID + * @description The ID of the user that the social link is associated with + */ + userId: string; + /** @description The handle of the user within the external service */ + handle?: string; + /** @description The unique ID that represents this member's social link within the external service */ + serviceId?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the social link was created at + */ + createdAt: string; + }; + /** + * @description Metadata of who or what is mentioned in content + * @example { + * "users": [ + * { + * "id": "Ann6LewA" + * } + * ], + * "channels": [ + * { + * "id": "00000000-0000-0000-0000-000000000000" + * } + * ], + * "roles": [ + * { + * "id": 591232 + * } + * ], + * "everyone": true, + * "here": true + * } + */ + Mentions: { + /** + * Users + * @description Info on mentioned users + */ + users?: ({ + /** + * User ID + * @description The ID of the user + */ + id: string; + })[]; + /** + * Channels + * @description Info on mentioned channels + */ + channels?: ({ + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + id: string; + })[]; + /** + * Roles + * @description Info on mentioned roles + */ + roles?: ({ + /** + * Role ID + * @description The ID of the role + */ + id: number; + })[]; + /** + * Everyone + * @description If @everyone was mentioned + */ + everyone?: boolean; + /** + * Here + * @description If @here was mentioned + */ + here?: boolean; + }; + /** + * @example { + * "id": 1234567890, + * "content": "Great idea!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "forumTopicId": 2036274747, + * "createdBy": "Ann6LewA" + * } + */ + ForumTopicComment: { + /** @description The ID of the forum topic comment */ + id: number; + /** + * Content + * Format: markdown + * @description The content of the forum topic comment + */ + content: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic comment was created at + */ + createdAt: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic comment was updated at, if relevant + */ + updatedAt?: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** @description The ID of the forum topic */ + forumTopicId: number; + /** + * Created by + * @description The ID of the user who created this forum topic comment (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "forumTopicId": 123456 + * } + */ + ForumTopicReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** @description The ID of the forum topic */ + forumTopicId: number; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "forumTopicId": 123456, + * "forumTopicCommentId": 1234567890 + * } + */ + ForumTopicCommentReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** @description The ID of the forum topic */ + forumTopicId: number; + /** @description The ID of the forum topic comment */ + forumTopicCommentId: number; + }; + /** + * @example { + * "id": 123456, + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "title": "Welcome new members!!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "content": "Please introduce yourself in this topic!!!" + * } + */ + ForumTopic: { + /** @description The ID of the forum topic */ + id: number; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Title + * @description The title of the forum topic + */ + title: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this forum topic (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was updated at, if relevant + */ + updatedAt?: string; + /** + * Bumped at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was bumped at. This timestamp is updated whenever there is any activity on the posts within the forum topic. + */ + bumpedAt?: string; + /** + * Is pinned + * @default false + */ + isPinned?: boolean; + /** + * Is locked + * @default false + */ + isLocked?: boolean; + /** + * Content + * Format: markdown + * @description The content of the forum topic + */ + content: string; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "id": 123456, + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "title": "Welcome new members!!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + ForumTopicSummary: { + /** @description The ID of the forum topic */ + id: number; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Title + * @description The title of the forum topic + */ + title: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this forum topic (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was updated at, if relevant + */ + updatedAt?: string; + /** + * Bumped at + * Format: date-time + * @description The ISO 8601 timestamp that the forum topic was bumped at. This timestamp is updated whenever there is any activity on the posts within the forum topic. + */ + bumpedAt?: string; + /** + * Is pinned + * @default false + */ + isPinned?: boolean; + /** + * Is locked + * @default false + */ + isLocked?: boolean; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "message": "Remember to say hello **world**!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "note": { + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "content": "Duly noted" + * } + * } + */ + ListItem: { + /** + * Format: uuid + * @description The ID of the list item + */ + id: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Message + * Format: markdown + * @description The message of the list item + */ + message: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this list item (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Created by Webhook ID + * @description The ID of the webhook who created this list item, if it was created by a webhook + */ + createdByWebhookId?: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this list item + */ + updatedBy?: string; + /** + * Format: uuid + * @description The ID of the parent list item if this list item is nested + */ + parentListItemId?: string; + /** + * Completed at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was completed at + */ + completedAt?: string; + /** + * Completed by + * @description The ID of the user who completed this list item + */ + completedBy?: string; + note?: { + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the note was created at. If this field is populated, then there's a note associated with the list item + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this note + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the note was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this note + */ + updatedBy?: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Note + * Format: markdown + * @description The note of the list item + */ + content: string; + }; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "message": "Remember to say hello **world**!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "note": { + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + * } + */ + ListItemSummary: { + /** + * Format: uuid + * @description The ID of the list item + */ + id: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Message + * Format: markdown + * @description The message of the list item + */ + message: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this list item (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Created by Webhook ID + * @description The ID of the webhook who created this list item, if it was created by a webhook + */ + createdByWebhookId?: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this list item + */ + updatedBy?: string; + /** + * Format: uuid + * @description The ID of the parent list item if this list item is nested + */ + parentListItemId?: string; + /** + * Completed at + * Format: date-time + * @description The ISO 8601 timestamp that the list item was completed at + */ + completedAt?: string; + /** + * Completed by + * @description The ID of the user who completed this list item + */ + completedBy?: string; + note?: { + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the note was created at. If this field is populated, then there's a note associated with the list item + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this note + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the note was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this note + */ + updatedBy?: string; + }; + }; + /** + * @example { + * "id": 0, + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "title": "HOW-TO: Smoke These Meats with Sweet Baby Ray's", + * "content": "Spicy jalapeno bacon ipsum dolor amet sirloin ground round short loin, meatball brisket capicola tri-tip ham pork belly biltong corned beef chuck. Chicken ham brisket shank rump buffalo t-bone. Short loin sausage buffalo porchetta pork belly rump tri-tip frankfurter tail pork chop cow sirloin. Pancetta porchetta tail ball tip chislic beef ribs. Buffalo andouille leberkas jerky. Fatback shankle andouille beef. Cow kielbasa buffalo pork loin chislic meatloaf short loin rump meatball prosciutto.", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "updatedAt": "2021-07-15T22:20:00.706Z", + * "updatedBy": "Ann6LewA" + * } + */ + Doc: { + /** + * Doc ID + * @description The ID of the doc + */ + id: number; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Title + * @description The title of the doc + */ + title: string; + /** + * Content + * Format: markdown + * @description The content of the doc + */ + content: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the doc was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this doc + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the doc was updated at, if relevant + */ + updatedAt?: string; + /** + * Updated by + * @description The ID of the user who updated this doc + */ + updatedBy?: string; + }; + /** + * @example { + * "id": 123456, + * "content": "Wow, cool document!!!", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "docId": 0, + * "createdBy": "Ann6LewA" + * } + */ + DocComment: { + /** + * Doc comment ID + * @description The ID of the doc comment + */ + id: number; + /** + * Content + * Format: markdown + * @description The content of the doc comment + */ + content: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the doc comment was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this doc comment (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the doc comment was updated at, if relevant + */ + updatedAt?: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Doc ID + * @description The ID of the doc + */ + docId: number; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "docId": 0 + * } + */ + DocReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Doc ID + * @description The ID of the doc + */ + docId: number; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "docId": 0, + * "docCommentId": 123456 + * } + */ + DocCommentReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Doc ID + * @description The ID of the doc + */ + docId: number; + /** + * Doc comment ID + * @description The ID of the doc comment + */ + docCommentId: number; + }; + /** + * @example { + * "user": { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch", + * "createdAt": "2021-06-15T20:15:00.706Z" + * }, + * "roleIds": [], + * "nickname": "Professor Chaos", + * "joinedAt": "2021-07-15T20:15:00.706Z" + * } + */ + ServerMember: { + user: components["schemas"]["User"]; + /** Role IDs */ + roleIds: (number)[]; + /** Nickname */ + nickname?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the member was created at + */ + joinedAt: string; + /** + * Is owner + * @default false + */ + isOwner?: boolean; + }; + /** + * @example { + * "user": { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch" + * }, + * "roleIds": [] + * } + */ + ServerMemberSummary: { + user: components["schemas"]["UserSummary"]; + /** Role IDs */ + roleIds: (number)[]; + }; + /** + * @example { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch", + * "createdAt": "2021-06-15T20:15:00.706Z" + * } + */ + User: { + /** + * User ID + * @description The ID of the user + */ + id: string; + /** + * User type + * @description The type of user. If this property is absent, it can assumed to be of type `user` + * @enum {string} + */ + type?: "bot" | "user"; + /** + * User name + * @description The user's name + */ + name: string; + /** + * Avatar + * Format: media-uri + * @description The avatar image associated with the user + */ + avatar?: string; + /** + * Banner + * Format: media-uri + * @description The banner image associated with the user + */ + banner?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the user was created at + */ + createdAt: string; + }; + /** + * @example { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch" + * } + */ + UserSummary: { + /** + * User ID + * @description The ID of the user + */ + id: string; + /** + * User type + * @description The type of user. If this property is absent, it can assumed to be of type `user` + * @enum {string} + */ + type?: "bot" | "user"; + /** + * User name + * @description The user's name + */ + name: string; + /** + * Avatar + * Format: media-uri + * @description The avatar image associated with the user + */ + avatar?: string; + }; + /** + * @example { + * "user": { + * "id": "Ann6LewA", + * "type": "user", + * "name": "Leopold Stotch" + * }, + * "reason": "More toxic than a poison Pokémon", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + ServerMemberBan: { + user: components["schemas"]["UserSummary"]; + /** + * Reason + * @description The reason for the ban as submitted by the banner + */ + reason?: string; + /** + * Created by + * @description The ID of the user who created this server member ban + */ + createdBy: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the server member ban was created at + */ + createdAt: string; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "type": "chat", + * "name": "The Dank Cellar", + * "topic": "Dank memes ONLY", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "serverId": "wlVr3Ggl", + * "groupId": "ZVzBo83p" + * } + */ + ServerChannel: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + id: string; + /** + * @description The type of channel. This will determine what routes to use for creating content in a channel. For example, if this "chat", then one must use the routes for creating channel messages + * @enum {string} + */ + type: "announcements" | "chat" | "calendar" | "forums" | "media" | "docs" | "voice" | "list" | "scheduling" | "stream"; + /** @description The name of the channel */ + name: string; + /** @description The topic of the channel */ + topic?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the channel was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this channel + */ + createdBy: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the channel was updated at, if relevant + */ + updatedAt?: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description ID of the parent channel or parent thread, if present. Only relevant for server channels + */ + parentId?: string; + /** @description Only relevant for server channels */ + categoryId?: number; + /** + * Group ID + * @description The ID of the group + */ + groupId: string; + /** + * Is public + * @description Whether the channel can be accessed from users who are not member of the server + * @default false + */ + isPublic?: boolean; + /** + * Archived by + * @description The ID of the user who archived this channel + */ + archivedBy?: string; + /** + * Archived at + * Format: date-time + * @description The ISO 8601 timestamp that the channel was archived at, if relevant + */ + archivedAt?: string; + }; + /** + * @example { + * "id": "wlVr3Ggl", + * "type": "community", + * "name": "Guilded", + * "url": "Guilded-Official", + * "about": "The Official Guilded Server! For devs, friends, and fans alike!", + * "ownerId": "Ann6LewA", + * "createdAt": "2018-10-05T20:15:00.706Z", + * "isVerified": true, + * "timezone": "America/Los Angeles (PST/PDT)" + * } + */ + Server: { + /** + * Server ID + * @description The ID of the server + */ + id: string; + /** + * Created by + * @description The ID of the user who created this server + */ + ownerId: string; + /** + * Server type + * @description The type of server designated from the server's settings page + * @enum {string} + */ + type?: "team" | "organization" | "community" | "clan" | "guild" | "friends" | "streaming" | "other"; + /** + * Server name + * @description The name given to the server + */ + name: string; + /** + * Server URL + * @description The URL that the server can be accessible from. For example, a value of "Guilded-Official" means the server can be accessible from https://www.guilded.gg/Guilded-Official + */ + url?: string; + /** + * Description + * @description The description associated with the server + */ + about?: string; + /** + * Avatar + * Format: media-uri + * @description The avatar image associated with the server + */ + avatar?: string; + /** + * Banner + * Format: media-uri + * @description The banner image associated with the server + */ + banner?: string; + /** + * Timezone + * @description The timezone associated with the server + */ + timezone?: string; + /** + * Is verified + * @description The verified status of the server + */ + isVerified?: boolean; + /** + * Channel ID + * Format: uuid + * @description The channel ID of the default channel of the server. This channel is defined as the first chat or voice channel in the left sidebar of a server in our UI. This channel is useful for sending welcome messages, though note that a bot may not have permissions to interact with this channel depending on how the server is configured. + */ + defaultChannelId?: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the server was created at + */ + createdAt: string; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "name": "E-102 Gamma", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + Webhook: { + /** + * Webhook ID + * Format: uuid + * @description The ID of the webhook + */ + id: string; + /** + * Name + * @description The name of the webhook + */ + name: string; + /** + * Avatar + * Format: media-uri + * @description The avatar image associated with the webhook + */ + avatar?: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the webhook was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this webhook + */ + createdBy: string; + /** + * Deleted at + * Format: date-time + * @description The ISO 8601 timestamp that the webhook was deleted at + */ + deletedAt?: string; + /** + * Token + * @description The token of the webhook + */ + token?: string; + }; + /** + * @example { + * "id": 1, + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "name": "Surprise LAN party for my wife 🤫", + * "description": "**Don't say anything to her!** She's gonna love playing Call of Duty all night", + * "location": "My house!", + * "url": "https://www.surprisepartygame.com/", + * "duration": 60, + * "color": 16106496, + * "startsAt": "2022-06-16T00:00:00.000Z", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + CalendarEvent: { + /** + * Calendar event ID + * @description The ID of the calendar event + */ + id: number; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Name + * @description The name of the event + */ + name: string; + /** + * Description + * Format: markdown + * @description The description of the event + */ + description?: string; + /** + * Location + * @description The location of the event + */ + location?: string; + /** + * Format: uri + * @description A URL to associate with the event + */ + url?: string; + /** @description The color of the event when viewing in the calendar */ + color?: number; + /** @description Is this event a repeating event */ + repeats?: boolean; + /** + * Calendar event series ID + * Format: uuid + * @description The ID of the calendar event series. Only shows if the event is repeating + */ + seriesId?: string; + /** + * Role IDs + * @description The role IDs to restrict the event to + */ + roleIds?: (number)[]; + /** + * RSVP disabled + * @description When disabled, users will not be able to RSVP to the event + */ + rsvpDisabled?: boolean; + /** + * Is all day + * @description Does the event last all day + */ + isAllDay?: boolean; + /** @description The number of RSVPs to allow before waitlisting RSVPs */ + rsvpLimit?: number; + /** @description When `rsvpLimit` is set, users from the waitlist will be added as space becomes available in the event */ + autofillWaitlist?: boolean; + /** + * Starts at + * Format: date-time + * @description The ISO 8601 timestamp that the event starts at + */ + startsAt: string; + /** + * Duration + * @description The duration of the event _**in minutes**_ + */ + duration?: number; + /** Is private */ + isPrivate?: boolean; + mentions?: components["schemas"]["Mentions"]; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the event was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this event + */ + createdBy: string; + cancellation?: { + /** + * Description + * Format: markdown + * @description The description of event cancellation + */ + description?: string; + /** + * Created by + * @description The ID of the user who created this event cancellation + */ + createdBy: string; + }; + }; + /** + * @example { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * } + */ + Emote: { + /** + * Emote ID + * @description The ID of the emote + */ + id: number; + /** + * Name + * @description The name of the emote + */ + name: string; + /** + * Emote URL + * Format: media-uri + * @description The URL of the emote image + */ + url: string; + /** + * Server ID + * @description The ID of the server the emote was created on + */ + serverId?: string; + }; + /** + * @example { + * "calendarEventId": 1, + * "channelId": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "userId": "Ann6LewA", + * "status": "going", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA" + * } + */ + CalendarEventRsvp: { + /** + * Calendar event ID + * @description The ID of the calendar event + */ + calendarEventId: number; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * User ID + * @description The ID of the user + */ + userId: string; + /** + * Status + * @description The status of the RSVP + * @enum {string} + */ + status: "going" | "maybe" | "declined" | "invited" | "waitlisted" | "not responded"; + /** + * Created by + * @description The ID of the user who created this RSVP + */ + createdBy: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the RSVP was created at + */ + createdAt: string; + /** + * Updated by + * @description The ID of the user who updated this RSVP + */ + updatedBy?: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the RSVP was updated at, if relevant + */ + updatedAt?: string; + }; + /** + * @example { + * "id": 1234567890, + * "content": "I will be there!!", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdAt": "2022-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "calendarEventId": 987654321 + * } + */ + CalendarEventComment: { + /** + * Calendar event comment ID + * @description The ID of the calendar event comment + */ + id: number; + /** + * Content + * Format: markdown + * @description The content of the calendar event comment + */ + content: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the calendar event comment was created at + */ + createdAt: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the calendar event comment was updated at, if relevant + */ + updatedAt?: string; + /** + * Calendar event ID + * @description The ID of the calendar event + */ + calendarEventId: number; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Created by + * @description The ID of the user who created this calendar event comment (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "calendarEventId": 1 + * } + */ + CalendarEventReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Calendar event ID + * @description The ID of the calendar event + */ + calendarEventId: number; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "calendarEventId": 1, + * "calendarEventCommentId": 1234567890 + * } + */ + CalendarEventCommentReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Calendar event ID + * @description The ID of the calendar event + */ + calendarEventId: number; + /** + * Calendar event comment ID + * @description The ID of the calendar event comment + */ + calendarEventCommentId: number; + }; + /** + * @example { + * "id": "00000000-0000-0000-0000-000000000000", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000" + * } + */ + CalendarEventSeries: { + /** + * Calendar event series ID + * Format: uuid + * @description The ID of the calendar event series + */ + id: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + }; + /** + * @example { + * "id": "9RVMoDZy", + * "serverId": "wlVr3Ggl", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdAt": "2021-06-15T20:15:00.706Z", + * "createdBy": "Ann6LewA", + * "title": "Pizza Party, don't be tardy!", + * "content": "Grab a slice, don't be slow, At our pizza party, it's the way to go! Toppings galore, cheesy delight, Come join us, it'll be out of sight!" + * } + */ + Announcement: { + /** + * Announcement ID + * @description The ID of the announcement + */ + id: string; + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the announcement was created at + */ + createdAt: string; + /** + * Created by + * @description The ID of the user who created this announcement + */ + createdBy: string; + /** + * Content + * Format: markdown + * @description The content of the announcement + */ + content: string; + mentions?: components["schemas"]["Mentions"]; + /** + * Title + * @description The title of the announcement + */ + title: string; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "announcementId": "9RVMoDZy" + * } + */ + AnnouncementReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Announcement ID + * @description The ID of the announcement + */ + announcementId: string; + }; + /** + * @example { + * "id": 123456, + * "content": "Now THAT is one awesome announcement!!!", + * "createdAt": "2023-04-07T16:19:00.000Z", + * "channelId": "00000000-0000-0000-0000-000000000000", + * "announcementId": "9RVMoDZy", + * "createdBy": "Ann6LewA" + * } + */ + AnnouncementComment: { + /** + * Announcement comment ID + * @description The ID of the announcement comment + */ + id: number; + /** + * Content + * Format: markdown + * @description The content of the announcement comment + */ + content: string; + /** + * Created at + * Format: date-time + * @description The ISO 8601 timestamp that the announcement comment was created at + */ + createdAt: string; + /** + * Updated at + * Format: date-time + * @description The ISO 8601 timestamp that the announcement comment was updated at, if relevant + */ + updatedAt?: string; + /** + * Created by + * @description The ID of the user who created this announcement comment (Note: If this event has `createdByWebhookId` present, this field will still be populated, but can be ignored. In this case, the value of this field will always be Ann6LewA) + */ + createdBy: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Announcement ID + * @description The ID of the announcement + */ + announcementId: string; + mentions?: components["schemas"]["Mentions"]; + }; + /** + * @example { + * "channelId": "00000000-0000-0000-0000-000000000000", + * "createdBy": "Ann6LewA", + * "emote": { + * "id": 90000000, + * "name": "grinning", + * "url": "https://img.guildedcdn.com/asset/Emojis/grinning.webp" + * }, + * "announcementId": "9RVMoDZy", + * "announcementCommentId": 123456 + * } + */ + AnnouncementCommentReaction: { + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * User ID + * @description The ID of the user who added the reaction + */ + createdBy: string; + emote: components["schemas"]["Emote"]; + /** + * Announcement ID + * @description The ID of the announcement + */ + announcementId: string; + /** + * Announcement comment ID + * @description The ID of the announcement comment + */ + announcementCommentId: number; + }; + }; + responses: { + _WelcomeMessage: { + content: { + "application/json": { + /** @description The interval in milliseconds that your bot should be configured to send ping frames for the bot's [heartbeat](/docs/api/heartbeat) to be considered valid. */ + heartbeatIntervalMs: number; + /** @description The last message's ID that was sent to this bot. See [event replay](/docs/api/replay) for more details */ + lastMessageId: string; + /** + * Bot ID + * Format: uuid + * @description The ID of the bot + */ + botId: string; + user: components["schemas"]["User"]; + }; + }; + }; + /** @description Emitted when a bot is added to a server */ + BotServerMembershipCreated: { + content: { + "application/json": { + server: components["schemas"]["Server"]; + /** + * Created by + * @description The ID of the user who created this server membership + */ + createdBy: string; + }; + }; + }; + /** @description Emitted when a bot is removed from a server */ + BotServerMembershipDeleted: { + content: { + "application/json": { + server: components["schemas"]["Server"]; + /** + * Deleted by + * @description The ID of the user who deleted this server membership + */ + deletedBy: string; + }; + }; + }; + ChatMessageCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + message: components["schemas"]["ChatMessage"]; + }; + }; + }; + ChatMessageUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + message: components["schemas"]["ChatMessage"]; + }; + }; + }; + ChatMessageDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + message: { + /** + * Message ID + * Format: uuid + * @description The ID of the message + */ + id: string; + /** + * Server ID + * @description The ID of the server + */ + serverId?: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Deleted at + * Format: date-time + * @description The ISO 8601 timestamp that the message was deleted at + */ + deletedAt: string; + /** Is private */ + isPrivate?: boolean; + }; + }; + }; + }; + ServerMemberJoined: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + member: components["schemas"]["ServerMember"]; + }; + }; + }; + ServerMemberRemoved: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * User ID + * @description The ID of the user + */ + userId: string; + /** + * Is kick? + * @description If this member leaving was the result of a kick + */ + isKick?: boolean; + /** + * Is ban? + * @description If this member leaving was the result of a ban + */ + isBan?: boolean; + }; + }; + }; + ServerMemberBanned: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + serverMemberBan: components["schemas"]["ServerMemberBan"]; + }; + }; + }; + ServerMemberUnbanned: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + serverMemberBan: components["schemas"]["ServerMemberBan"]; + }; + }; + }; + ServerMemberUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + userInfo: { + /** + * User ID + * @description The ID of the user + */ + id: string; + /** + * Nickname + * @description The nickname that was just updated for the user + */ + nickname?: string | null; + }; + }; + }; + }; + ServerRolesUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + memberRoleIds: ({ + /** + * User ID + * @description The ID of the member that had roles updated + */ + userId: string; + /** + * Role IDs + * @description The IDs of the roles that the member currently has _after_ this operation + */ + roleIds: (number)[]; + })[]; + }; + }; + }; + ServerChannelCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + channel: components["schemas"]["ServerChannel"]; + }; + }; + }; + ServerChannelUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + channel: components["schemas"]["ServerChannel"]; + }; + }; + }; + ServerChannelDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + channel: components["schemas"]["ServerChannel"]; + }; + }; + }; + ServerMemberSocialLinkCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + socialLink: components["schemas"]["SocialLink"]; + }; + }; + }; + ServerMemberSocialLinkUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + socialLink: components["schemas"]["SocialLink"]; + }; + }; + }; + ServerMemberSocialLinkDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + socialLink: components["schemas"]["SocialLink"]; + }; + }; + }; + ServerWebhookCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + webhook: components["schemas"]["Webhook"]; + }; + }; + }; + ServerWebhookUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + webhook: components["schemas"]["Webhook"]; + }; + }; + }; + DocCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + doc: components["schemas"]["Doc"]; + }; + }; + }; + DocUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + doc: components["schemas"]["Doc"]; + }; + }; + }; + DocDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + doc: components["schemas"]["Doc"]; + }; + }; + }; + DocCommentCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + docComment: components["schemas"]["DocComment"]; + }; + }; + }; + DocCommentDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + docComment: components["schemas"]["DocComment"]; + }; + }; + }; + DocCommentUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + docComment: components["schemas"]["DocComment"]; + }; + }; + }; + CalendarEventCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEvent: components["schemas"]["CalendarEvent"]; + }; + }; + }; + CalendarEventUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEvent: components["schemas"]["CalendarEvent"]; + }; + }; + }; + CalendarEventDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEvent: components["schemas"]["CalendarEvent"]; + }; + }; + }; + ForumTopicCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + ForumTopicUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + ForumTopicDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + ForumTopicPinned: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + ForumTopicUnpinned: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + ForumTopicReactionCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["ForumTopicReaction"]; + }; + }; + }; + ForumTopicReactionDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["ForumTopicReaction"]; + }; + }; + }; + ForumTopicLocked: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + ForumTopicUnlocked: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopic: components["schemas"]["ForumTopic"]; + }; + }; + }; + ForumTopicCommentCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopicComment: components["schemas"]["ForumTopicComment"]; + }; + }; + }; + ForumTopicCommentUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopicComment: components["schemas"]["ForumTopicComment"]; + }; + }; + }; + ForumTopicCommentDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + forumTopicComment: components["schemas"]["ForumTopicComment"]; + }; + }; + }; + CalendarEventRsvpUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEventRsvp: components["schemas"]["CalendarEventRsvp"]; + }; + }; + }; + CalendarEventRsvpManyUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEventRsvps: (components["schemas"]["CalendarEventRsvp"])[]; + }; + }; + }; + CalendarEventRsvpDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEventRsvp: components["schemas"]["CalendarEventRsvp"]; + }; + }; + }; + ListItemCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + listItem: components["schemas"]["ListItem"]; + }; + }; + }; + ListItemUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + listItem: components["schemas"]["ListItem"]; + }; + }; + }; + ListItemDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + listItem: components["schemas"]["ListItem"]; + }; + }; + }; + ListItemCompleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + listItem: components["schemas"]["ListItem"]; + }; + }; + }; + ListItemUncompleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + listItem: components["schemas"]["ListItem"]; + }; + }; + }; + ChannelMessageReactionCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["ChatMessageReaction"]; + }; + }; + }; + ChannelMessageReactionDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Deleted by + * @description The ID of the user who deleted this reaction + */ + deletedBy: string; + reaction: components["schemas"]["ChatMessageReaction"]; + }; + }; + }; + ChannelMessageReactionManyDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + /** + * Channel ID + * Format: uuid + * @description The ID of the channel + */ + channelId: string; + /** + * Message ID + * Format: uuid + * @description The ID of the message + */ + messageId: string; + /** + * Deleted by + * @description The ID of the user who deleted this reaction + */ + deletedBy: string; + /** @description The count of reactions that were removed */ + count: number; + /** @description If present, only reactions of this emote were bulk removed from the message */ + emote?: components["schemas"]["Emote"]; + }; + }; + }; + ForumTopicCommentReactionCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["ForumTopicCommentReaction"]; + }; + }; + }; + ForumTopicCommentReactionDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["ForumTopicCommentReaction"]; + }; + }; + }; + CalendarEventCommentCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEventComment: components["schemas"]["CalendarEventComment"]; + }; + }; + }; + CalendarEventCommentDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEventComment: components["schemas"]["CalendarEventComment"]; + }; + }; + }; + CalendarEventCommentUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEventComment: components["schemas"]["CalendarEventComment"]; + }; + }; + }; + CalendarEventReactionCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["CalendarEventReaction"]; + }; + }; + }; + CalendarEventReactionDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["CalendarEventReaction"]; + }; + }; + }; + CalendarEventCommentReactionCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["CalendarEventCommentReaction"]; + }; + }; + }; + CalendarEventCommentReactionDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["CalendarEventCommentReaction"]; + }; + }; + }; + DocReactionCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["DocReaction"]; + }; + }; + }; + DocReactionDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["DocReaction"]; + }; + }; + }; + DocCommentReactionCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["DocCommentReaction"]; + }; + }; + }; + DocCommentReactionDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["DocCommentReaction"]; + }; + }; + }; + CalendarEventSeriesUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEventSeries: components["schemas"]["CalendarEventSeries"]; + /** + * Calendar event ID + * @description The calendar event updates started at + */ + calendarEventId?: number; + }; + }; + }; + CalendarEventSeriesDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + calendarEventSeries: components["schemas"]["CalendarEventSeries"]; + /** + * Calendar event ID + * @description The calendar event deletions started at + */ + calendarEventId?: number; + }; + }; + }; + AnnouncementCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + announcement: components["schemas"]["Announcement"]; + }; + }; + }; + AnnouncementUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + announcement: components["schemas"]["Announcement"]; + }; + }; + }; + AnnouncementDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + announcement: components["schemas"]["Announcement"]; + }; + }; + }; + AnnouncementReactionCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["AnnouncementReaction"]; + }; + }; + }; + AnnouncementReactionDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["AnnouncementReaction"]; + }; + }; + }; + AnnouncementCommentCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + announcementComment: components["schemas"]["AnnouncementComment"]; + }; + }; + }; + AnnouncementCommentUpdated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + announcementComment: components["schemas"]["AnnouncementComment"]; + }; + }; + }; + AnnouncementCommentDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + announcementComment: components["schemas"]["AnnouncementComment"]; + }; + }; + }; + AnnouncementCommentReactionCreated: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["AnnouncementCommentReaction"]; + }; + }; + }; + AnnouncementCommentReactionDeleted: { + content: { + "application/json": { + /** + * Server ID + * @description The ID of the server + */ + serverId: string; + reaction: components["schemas"]["AnnouncementCommentReaction"]; + }; + }; + }; + }; + parameters: never; + requestBodies: never; + headers: never; + pathItems: never; +} + +export type external = Record; + +export type operations = Record; diff --git a/packages/guilded-api-typings/lib/v1/ws/CalendarEvent.ts b/packages/guilded-api-typings/lib/v1/ws/CalendarEvent.ts deleted file mode 100644 index ebe708b6..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/CalendarEvent.ts +++ /dev/null @@ -1,48 +0,0 @@ -import type { CalendarEventPayload, CalendarEventRsvpPayload } from "../structs/CalendarEvent"; -import type { SkeletonWSPayload, WSEvent } from "./Events"; - -export type WSCalendarEventCreated = SkeletonWSPayload & { - d: { - calendarEvent: CalendarEventPayload; - serverId: string; - }; - t: WSEvent["CalendarEventCreated"]; -}; -export type WSCalendarEventUpdated = SkeletonWSPayload & { - d: { - calendarEvent: CalendarEventPayload; - serverId: string; - }; - t: WSEvent["CalendarEventUpdated"]; -}; -export type WSCalendarEventDeleted = SkeletonWSPayload & { - d: { - calendarEvent: CalendarEventPayload; - serverId: string; - }; - t: WSEvent["CalendarEventDeleted"]; -}; - -export type WSCalendarEventRsvpUpdated = SkeletonWSPayload & { - d: { - calendarEventRsvp: CalendarEventRsvpPayload; - serverId: string; - }; - t: WSEvent["CalendarEventRsvpUpdated"]; -}; - -export type WSCalendarEventRsvpManyUpdated = SkeletonWSPayload & { - d: { - calendarEventRsvps: CalendarEventRsvpPayload[]; - serverId: string; - }; - t: WSEvent["CalendarEventRsvpManyUpdated"]; -}; - -export type WSCalendarEventRsvpDeleted = SkeletonWSPayload & { - d: { - calendarEventRsvp: CalendarEventRsvpPayload; - serverId: string; - }; - t: WSEvent["CalendarEventRsvpDeleted"]; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/Channel.ts b/packages/guilded-api-typings/lib/v1/ws/Channel.ts deleted file mode 100644 index b653f5b0..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/Channel.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { ServerChannelPayload } from "../structs"; -import type { SkeletonWSPayload, WSEvent } from "./Events"; - -export type WSServerChannelCreated = SkeletonWSPayload & { - d: { - channel: ServerChannelPayload; - serverId: string; - }; - t: WSEvent["ServerChannelCreated"]; -}; -export type WSServerChannelUpdated = SkeletonWSPayload & { - d: { - channel: ServerChannelPayload; - serverId: string; - }; - t: WSEvent["ServerChannelUpdated"]; -}; -export type WSServerChannelDeleted = SkeletonWSPayload & { - d: { - channel: ServerChannelPayload; - serverId: string; - }; - t: WSEvent["ServerChannelDeleted"]; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/Doc.ts b/packages/guilded-api-typings/lib/v1/ws/Doc.ts deleted file mode 100644 index 75b7a2ca..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/Doc.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { DocPayload } from "../structs"; -import type { SkeletonWSPayload, WSEvent } from "./Events"; - -export type WSDocCreated = SkeletonWSPayload & { - d: { - doc: DocPayload; - serverId: string; - }; - t: WSEvent["DocCreated"]; -}; -export type WSDocUpdated = SkeletonWSPayload & { - d: { - doc: DocPayload; - serverId: string; - }; - t: WSEvent["DocUpdated"]; -}; -export type WSDocDeleted = SkeletonWSPayload & { - d: { - doc: DocPayload; - serverId: string; - }; - t: WSEvent["DocDeleted"]; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/Events.ts b/packages/guilded-api-typings/lib/v1/ws/Events.ts deleted file mode 100644 index 9f9e13a2..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/Events.ts +++ /dev/null @@ -1,75 +0,0 @@ -export enum WSOpCodes { - SUCCESS, - WELCOME, - RESUME, - ERROR = 8, - PING, - PONG, -} - -export const WebSocketEvents = { - CalendarEventCreated: "CalendarEventCreated", - CalendarEventUpdated: "CalendarEventUpdated", - CalendarEventDeleted: "CalendarEventDeleted", - CalendarEventRsvpUpdated: "CalendarEventRsvpUpdated", - CalendarEventRsvpManyUpdated: "CalendarEventRsvpManyUpdated", - CalendarEventRsvpDeleted: "CalendarEventRsvpDeleted", - ChatMessageCreated: "ChatMessageCreated", - ChatMessageUpdated: "ChatMessageUpdated", - ChatMessageDeleted: "ChatMessageDeleted", - ServerMemberJoined: "ServerMemberJoined", - ServerMemberRemoved: "ServerMemberRemoved", - ServerMemberUpdated: "ServerMemberUpdated", - ServerMemberBanned: "ServerMemberBanned", - ServerMemberUnbanned: "ServerMemberUnbanned", - ServerMemberSocialLinkCreated: "ServerMemberSocialLinkCreated", - ServerMemberSocialLinkUpdated: "ServerMemberSocialLinkUpdated", - ServerMemberSocialLinkDeleted: "ServerMemberSocialLinkDeleted", - BotServerMembershipCreated: "BotServerMembershipCreated", - BotServerMembershipDeleted: "BotServerMembershipDeleted", - ServerRolesUpdated: "ServerRolesUpdated", - ServerWebhookCreated: "ServerWebhookCreated", - ServerWebhookUpdated: "ServerWebhookUpdated", - ListItemCompleted: "ListItemCompleted", - ListItemUncompleted: "ListItemUncompleted", - ListItemCreated: "ListItemCreated", - ListItemUpdated: "ListItemUpdated", - ListItemDeleted: "ListItemDeleted", - ServerChannelCreated: "ServerChannelCreated", - ServerChannelUpdated: "ServerChannelUpdated", - ServerChannelDeleted: "ServerChannelDeleted", - DocCreated: "DocCreated", - DocUpdated: "DocUpdated", - DocDeleted: "DocDeleted", - ChannelMessageReactionCreated: "ChannelMessageReactionCreated", - ChannelMessageReactionDeleted: "ChannelMessageReactionDeleted", - ForumTopicCreated: "ForumTopicCreated", - ForumTopicUpdated: "ForumTopicUpdated", - ForumTopicDeleted: "ForumTopicDeleted", - ForumTopicPinned: "ForumTopicPinned", - ForumTopicUnpinned: "ForumTopicUnpinned", - ForumTopicLocked: "ForumTopicLocked", - ForumTopicUnlocked: "ForumTopicUnlocked", -} as const; -export type WSEvent = typeof WebSocketEvents; - -export type SkeletonWSPayload = { - d: unknown; - op: WSOpCodes; - s?: string; - t: keyof WSEvent; -}; - -export type WSWelcomePayload = SkeletonWSPayload & { - d: { - heartbeatIntervalMs: number; - lastMessageId: string; - user: { - botId: string; - createdAt: string; - createdBy: string; - id: string; - name: string; - }; - }; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/Forum.ts b/packages/guilded-api-typings/lib/v1/ws/Forum.ts deleted file mode 100644 index 748a7fcf..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/Forum.ts +++ /dev/null @@ -1,58 +0,0 @@ -import type { ForumTopicPayload } from "../structs"; -import type { SkeletonWSPayload, WSEvent } from "./Events"; - -export type WSForumTopicCreated = SkeletonWSPayload & { - d: { - forumTopic: ForumTopicPayload; - serverId: string; - }; - t: WSEvent["ForumTopicCreated"]; -}; - -export type WSForumTopicUpdated = SkeletonWSPayload & { - d: { - forumTopic: ForumTopicPayload; - serverId: string; - }; - t: WSEvent["ForumTopicUpdated"]; -}; - -export type WSForumTopicDeleted = SkeletonWSPayload & { - d: { - forumTopic: ForumTopicPayload; - serverId: string; - }; - t: WSEvent["ForumTopicDeleted"]; -}; - -export type WSForumTopicPinned = SkeletonWSPayload & { - d: { - forumTopic: ForumTopicPayload; - serverId: string; - }; - t: WSEvent["ForumTopicPinned"]; -}; - -export type WSForumTopicUnpinned = SkeletonWSPayload & { - d: { - forumTopic: ForumTopicPayload; - serverId: string; - }; - t: WSEvent["ForumTopicUnpinned"]; -}; - -export type WSForumTopicLocked = SkeletonWSPayload & { - d: { - forumTopic: ForumTopicPayload; - serverId: string; - }; - t: WSEvent["ForumTopicLocked"]; -}; - -export type WSForumTopicUnlocked = SkeletonWSPayload & { - d: { - forumTopic: ForumTopicPayload; - serverId: string; - }; - t: WSEvent["ForumTopicUnlocked"]; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/List.ts b/packages/guilded-api-typings/lib/v1/ws/List.ts deleted file mode 100644 index 66078aaf..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/List.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { ListItemPayload } from "../structs"; -import type { SkeletonWSPayload, WSEvent } from "./Events"; - -export type WSListItemCreated = SkeletonWSPayload & { - d: { - listItem: ListItemPayload; - serverId: string; - }; - t: WSEvent["ListItemCreated"]; -}; -export type WSListItemUpdated = SkeletonWSPayload & { - d: { - listItem: ListItemPayload; - serverId: string; - }; - t: WSEvent["ListItemUpdated"]; -}; -export type WSListItemDeleted = SkeletonWSPayload & { - d: { - listItem: ListItemPayload; - serverId: string; - }; - t: WSEvent["ListItemDeleted"]; -}; - -export type WSListItemCompleted = SkeletonWSPayload & { - d: { - listItem: ListItemPayload; - serverId: string; - }; - t: WSEvent["ListItemCompleted"]; -}; - -export type WSListItemUncompleted = SkeletonWSPayload & { - d: { - listItem: ListItemPayload; - serverId: string; - }; - t: WSEvent["ListItemUncompleted"]; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/Member.ts b/packages/guilded-api-typings/lib/v1/ws/Member.ts deleted file mode 100644 index 14ed5c31..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/Member.ts +++ /dev/null @@ -1,101 +0,0 @@ -import type { - ServerMemberBanPayload, - ServerMemberPayload, - ServerMemberRoleIdsPayload, - ServerPayload, - SocialLink, -} from "../structs"; -import type { SkeletonWSPayload, WSEvent } from "./Events"; - -export type WSServerMemberJoinedPayload = SkeletonWSPayload & { - d: { - member: ServerMemberPayload; - serverId: string; - }; - t: WSEvent["ServerMemberJoined"]; -}; - -export type WSServerMemberRemovedPayload = SkeletonWSPayload & { - d: { - isBan: boolean; - isKick: boolean; - serverId: string; - userId: string; - }; - t: WSEvent["ServerMemberRemoved"]; -}; - -export type WSServerMemberUpdatedPayload = SkeletonWSPayload & { - d: { - serverId: string; - userInfo: { - id: string; - nickname: string; - }; - }; - t: WSEvent["ServerMemberUpdated"]; -}; - -export type WSServerMemberBannedPayload = SkeletonWSPayload & { - d: { - serverId: string; - serverMemberBan: ServerMemberBanPayload; - }; - t: WSEvent["ServerMemberBanned"]; -}; - -export type WSServerMemberUnbannedPayload = SkeletonWSPayload & { - d: { - serverId: string; - serverMemberBan: ServerMemberBanPayload; - }; - t: WSEvent["ServerMemberUnbanned"]; -}; - -export type WSServerRolesUpdatedPayload = SkeletonWSPayload & { - d: { - memberRoleIds: ServerMemberRoleIdsPayload[]; - serverId: string; - }; - t: WSEvent["ServerRolesUpdated"]; -}; - -export type WSBotServerMembershipCreated = SkeletonWSPayload & { - d: { - createdBy: string; - server: ServerPayload; - }; - t: WSEvent["BotServerMembershipCreated"]; -}; - -export type WSBotServerMembershipDeleted = SkeletonWSPayload & { - d: { - deletedBy: string; - server: ServerPayload; - }; - t: WSEvent["BotServerMembershipDeleted"]; -}; - -export type WSServerMemberSocialLinkCreated = SkeletonWSPayload & { - d: { - serverId: string; - socialLink: SocialLink; - }; - t: WSEvent["ServerMemberSocialLinkCreated"]; -}; - -export type WSServerMemberSocialLinkUpdated = SkeletonWSPayload & { - d: { - serverId: string; - socialLink: SocialLink; - }; - t: WSEvent["ServerMemberSocialLinkUpdated"]; -}; - -export type WSServerMemberSocialLinkDeleted = SkeletonWSPayload & { - d: { - serverId: string; - socialLink: SocialLink; - }; - t: WSEvent["ServerMemberSocialLinkDeleted"]; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/Message.ts b/packages/guilded-api-typings/lib/v1/ws/Message.ts deleted file mode 100644 index 707a23cd..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/Message.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { ChatMessagePayload } from "../structs"; -import type { SkeletonWSPayload, WSEvent } from "./Events"; - -export type WSChatMessageCreatedPayload = SkeletonWSPayload & { - d: { - message: ChatMessagePayload; - serverId: string; - }; - t: WSEvent["ChatMessageCreated"]; -}; - -export type WSChatMessageUpdatedPayload = SkeletonWSPayload & { - d: { - message: ChatMessagePayload; - serverId: string; - }; - t: WSEvent["ChatMessageUpdated"]; -}; - -export type WSChatMessageDeletedPayload = SkeletonWSPayload & { - d: { - message: { - channelId: string; - deletedAt: string; - id: string; - isPrivate: boolean; - serverId: string; - }; - serverId: string; - }; - t: WSEvent["ChatMessageDeleted"]; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/Reaction.ts b/packages/guilded-api-typings/lib/v1/ws/Reaction.ts deleted file mode 100644 index 818f1f47..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/Reaction.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { EmotePayload } from "../structs"; -import type { SkeletonWSPayload, WSEvent } from "./Events"; - -export type WSChannelMessageReactionCreatedPayload = SkeletonWSPayload & { - d: { - reaction: { - channelId: string; - createdBy: string; - emote: EmotePayload; - messageId: string; - }; - serverId: string; - }; - t: WSEvent["ChannelMessageReactionCreated"]; -}; - -export type WSChannelMessageReactionDeletedPayload = SkeletonWSPayload & { - d: { - reaction: { - channelId: string; - createdBy: string; - emote: EmotePayload; - messageId: string; - }; - serverId: string; - }; - t: WSEvent["ChannelMessageReactionDeleted"]; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/Webhook.ts b/packages/guilded-api-typings/lib/v1/ws/Webhook.ts deleted file mode 100644 index 33409089..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/Webhook.ts +++ /dev/null @@ -1,18 +0,0 @@ -import type { WebhookPayload } from "../structs"; -import type { SkeletonWSPayload, WSEvent } from "./Events"; - -export type WSServerWebhookCreatedPayload = SkeletonWSPayload & { - d: { - serverId: string; - webhook: WebhookPayload; - }; - t: WSEvent["ServerWebhookCreated"]; -}; - -export type WSServerWebhookUpdatedPayload = SkeletonWSPayload & { - d: { - serverId: string; - webhook: WebhookPayload; - }; - t: WSEvent["ServerWebhookUpdated"]; -}; diff --git a/packages/guilded-api-typings/lib/v1/ws/index.ts b/packages/guilded-api-typings/lib/v1/ws/index.ts deleted file mode 100644 index 09434b36..00000000 --- a/packages/guilded-api-typings/lib/v1/ws/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from "./CalendarEvent"; -export * from "./Channel"; -export * from "./Doc"; -export * from "./Events"; -export * from "./Forum"; -export * from "./List"; -export * from "./Member"; -export * from "./Message"; -export * from "./Reaction"; -export * from "./Webhook"; diff --git a/packages/guilded-api-typings/package.json b/packages/guilded-api-typings/package.json index 40399844..b111bdab 100644 --- a/packages/guilded-api-typings/package.json +++ b/packages/guilded-api-typings/package.json @@ -1,63 +1,66 @@ { - "name": "@guildedjs/guilded-api-typings", - "version": "3.0.2", - "description": "Typings for the guilded API", - "author": "Zaid \"Nico\" ", - "license": "MIT", - "types": "dist/index.d.ts", - "main": "dist/index.js", - "typedoc": { - "entryPoint": "lib/index.ts" - }, - "scripts": { - "build": "tsc", - "build:typecheck": "tsc --noEmit", - "prepublishOnly": "rimraf dist/ && pnpm run build" - }, - "devDependencies": { - "typescript": "5.0.4" - }, - "contributors": [ - { - "name": "Zaid \"Nico\"", - "email": "contact@nico.engineer", - "url": "https://github.com/zaida04" - }, - { - "name": "Skillz4Killz", - "email": "guildedjs@drskillz.33mail.com", - "url": "https://github.com/Skillz4Killz" - }, - { - "name": "Uhuh \"Dylan\"", - "email": "dylan@panku.io", - "url": "https://github.com/uhuh" - }, - { - "name": "DaStormer", - "email": "dastormer@stormdevelopmentz.xyz", - "url": "https://github.com/DaStormer" - } - ], - "keywords": [ - "guilded", - "guildedjs", - "guilded.js", - "guilded-api", - "guilded-api-wrapper", - "guilded-wrapper", - "guilded-api-typings" - ], - "files": [ - "dist" - ], - "homepage": "https://github.com/guildedjs/guilded.js/tree/main/packages/guilded-api-typings#readme", - "repository": { - "type": "git", - "url": "git+https://github.com/guildedjs/guilded.js.git" - }, - "bugs": { - "url": "https://github.com/guildedjs/guilded.js/issues" - }, - "gitHead": "eee38a19e0bfa812d7136cc78a6bc99e0b402b0c" -} + "name": "@guildedjs/guilded-api-typings", + "version": "3.0.2", + "description": "Typings for the guilded API", + "author": "Zaid \"Nico\" ", + "license": "MIT", + "types": "dist/index.d.ts", + "main": "dist/index.js", + "typedoc": { + "entryPoint": "lib/index.ts" + }, + "scripts": { + "build": "tsc", + "build:typecheck": "tsc --noEmit", + "prepublishOnly": "rimraf dist/ && pnpm run build", + "generate:ws": "openapi-typescript \"https://www.guilded.gg/api/v1/socket-open-api-schema.json\" --output lib/v1/ws.ts", + "generate:rest": "openapi-typescript \"https://www.guilded.gg/api/v1/open-api-schema.json\" --output lib/v1/rest.ts" + }, + "devDependencies": { + "openapi-typescript": "^6.2.4", + "typescript": "5.0.4" + }, + "contributors": [ + { + "name": "Zaid \"Nico\"", + "email": "contact@nico.engineer", + "url": "https://github.com/zaida04" + }, + { + "name": "Skillz4Killz", + "email": "guildedjs@drskillz.33mail.com", + "url": "https://github.com/Skillz4Killz" + }, + { + "name": "Uhuh \"Dylan\"", + "email": "dylan@panku.io", + "url": "https://github.com/uhuh" + }, + { + "name": "DaStormer", + "email": "dastormer@stormdevelopmentz.xyz", + "url": "https://github.com/DaStormer" + } + ], + "keywords": [ + "guilded", + "guildedjs", + "guilded.js", + "guilded-api", + "guilded-api-wrapper", + "guilded-wrapper", + "guilded-api-typings" + ], + "files": [ + "dist" + ], + "homepage": "https://github.com/guildedjs/guilded.js/tree/main/packages/guilded-api-typings#readme", + "repository": { + "type": "git", + "url": "git+https://github.com/guildedjs/guilded.js.git" + }, + "bugs": { + "url": "https://github.com/guildedjs/guilded.js/issues" + }, + "gitHead": "eee38a19e0bfa812d7136cc78a6bc99e0b402b0c" +} \ No newline at end of file diff --git a/packages/guilded.js/lib/events.ts b/packages/guilded.js/lib/events.ts index 2bd3af04..a430f1e5 100644 --- a/packages/guilded.js/lib/events.ts +++ b/packages/guilded.js/lib/events.ts @@ -1,42 +1,39 @@ -import type { - EmotePayload, - UserSummaryPayload, -} from "@guildedjs/guilded-api-typings"; -import type { ForumTopic, Member } from "./structures"; +import { Schema } from "@guildedjs/guilded-api-typings"; +import type { Member } from "./structures"; export interface ServerEvent { - serverId: string; + serverId: string; } export interface MemberUnbannedEvent extends ServerEvent { - createdAt: string; - createdBy: string; - reason?: string; - user: UserSummaryPayload; + createdAt: string; + createdBy: string; + reason?: string; + user: Schema<"UserSummary">; } export interface MemberRemovedEvent extends ServerEvent { - isBan: boolean; - isKick: boolean; - userId: string; + isBan?: boolean; + isKick?: boolean; + userId: string; } export interface MemberUpdatedEvent extends ServerEvent { - userId: string; - nickname: string; - oldMember: Member | null; + userId: string; + nickname: string | null; + oldMember: Member | null; } export interface MessageReactionDeletedEvent extends ServerEvent { - channelId: string; - createdBy: string; - emote: EmotePayload; - messageId: string; + channelId: string; + createdBy: string; + emote: Schema<"Emote">; + messageId: string; } export interface MessageDeletedEvent extends ServerEvent { - channelId: string; - deletedAt: string; - id: string; - isPrivate: boolean; + channelId: string; + deletedAt: string; + id: string; + isPrivate?: boolean; } diff --git a/packages/guilded.js/lib/gateway/ClientGatewayHandler.ts b/packages/guilded.js/lib/gateway/ClientGatewayHandler.ts index 663965a5..faf11d53 100644 --- a/packages/guilded.js/lib/gateway/ClientGatewayHandler.ts +++ b/packages/guilded.js/lib/gateway/ClientGatewayHandler.ts @@ -3,50 +3,9 @@ import { MessageEventHandler } from "./handler/MessageEventHandler"; import { ServerEventHandler } from "./handler/ServerEventHandler"; import { ServerMemberEventHandler } from "./handler/ServerMemberEventHandler"; import type { - SkeletonWSPayload, - WSChatMessageCreatedPayload, - WSChatMessageDeletedPayload, - WSChatMessageUpdatedPayload, - WSDocCreated, - WSDocDeleted, - WSDocUpdated, - WSEvent, - WSListItemCompleted, - WSListItemCreated, - WSListItemDeleted, - WSListItemUncompleted, - WSListItemUpdated, - WSServerChannelCreated, - WSServerChannelDeleted, - WSServerChannelUpdated, - WSServerMemberBannedPayload, - WSServerMemberJoinedPayload, - WSServerMemberRemovedPayload, - WSServerMemberUnbannedPayload, - WSServerMemberUpdatedPayload, - WSServerRolesUpdatedPayload, - WSServerWebhookCreatedPayload, - WSServerWebhookUpdatedPayload, - WSChannelMessageReactionCreatedPayload, - WSChannelMessageReactionDeletedPayload, - WSCalendarEventCreated, - WSCalendarEventDeleted, - WSCalendarEventUpdated, - WSCalendarEventRsvpUpdated, - WSCalendarEventRsvpManyUpdated, - WSCalendarEventRsvpDeleted, - WSForumTopicCreated, - WSForumTopicDeleted, - WSForumTopicUpdated, - WSForumTopicPinned, - WSForumTopicUnpinned, - WSForumTopicLocked, - WSForumTopicUnlocked, - WSBotServerMembershipCreated, - WSBotServerMembershipDeleted, - WSServerMemberSocialLinkCreated, - WSServerMemberSocialLinkUpdated, - WSServerMemberSocialLinkDeleted, + SkeletonWSPayload, + WSEvent, + WSPacket, } from "@guildedjs/guilded-api-typings"; import { WebSocketEvents } from "@guildedjs/guilded-api-typings"; import { ServerWebhookEventHandler } from "./handler/ServerWebhookEventHandler"; @@ -55,170 +14,170 @@ import { ServerChannelEventHandler } from "./handler/ServerChannelEventHandler"; import { DocEventHandler } from "./handler/DocEventHandler"; import { ReactionEventHandler } from "./handler/ReactionEventHandler"; import { - CalendarEventHandler, - CalendarEventRsvpHandler, + CalendarEventHandler, + CalendarEventRsvpHandler, } from "./handler/CalendarEventHandler"; import { ForumEventHandler } from "./handler/ForumEventHandler"; import { BotEventHandler } from "./handler/BotEventHandler"; export class ClientGatewayHandler { - calendarEventHandler = new CalendarEventHandler(this.client); - calendarEventRsvpHandler = new CalendarEventRsvpHandler(this.client); - messageHandler = new MessageEventHandler(this.client); - ServerHandler = new ServerEventHandler(this.client); - ServerMemberHandler = new ServerMemberEventHandler(this.client); - ServerWebhookHandler = new ServerWebhookEventHandler(this.client); - listHandler = new ListEventHandler(this.client); - ServerChannelHandler = new ServerChannelEventHandler(this.client); - docHandler = new DocEventHandler(this.client); - reactionHandler = new ReactionEventHandler(this.client); - forumHandler = new ForumEventHandler(this.client); - botHandler = new BotEventHandler(this.client); + calendarEventHandler = new CalendarEventHandler(this.client); + calendarEventRsvpHandler = new CalendarEventRsvpHandler(this.client); + messageHandler = new MessageEventHandler(this.client); + ServerHandler = new ServerEventHandler(this.client); + ServerMemberHandler = new ServerMemberEventHandler(this.client); + ServerWebhookHandler = new ServerWebhookEventHandler(this.client); + listHandler = new ListEventHandler(this.client); + ServerChannelHandler = new ServerChannelEventHandler(this.client); + docHandler = new DocEventHandler(this.client); + reactionHandler = new ReactionEventHandler(this.client); + forumHandler = new ForumEventHandler(this.client); + botHandler = new BotEventHandler(this.client); - readonly eventToHandlerMap: Record< - keyof WSEvent, - (data: SkeletonWSPayload) => boolean | Promise - > = { - [WebSocketEvents.CalendarEventCreated]: (data) => - this.calendarEventHandler.calendarEventCreated( - data as WSCalendarEventCreated - ), - [WebSocketEvents.CalendarEventDeleted]: (data) => - this.calendarEventHandler.calendarEventDeleted( - data as WSCalendarEventDeleted - ), - [WebSocketEvents.CalendarEventUpdated]: (data) => - this.calendarEventHandler.calendarEventUpdated( - data as WSCalendarEventUpdated - ), - [WebSocketEvents.CalendarEventRsvpUpdated]: (data) => - this.calendarEventRsvpHandler.calendarEventRsvpUpdated( - data as WSCalendarEventRsvpUpdated - ), - [WebSocketEvents.CalendarEventRsvpManyUpdated]: (data) => - this.calendarEventRsvpHandler.calendarEventRsvpManyUpdated( - data as WSCalendarEventRsvpManyUpdated - ), - [WebSocketEvents.CalendarEventRsvpDeleted]: (data) => - this.calendarEventRsvpHandler.calendarEventRsvpDeleted( - data as WSCalendarEventRsvpDeleted - ), - [WebSocketEvents.ChatMessageCreated]: (data) => - this.messageHandler.messageCreated(data as WSChatMessageCreatedPayload), - [WebSocketEvents.ChatMessageDeleted]: (data) => - this.messageHandler.messageDeleted(data as WSChatMessageDeletedPayload), - [WebSocketEvents.ChatMessageUpdated]: (data) => - this.messageHandler.messageUpdated(data as WSChatMessageUpdatedPayload), - [WebSocketEvents.ServerMemberJoined]: (data) => - this.ServerMemberHandler.serverMemberJoined( - data as WSServerMemberJoinedPayload - ), - [WebSocketEvents.ServerMemberRemoved]: (data) => - this.ServerMemberHandler.serverMemberRemoved( - data as WSServerMemberRemovedPayload - ), - [WebSocketEvents.ServerMemberUpdated]: (data) => - this.ServerMemberHandler.serverMemberUpdated( - data as WSServerMemberUpdatedPayload - ), - [WebSocketEvents.ServerRolesUpdated]: (data) => - this.ServerHandler.serverRolesUpdated( - data as WSServerRolesUpdatedPayload - ), - [WebSocketEvents.ServerMemberBanned]: (data) => - this.ServerMemberHandler.serverMemberBanned( - data as WSServerMemberBannedPayload - ), - [WebSocketEvents.ServerMemberUnbanned]: (data) => - this.ServerMemberHandler.serverMemberUnbanned( - data as WSServerMemberUnbannedPayload - ), - [WebSocketEvents.ServerMemberSocialLinkCreated]: (data) => - this.ServerMemberHandler.serverMemberSocialLinkCreated( - data as WSServerMemberSocialLinkCreated - ), - [WebSocketEvents.ServerMemberSocialLinkUpdated]: (data) => - this.ServerMemberHandler.serverMemberSocialLinkUpdated( - data as WSServerMemberSocialLinkUpdated - ), - [WebSocketEvents.ServerMemberSocialLinkDeleted]: (data) => - this.ServerMemberHandler.serverMemberSocialLinkDeleted( - data as WSServerMemberSocialLinkDeleted - ), - [WebSocketEvents.ServerWebhookCreated]: (data) => - this.ServerWebhookHandler.serverWebhookCreated( - data as WSServerWebhookCreatedPayload - ), - [WebSocketEvents.ServerWebhookUpdated]: (data) => - this.ServerWebhookHandler.serverWebhookUpdated( - data as WSServerWebhookUpdatedPayload - ), - [WebSocketEvents.BotServerMembershipCreated]: (data) => - this.botHandler.botServerMembershipCreated( - data as WSBotServerMembershipCreated - ), - [WebSocketEvents.BotServerMembershipDeleted]: (data) => - this.botHandler.botServerMembershipDeleted( - data as WSBotServerMembershipDeleted - ), - [WebSocketEvents.ListItemCompleted]: (data) => - this.listHandler.listItemCompleted(data as WSListItemCompleted), - [WebSocketEvents.ListItemUncompleted]: (data) => - this.listHandler.listItemUncompleted(data as WSListItemUncompleted), - [WebSocketEvents.ListItemCreated]: (data) => - this.listHandler.listItemCreated(data as WSListItemCreated), - [WebSocketEvents.ListItemUpdated]: (data) => - this.listHandler.listItemUpdated(data as WSListItemUpdated), - [WebSocketEvents.ListItemDeleted]: (data) => - this.listHandler.listItemDeleted(data as WSListItemDeleted), - [WebSocketEvents.DocCreated]: (data) => - this.docHandler.docCreated(data as WSDocCreated), - [WebSocketEvents.DocDeleted]: (data) => - this.docHandler.docDeleted(data as WSDocDeleted), - [WebSocketEvents.DocUpdated]: (data) => - this.docHandler.docUpdated(data as WSDocUpdated), - [WebSocketEvents.ServerChannelCreated]: (data) => - this.ServerChannelHandler.serverChannelCreated( - data as WSServerChannelCreated - ), - [WebSocketEvents.ServerChannelDeleted]: (data) => - this.ServerChannelHandler.serverChannelDeleted( - data as WSServerChannelDeleted - ), - [WebSocketEvents.ServerChannelUpdated]: (data) => - this.ServerChannelHandler.serverChannelUpdated( - data as WSServerChannelUpdated - ), - [WebSocketEvents.ChannelMessageReactionCreated]: (data) => - this.reactionHandler.messageReactionCreated( - data as WSChannelMessageReactionCreatedPayload - ), - [WebSocketEvents.ChannelMessageReactionDeleted]: (data) => - this.reactionHandler.messageReactionDeleted( - data as WSChannelMessageReactionDeletedPayload - ), - [WebSocketEvents.ForumTopicCreated]: (data) => - this.forumHandler.forumTopicCreated(data as WSForumTopicCreated), - [WebSocketEvents.ForumTopicDeleted]: (data) => - this.forumHandler.forumTopicDeleted(data as WSForumTopicDeleted), - [WebSocketEvents.ForumTopicUpdated]: (data) => - this.forumHandler.forumTopicUpdated(data as WSForumTopicUpdated), - [WebSocketEvents.ForumTopicPinned]: (data) => - this.forumHandler.forumTopicPinned(data as WSForumTopicPinned), - [WebSocketEvents.ForumTopicUnpinned]: (data) => - this.forumHandler.forumTopicUnpinned(data as WSForumTopicUnpinned), - [WebSocketEvents.ForumTopicLocked]: (data) => - this.forumHandler.forumTopicLocked(data as WSForumTopicLocked), - [WebSocketEvents.ForumTopicUnlocked]: (data) => - this.forumHandler.forumTopicUnlocked(data as WSForumTopicUnlocked), - }; + readonly eventToHandlerMap: Record< + keyof WSEvent, + (data: SkeletonWSPayload) => boolean | Promise + > = { + [WebSocketEvents.CalendarEventCreated]: (data) => + this.calendarEventHandler.calendarEventCreated( + data as WSPacket<"CalendarEventCreated"> + ), + [WebSocketEvents.CalendarEventDeleted]: (data) => + this.calendarEventHandler.calendarEventDeleted( + data as WSPacket<"CalendarEventDeleted"> + ), + [WebSocketEvents.CalendarEventUpdated]: (data) => + this.calendarEventHandler.calendarEventUpdated( + data as WSPacket<"CalendarEventUpdated"> + ), + [WebSocketEvents.CalendarEventRsvpUpdated]: (data) => + this.calendarEventRsvpHandler.calendarEventRsvpUpdated( + data as WSPacket<"CalendarEventRsvpUpdated"> + ), + [WebSocketEvents.CalendarEventRsvpManyUpdated]: (data) => + this.calendarEventRsvpHandler.calendarEventRsvpManyUpdated( + data as WSPacket<"CalendarEventRsvpManyUpdated"> + ), + [WebSocketEvents.CalendarEventRsvpDeleted]: (data) => + this.calendarEventRsvpHandler.calendarEventRsvpDeleted( + data as WSPacket<"CalendarEventRsvpDeleted"> + ), + [WebSocketEvents.ChatMessageCreated]: (data) => + this.messageHandler.messageCreated(data as WSPacket<"ChatMessageCreated">), + [WebSocketEvents.ChatMessageDeleted]: (data) => + this.messageHandler.messageDeleted(data as WSPacket<"ChatMessageDeleted">), + [WebSocketEvents.ChatMessageUpdated]: (data) => + this.messageHandler.messageUpdated(data as WSPacket<"ChatMessageUpdated">), + [WebSocketEvents.ServerMemberJoined]: (data) => + this.ServerMemberHandler.serverMemberJoined( + data as WSPacket<"ServerMemberJoined"> + ), + [WebSocketEvents.ServerMemberRemoved]: (data) => + this.ServerMemberHandler.serverMemberRemoved( + data as WSPacket<"ServerMemberRemoved"> + ), + [WebSocketEvents.ServerMemberUpdated]: (data) => + this.ServerMemberHandler.serverMemberUpdated( + data as WSPacket<"ServerMemberUpdated"> + ), + [WebSocketEvents.ServerRolesUpdated]: (data) => + this.ServerHandler.serverRolesUpdated( + data as WSPacket<"ServerRolesUpdated"> + ), + [WebSocketEvents.ServerMemberBanned]: (data) => + this.ServerMemberHandler.serverMemberBanned( + data as WSPacket<"ServerMemberBanned"> + ), + [WebSocketEvents.ServerMemberUnbanned]: (data) => + this.ServerMemberHandler.serverMemberUnbanned( + data as WSPacket<"ServerMemberUnbanned"> + ), + [WebSocketEvents.ServerMemberSocialLinkCreated]: (data) => + this.ServerMemberHandler.serverMemberSocialLinkCreated( + data as WSPacket<"ServerMemberSocialLinkCreated"> + ), + [WebSocketEvents.ServerMemberSocialLinkUpdated]: (data) => + this.ServerMemberHandler.serverMemberSocialLinkUpdated( + data as WSPacket<"ServerMemberSocialLinkUpdated"> + ), + [WebSocketEvents.ServerMemberSocialLinkDeleted]: (data) => + this.ServerMemberHandler.serverMemberSocialLinkDeleted( + data as WSPacket<"ServerMemberSocialLinkDeleted"> + ), + [WebSocketEvents.ServerWebhookCreated]: (data) => + this.ServerWebhookHandler.serverWebhookCreated( + data as WSPacket<"ServerWebhookCreated"> + ), + [WebSocketEvents.ServerWebhookUpdated]: (data) => + this.ServerWebhookHandler.serverWebhookUpdated( + data as WSPacket<"ServerWebhookUpdated"> + ), + [WebSocketEvents.BotServerMembershipCreated]: (data) => + this.botHandler.botServerMembershipCreated( + data as WSPacket<"BotServerMembershipCreated"> + ), + [WebSocketEvents.BotServerMembershipDeleted]: (data) => + this.botHandler.botServerMembershipDeleted( + data as WSPacket<"BotServerMembershipDeleted"> + ), + [WebSocketEvents.ListItemCompleted]: (data) => + this.listHandler.listItemCompleted(data as WSPacket<"ListItemCompleted">), + [WebSocketEvents.ListItemUncompleted]: (data) => + this.listHandler.listItemUncompleted(data as WSPacket<"ListItemUncompleted">), + [WebSocketEvents.ListItemCreated]: (data) => + this.listHandler.listItemCreated(data as WSPacket<"ListItemCreated">), + [WebSocketEvents.ListItemUpdated]: (data) => + this.listHandler.listItemUpdated(data as WSPacket<"ListItemUpdated">), + [WebSocketEvents.ListItemDeleted]: (data) => + this.listHandler.listItemDeleted(data as WSPacket<"ListItemDeleted">), + [WebSocketEvents.DocCreated]: (data) => + this.docHandler.docCreated(data as WSPacket<"DocCreated">), + [WebSocketEvents.DocDeleted]: (data) => + this.docHandler.docDeleted(data as WSPacket<"DocDeleted">), + [WebSocketEvents.DocUpdated]: (data) => + this.docHandler.docUpdated(data as WSPacket<"DocUpdated">), + [WebSocketEvents.ServerChannelCreated]: (data) => + this.ServerChannelHandler.serverChannelCreated( + data as WSPacket<"ServerChannelCreated"> + ), + [WebSocketEvents.ServerChannelDeleted]: (data) => + this.ServerChannelHandler.serverChannelDeleted( + data as WSPacket<"ServerChannelDeleted"> + ), + [WebSocketEvents.ServerChannelUpdated]: (data) => + this.ServerChannelHandler.serverChannelUpdated( + data as WSPacket<"ServerChannelUpdated"> + ), + [WebSocketEvents.ChannelMessageReactionCreated]: (data) => + this.reactionHandler.messageReactionCreated( + data as WSPacket<"ChannelMessageReactionCreated"> + ), + [WebSocketEvents.ChannelMessageReactionDeleted]: (data) => + this.reactionHandler.messageReactionDeleted( + data as WSPacket<"ChannelMessageReactionDeleted"> + ), + [WebSocketEvents.ForumTopicCreated]: (data) => + this.forumHandler.forumTopicCreated(data as WSPacket<"ForumTopicCreated">), + [WebSocketEvents.ForumTopicDeleted]: (data) => + this.forumHandler.forumTopicDeleted(data as WSPacket<"ForumTopicDeleted">), + [WebSocketEvents.ForumTopicUpdated]: (data) => + this.forumHandler.forumTopicUpdated(data as WSPacket<"ForumTopicUpdated">), + [WebSocketEvents.ForumTopicPinned]: (data) => + this.forumHandler.forumTopicPinned(data as WSPacket<"ForumTopicPinned">), + [WebSocketEvents.ForumTopicUnpinned]: (data) => + this.forumHandler.forumTopicUnpinned(data as WSPacket<"ForumTopicUnpinned">), + [WebSocketEvents.ForumTopicLocked]: (data) => + this.forumHandler.forumTopicLocked(data as WSPacket<"ForumTopicLocked">), + [WebSocketEvents.ForumTopicUnlocked]: (data) => + this.forumHandler.forumTopicUnlocked(data as WSPacket<"ForumTopicUnlocked">), + }; - constructor(public readonly client: Client) {} - handleWSMessage(event: keyof WSEvent, data: SkeletonWSPayload): void { - const discardEventOption = this.client.options.gateway?.discardEvent; - if (discardEventOption?.(event, data)) return; + constructor(public readonly client: Client) { } + handleWSMessage(event: keyof WSEvent, data: SkeletonWSPayload): void { + const discardEventOption = this.client.options.gateway?.discardEvent; + if (discardEventOption?.(event, data)) return; - this.eventToHandlerMap[event]?.(data) ?? - this.client.emit("unknownGatewayEvent", data); - } + this.eventToHandlerMap[event]?.(data) ?? + this.client.emit("unknownGatewayEvent", data); + } } diff --git a/packages/guilded.js/lib/gateway/handler/BotEventHandler.ts b/packages/guilded.js/lib/gateway/handler/BotEventHandler.ts index 49964660..142bd4fd 100644 --- a/packages/guilded.js/lib/gateway/handler/BotEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/BotEventHandler.ts @@ -1,33 +1,30 @@ -import type { - WSBotServerMembershipCreated, - WSBotServerMembershipDeleted, -} from "@guildedjs/guilded-api-typings"; +import { WSPacket, WSPayload } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { Server } from "../../structures/Server"; import { GatewayEventHandler } from "./GatewayEventHandler"; export class BotEventHandler extends GatewayEventHandler { - botServerMembershipCreated(data: WSBotServerMembershipCreated): boolean { - const server = - this.client.servers.cache.get(data.d.server.id)?._update(data.d.server) ?? - new Server(this.client, data.d.server); + botServerMembershipCreated(data: WSPacket<"BotServerMembershipCreated">): boolean { + const server = + this.client.servers.cache.get(data.d.server.id)?._update(data.d.server) ?? + new Server(this.client, data.d.server); - return this.client.emit( - constants.clientEvents.BOT_SERVER_CREATED, - server, - data.d.createdBy - ); - } + return this.client.emit( + constants.clientEvents.BOT_SERVER_CREATED, + server, + data.d.createdBy + ); + } - botServerMembershipDeleted(data: WSBotServerMembershipDeleted): boolean { - const server = - this.client.servers.cache.get(data.d.server.id)?._update(data.d.server) ?? - new Server(this.client, data.d.server); + botServerMembershipDeleted(data: WSPacket<"BotServerMembershipDeleted">): boolean { + const server = + this.client.servers.cache.get(data.d.server.id)?._update(data.d.server) ?? + new Server(this.client, data.d.server); - return this.client.emit( - constants.clientEvents.BOT_SERVER_DELETED, - server, - data.d.deletedBy - ); - } + return this.client.emit( + constants.clientEvents.BOT_SERVER_DELETED, + server, + data.d.deletedBy + ); + } } diff --git a/packages/guilded.js/lib/gateway/handler/CalendarEventHandler.ts b/packages/guilded.js/lib/gateway/handler/CalendarEventHandler.ts index 213bc49b..fee6e0db 100644 --- a/packages/guilded.js/lib/gateway/handler/CalendarEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/CalendarEventHandler.ts @@ -1,149 +1,142 @@ -import type { - WSCalendarEventCreated, - WSCalendarEventDeleted, - WSCalendarEventUpdated, - WSCalendarEventRsvpUpdated, - WSCalendarEventRsvpManyUpdated, - WSCalendarEventRsvpDeleted, -} from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { - CalendarEvent, - CalendarEventRsvp, + CalendarEvent, + CalendarEventRsvp, } from "../../structures/CalendarEvent"; import { GatewayEventHandler } from "./GatewayEventHandler"; import { Collection } from "@discordjs/collection"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; export class CalendarEventHandler extends GatewayEventHandler { - calendarEventCreated(data: WSCalendarEventCreated): boolean { - const existingCalendar = this.client.calendars.cache.get( - data.d.calendarEvent.id - ); - if (existingCalendar) - return this.client.emit( - constants.clientEvents.CALENDAR_EVENT_CREATED, - existingCalendar - ); + calendarEventCreated(data: WSPacket<"CalendarEventCreated">): boolean { + const existingCalendar = this.client.calendars.cache.get( + data.d.calendarEvent.id + ); + if (existingCalendar) + return this.client.emit( + constants.clientEvents.CALENDAR_EVENT_CREATED, + existingCalendar + ); - const newCalendarEvent = new CalendarEvent( - this.client, - data.d.calendarEvent - ); - if (this.client.calendars.shouldCacheCalendar) - this.client.calendars.cache.set(newCalendarEvent.id, newCalendarEvent); - return this.client.emit( - constants.clientEvents.CALENDAR_EVENT_CREATED, - newCalendarEvent - ); - } + const newCalendarEvent = new CalendarEvent( + this.client, + data.d.calendarEvent + ); + if (this.client.calendars.shouldCacheCalendar) + this.client.calendars.cache.set(newCalendarEvent.id, newCalendarEvent); + return this.client.emit( + constants.clientEvents.CALENDAR_EVENT_CREATED, + newCalendarEvent + ); + } - calendarEventUpdated(data: WSCalendarEventUpdated): boolean { - const existingCalendar = this.client.calendars.cache.get( - data.d.calendarEvent.id - ); - const oldCalendar = existingCalendar?._clone(); - const updatedCalendar = - existingCalendar?._update(data.d.calendarEvent) ?? - new CalendarEvent(this.client, data.d.calendarEvent); - if (this.client.calendars.shouldCacheCalendar && !existingCalendar) - this.client.calendars.cache.set(updatedCalendar.id, updatedCalendar); - return this.client.emit( - constants.clientEvents.CALENDAR_EVENT_UPDATED, - updatedCalendar, - oldCalendar ?? null - ); - } + calendarEventUpdated(data: WSPacket<"CalendarEventUpdated">): boolean { + const existingCalendar = this.client.calendars.cache.get( + data.d.calendarEvent.id + ); + const oldCalendar = existingCalendar?._clone(); + const updatedCalendar = + existingCalendar?._update(data.d.calendarEvent) ?? + new CalendarEvent(this.client, data.d.calendarEvent); + if (this.client.calendars.shouldCacheCalendar && !existingCalendar) + this.client.calendars.cache.set(updatedCalendar.id, updatedCalendar); + return this.client.emit( + constants.clientEvents.CALENDAR_EVENT_UPDATED, + updatedCalendar, + oldCalendar ?? null + ); + } - calendarEventDeleted(data: WSCalendarEventDeleted): boolean { - const existingCalendar = this.client.calendars.cache.get( - data.d.calendarEvent.id - ); - const deletedCalendar = - existingCalendar?._update(data.d.calendarEvent) ?? - new CalendarEvent(this.client, data.d.calendarEvent); - if (this.client.options.cache?.removeCalendarsOnDelete) - this.client.calendars.cache.delete(deletedCalendar.id); - return this.client.emit( - constants.clientEvents.CALENDAR_EVENT_DELETED, - deletedCalendar - ); - } + calendarEventDeleted(data: WSPacket<"CalendarEventDeleted">): boolean { + const existingCalendar = this.client.calendars.cache.get( + data.d.calendarEvent.id + ); + const deletedCalendar = + existingCalendar?._update(data.d.calendarEvent) ?? + new CalendarEvent(this.client, data.d.calendarEvent); + if (this.client.options.cache?.removeCalendarsOnDelete) + this.client.calendars.cache.delete(deletedCalendar.id); + return this.client.emit( + constants.clientEvents.CALENDAR_EVENT_DELETED, + deletedCalendar + ); + } } export class CalendarEventRsvpHandler extends GatewayEventHandler { - calendarEventRsvpUpdated(data: WSCalendarEventRsvpUpdated): boolean { - const existingCalendar = this.client.calendars.cache.get( - data.d.calendarEventRsvp.calendarEventId - ); - const existingCalendarRsvp = existingCalendar?.rsvps?.get( - data.d.calendarEventRsvp.userId - ); + calendarEventRsvpUpdated(data: WSPacket<"CalendarEventRsvpUpdated">): boolean { + const existingCalendar = this.client.calendars.cache.get( + data.d.calendarEventRsvp.calendarEventId + ); + const existingCalendarRsvp = existingCalendar?.rsvps?.get( + data.d.calendarEventRsvp.userId + ); - const oldCalendarRsvp = existingCalendarRsvp?._clone(); - const updatedCalendarRsvp = - existingCalendarRsvp?._update(data.d.calendarEventRsvp) ?? - new CalendarEventRsvp(this.client, data.d.calendarEventRsvp); + const oldCalendarRsvp = existingCalendarRsvp?._clone(); + const updatedCalendarRsvp = + existingCalendarRsvp?._update(data.d.calendarEventRsvp) ?? + new CalendarEventRsvp(this.client, data.d.calendarEventRsvp); - if ( - this.client.calendars.shouldCacheCalendar && - this.client.calendars.shouldCacheCalendarRsvps && - !existingCalendarRsvp - ) - existingCalendar?.rsvps?.set( - updatedCalendarRsvp.userId, - updatedCalendarRsvp - ); - return this.client.emit( - constants.clientEvents.CALENDAR_EVENT_RSVP_UPDATED, - updatedCalendarRsvp, - oldCalendarRsvp ?? null - ); - } + if ( + this.client.calendars.shouldCacheCalendar && + this.client.calendars.shouldCacheCalendarRsvps && + !existingCalendarRsvp + ) + existingCalendar?.rsvps?.set( + updatedCalendarRsvp.userId, + updatedCalendarRsvp + ); + return this.client.emit( + constants.clientEvents.CALENDAR_EVENT_RSVP_UPDATED, + updatedCalendarRsvp, + oldCalendarRsvp ?? null + ); + } - calendarEventRsvpManyUpdated(data: WSCalendarEventRsvpManyUpdated): boolean { - const rsvpCollection = new Collection(); - for (const rsvp of data.d.calendarEventRsvps) { - const existingCalendar = this.client.calendars.cache.get( - rsvp.calendarEventId - ); - const existingCalendarRsvp = existingCalendar?.rsvps?.get(rsvp.userId); - const newCalendarRsvp = - existingCalendarRsvp?._update(rsvp) ?? - new CalendarEventRsvp(this.client, rsvp); - rsvpCollection.set(rsvp.userId, newCalendarRsvp); - if ( - this.client.calendars.shouldCacheCalendar && - this.client.calendars.shouldCacheCalendarRsvps && - !existingCalendarRsvp - ) { - existingCalendar?.rsvps?.set(rsvp.userId, newCalendarRsvp); - } - } - return this.client.emit( - constants.clientEvents.CALENDAR_EVENT_RSVP_MANY_UPDATED, - rsvpCollection - ); - } + calendarEventRsvpManyUpdated(data: WSPacket<"CalendarEventRsvpManyUpdated">): boolean { + const rsvpCollection = new Collection(); + for (const rsvp of data.d.calendarEventRsvps) { + const existingCalendar = this.client.calendars.cache.get( + rsvp.calendarEventId + ); + const existingCalendarRsvp = existingCalendar?.rsvps?.get(rsvp.userId); + const newCalendarRsvp = + existingCalendarRsvp?._update(rsvp) ?? + new CalendarEventRsvp(this.client, rsvp); + rsvpCollection.set(rsvp.userId, newCalendarRsvp); + if ( + this.client.calendars.shouldCacheCalendar && + this.client.calendars.shouldCacheCalendarRsvps && + !existingCalendarRsvp + ) { + existingCalendar?.rsvps?.set(rsvp.userId, newCalendarRsvp); + } + } + return this.client.emit( + constants.clientEvents.CALENDAR_EVENT_RSVP_MANY_UPDATED, + rsvpCollection + ); + } - calendarEventRsvpDeleted(data: WSCalendarEventRsvpDeleted): boolean { - const existingCalendar = this.client.calendars.cache.get( - data.d.calendarEventRsvp.calendarEventId - ); - const existingCalendarRsvp = existingCalendar?.rsvps?.get( - data.d.calendarEventRsvp.userId - ); - const deletedCalendarRsvp = - existingCalendarRsvp?._update(data.d.calendarEventRsvp) ?? - new CalendarEventRsvp(this.client, data.d.calendarEventRsvp); - if (this.client.options.cache?.removeCalendarRsvpOnDelete) { - const currentCalendar = this.client.calendars.cache.get( - data.d.calendarEventRsvp.calendarEventId - ); - currentCalendar?.rsvps?.delete(data.d.calendarEventRsvp.userId); - } - return this.client.emit( - constants.clientEvents.CALENDAR_EVENT_RSVP_DELETED, - deletedCalendarRsvp - ); - } + calendarEventRsvpDeleted(data: WSPacket<"CalendarEventRsvpDeleted">): boolean { + const existingCalendar = this.client.calendars.cache.get( + data.d.calendarEventRsvp.calendarEventId + ); + const existingCalendarRsvp = existingCalendar?.rsvps?.get( + data.d.calendarEventRsvp.userId + ); + const deletedCalendarRsvp = + existingCalendarRsvp?._update(data.d.calendarEventRsvp) ?? + new CalendarEventRsvp(this.client, data.d.calendarEventRsvp); + if (this.client.options.cache?.removeCalendarRsvpOnDelete) { + const currentCalendar = this.client.calendars.cache.get( + data.d.calendarEventRsvp.calendarEventId + ); + currentCalendar?.rsvps?.delete(data.d.calendarEventRsvp.userId); + } + return this.client.emit( + constants.clientEvents.CALENDAR_EVENT_RSVP_DELETED, + deletedCalendarRsvp + ); + } } diff --git a/packages/guilded.js/lib/gateway/handler/DocEventHandler.ts b/packages/guilded.js/lib/gateway/handler/DocEventHandler.ts index f7162332..8c696686 100644 --- a/packages/guilded.js/lib/gateway/handler/DocEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/DocEventHandler.ts @@ -1,23 +1,23 @@ -import type { WSDocCreated, WSDocUpdated, WSDocDeleted } from "@guildedjs/guilded-api-typings"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import type { DocChannel } from "../../structures"; import { GatewayEventHandler } from "./GatewayEventHandler"; export class DocEventHandler extends GatewayEventHandler { - docCreated(data: WSDocCreated) { - const existingChannel = this.client.channels.cache.get(data.d.doc.channelId) as DocChannel | undefined; - if (existingChannel) existingChannel.docs.set(data.d.doc.id, data.d.doc); - return this.client.emit(constants.clientEvents.DOC_CREATED, data.d.doc); - } - docUpdated(data: WSDocUpdated) { - const existingChannel = this.client.channels.cache.get(data.d.doc.channelId) as DocChannel | undefined; - const existingDoc = existingChannel?.docs.get(data.d.doc.id); - if (existingChannel) existingChannel.docs.set(data.d.doc.id, data.d.doc); - return this.client.emit(constants.clientEvents.DOC_UPDATED, data.d.doc, existingDoc ?? null); - } - docDeleted(data: WSDocDeleted) { - const existingChannel = this.client.channels.cache.get(data.d.doc.channelId) as DocChannel | undefined; - if (existingChannel) existingChannel.docs.set(data.d.doc.id, data.d.doc); - return this.client.emit(constants.clientEvents.DOC_DELETED, data.d.doc); - } + docCreated(data: WSPacket<"DocCreated">) { + const existingChannel = this.client.channels.cache.get(data.d.doc.channelId) as DocChannel | undefined; + if (existingChannel) existingChannel.docs.set(data.d.doc.id, data.d.doc); + return this.client.emit(constants.clientEvents.DOC_CREATED, data.d.doc); + } + docUpdated(data: WSPacket<"DocUpdated">) { + const existingChannel = this.client.channels.cache.get(data.d.doc.channelId) as DocChannel | undefined; + const existingDoc = existingChannel?.docs.get(data.d.doc.id); + if (existingChannel) existingChannel.docs.set(data.d.doc.id, data.d.doc); + return this.client.emit(constants.clientEvents.DOC_UPDATED, data.d.doc, existingDoc ?? null); + } + docDeleted(data: WSPacket<"DocDeleted">) { + const existingChannel = this.client.channels.cache.get(data.d.doc.channelId) as DocChannel | undefined; + if (existingChannel) existingChannel.docs.set(data.d.doc.id, data.d.doc); + return this.client.emit(constants.clientEvents.DOC_DELETED, data.d.doc); + } } diff --git a/packages/guilded.js/lib/gateway/handler/ForumEventHandler.ts b/packages/guilded.js/lib/gateway/handler/ForumEventHandler.ts index 77fa56e1..90363f67 100644 --- a/packages/guilded.js/lib/gateway/handler/ForumEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/ForumEventHandler.ts @@ -1,90 +1,82 @@ -import type { - WSForumTopicCreated, - WSForumTopicUpdated, - WSForumTopicDeleted, - WSForumTopicPinned, - WSForumTopicUnpinned, - WSForumTopicLocked, - WSForumTopicUnlocked, -} from "@guildedjs/guilded-api-typings"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { ForumTopic } from "../../structures/Forum"; import { GatewayEventHandler } from "./GatewayEventHandler"; export class ForumEventHandler extends GatewayEventHandler { - forumTopicCreated(data: WSForumTopicCreated) { - // This is in the case that a REST request beats us to adding the topic in the cache. - const existingTopic = this.client.topics.cache.get(data.d.forumTopic.id); - if (existingTopic) - return this.client.emit( - constants.clientEvents.FORUM_TOPIC_CREATED, - existingTopic - ); + forumTopicCreated(data: WSPacket<"ForumTopicCreated">) { + // This is in the case that a REST request beats us to adding the topic in the cache. + const existingTopic = this.client.topics.cache.get(data.d.forumTopic.id); + if (existingTopic) + return this.client.emit( + constants.clientEvents.FORUM_TOPIC_CREATED, + existingTopic + ); - const newTopic = new ForumTopic(this.client, data.d.forumTopic); - if (this.client.topics.shouldCacheForumTopic) - this.client.topics.cache.set(newTopic.id, newTopic); - return this.client.emit( - constants.clientEvents.FORUM_TOPIC_CREATED, - newTopic - ); - } - forumTopicUpdated(data: WSForumTopicUpdated) { - const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); - if (!getCachedTopic) { - const newTopic = new ForumTopic(this.client, data.d.forumTopic); - return this.client.emit( - constants.clientEvents.FORUM_TOPIC_UPDATED, - newTopic, - null - ); - } - const frozenOldTopic = Object.freeze(getCachedTopic._clone()); - getCachedTopic._update(data.d.forumTopic); - return this.client.emit( - constants.clientEvents.FORUM_TOPIC_UPDATED, - getCachedTopic, - frozenOldTopic - ); - } - forumTopicDeleted(data: WSForumTopicDeleted) { - const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); - getCachedTopic?._update({ _deletedAt: new Date() }); - return this.client.emit( - constants.clientEvents.FORUM_TOPIC_DELETED, - getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) - ); - } - forumTopicPinned(data: WSForumTopicPinned) { - const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); - getCachedTopic?._update({ isPinned: true }); - return this.client.emit( - constants.clientEvents.FORUM_TOPIC_PINNED, - getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) - ); - } - forumTopicUnpinned(data: WSForumTopicUnpinned) { - const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); - getCachedTopic?._update({ isPinned: false }); - return this.client.emit( - constants.clientEvents.FORUM_TOPIC_UNPINNED, - getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) - ); - } - forumTopicLocked(data: WSForumTopicLocked) { - const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); - getCachedTopic?._update({ isLocked: true }); - return this.client.emit( - constants.clientEvents.FORUM_TOPIC_LOCKED, - getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) - ); - } - forumTopicUnlocked(data: WSForumTopicUnlocked) { - const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); - getCachedTopic?._update({ isLocked: false }); - return this.client.emit( - constants.clientEvents.FORUM_TOPIC_UNLOCKED, - getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) - ); - } + const newTopic = new ForumTopic(this.client, data.d.forumTopic); + if (this.client.topics.shouldCacheForumTopic) + this.client.topics.cache.set(newTopic.id, newTopic); + return this.client.emit( + constants.clientEvents.FORUM_TOPIC_CREATED, + newTopic + ); + } + forumTopicUpdated(data: WSPacket<"ForumTopicUpdated">) { + const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); + if (!getCachedTopic) { + const newTopic = new ForumTopic(this.client, data.d.forumTopic); + return this.client.emit( + constants.clientEvents.FORUM_TOPIC_UPDATED, + newTopic, + null + ); + } + const frozenOldTopic = Object.freeze(getCachedTopic._clone()); + getCachedTopic._update(data.d.forumTopic); + return this.client.emit( + constants.clientEvents.FORUM_TOPIC_UPDATED, + getCachedTopic, + frozenOldTopic + ); + } + forumTopicDeleted(data: WSPacket<"ForumTopicDeleted">) { + const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); + getCachedTopic?._update({ _deletedAt: new Date() }); + return this.client.emit( + constants.clientEvents.FORUM_TOPIC_DELETED, + getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) + ); + } + forumTopicPinned(data: WSPacket<"ForumTopicPinned">) { + const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); + getCachedTopic?._update({ isPinned: true }); + return this.client.emit( + constants.clientEvents.FORUM_TOPIC_PINNED, + getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) + ); + } + forumTopicUnpinned(data: WSPacket<"ForumTopicUnpinned">) { + const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); + getCachedTopic?._update({ isPinned: false }); + return this.client.emit( + constants.clientEvents.FORUM_TOPIC_UNPINNED, + getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) + ); + } + forumTopicLocked(data: WSPacket<"ForumTopicLocked">) { + const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); + getCachedTopic?._update({ isLocked: true }); + return this.client.emit( + constants.clientEvents.FORUM_TOPIC_LOCKED, + getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) + ); + } + forumTopicUnlocked(data: WSPacket<"ForumTopicUnlocked">) { + const getCachedTopic = this.client.topics.cache.get(data.d.forumTopic.id); + getCachedTopic?._update({ isLocked: false }); + return this.client.emit( + constants.clientEvents.FORUM_TOPIC_UNLOCKED, + getCachedTopic ?? new ForumTopic(this.client, data.d.forumTopic) + ); + } } diff --git a/packages/guilded.js/lib/gateway/handler/ListEventHandler.ts b/packages/guilded.js/lib/gateway/handler/ListEventHandler.ts index e0863a57..50edd821 100644 --- a/packages/guilded.js/lib/gateway/handler/ListEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/ListEventHandler.ts @@ -1,39 +1,33 @@ -import type { - WSListItemUncompleted, - WSListItemCompleted, - WSListItemCreated, - WSListItemUpdated, - WSListItemDeleted, -} from "@guildedjs/guilded-api-typings"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import type { ListChannel } from "../../structures"; import { GatewayEventHandler } from "./GatewayEventHandler"; export class ListEventHandler extends GatewayEventHandler { - listItemCompleted(data: WSListItemCompleted) { - const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; - if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); - return this.client.emit(constants.clientEvents.LIST_ITEM_COMPLETED, data.d.listItem); - } - listItemUncompleted(data: WSListItemUncompleted) { - const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; - if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); - return this.client.emit(constants.clientEvents.LIST_ITEM_UNCOMPLETED, data.d.listItem); - } - listItemCreated(data: WSListItemCreated) { - const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; - if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); - return this.client.emit(constants.clientEvents.LIST_ITEM_CREATED, data.d.listItem); - } - listItemUpdated(data: WSListItemUpdated) { - const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; - const existingItem = existingChannel?.items.get(data.d.listItem.id); - if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); - return this.client.emit(constants.clientEvents.LIST_ITEM_UPDATED, data.d.listItem, existingItem ?? null); - } - listItemDeleted(data: WSListItemDeleted) { - const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; - if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); - return this.client.emit(constants.clientEvents.LIST_ITEM_DELETED, data.d.listItem); - } + listItemCompleted(data: WSPacket<"ListItemCompleted">) { + const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; + if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); + return this.client.emit(constants.clientEvents.LIST_ITEM_COMPLETED, data.d.listItem); + } + listItemUncompleted(data: WSPacket<"ListItemUncompleted">) { + const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; + if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); + return this.client.emit(constants.clientEvents.LIST_ITEM_UNCOMPLETED, data.d.listItem); + } + listItemCreated(data: WSPacket<"ListItemCreated">) { + const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; + if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); + return this.client.emit(constants.clientEvents.LIST_ITEM_CREATED, data.d.listItem); + } + listItemUpdated(data: WSPacket<"ListItemUpdated">) { + const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; + const existingItem = existingChannel?.items.get(data.d.listItem.id); + if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); + return this.client.emit(constants.clientEvents.LIST_ITEM_UPDATED, data.d.listItem, existingItem ?? null); + } + listItemDeleted(data: WSPacket<"ListItemDeleted">) { + const existingChannel = this.client.channels.cache.get(data.d.listItem.channelId) as ListChannel | undefined; + if (existingChannel) existingChannel.items.set(data.d.listItem.id, data.d.listItem); + return this.client.emit(constants.clientEvents.LIST_ITEM_DELETED, data.d.listItem); + } } diff --git a/packages/guilded.js/lib/gateway/handler/MessageEventHandler.ts b/packages/guilded.js/lib/gateway/handler/MessageEventHandler.ts index 35f1bb4d..6430a7c6 100644 --- a/packages/guilded.js/lib/gateway/handler/MessageEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/MessageEventHandler.ts @@ -1,60 +1,49 @@ -import type { - WSChatMessageCreatedPayload, - WSChatMessageDeletedPayload, - WSChatMessageUpdatedPayload, -} from "@guildedjs/guilded-api-typings"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { Message } from "../../structures/Message"; import { GatewayEventHandler } from "./GatewayEventHandler"; export class MessageEventHandler extends GatewayEventHandler { - async messageCreated(data: WSChatMessageCreatedPayload): Promise { - // This is in the case that a REST request beats us to adding the message in the cache. - const existingMessage = this.client.messages.cache.get(data.d.message.id); - if (existingMessage) - return this.client.emit( - constants.clientEvents.MESSAGE_CREATED, - existingMessage - ); - if ( - (this.client.options.cache?.fetchMessageAuthorOnCreate ?? true) && - data.d.serverId && - data.d.message.createdBy && - data.d.message.createdBy !== "Ann6LewA" - ) - await this.client.members - .fetch(data.d.serverId, data.d.message.createdBy) - .catch(() => null); + async messageCreated(data: WSPacket<"ChatMessageCreated">): Promise { + // This is in the case that a REST request beats us to adding the message in the cache. + const existingMessage = this.client.messages.cache.get(data.d.message.id); + if (existingMessage) + return this.client.emit( + constants.clientEvents.MESSAGE_CREATED, + existingMessage + ); - const newMessage = new Message(this.client, data.d.message); - if (this.client.messages.shouldCacheMessage) - this.client.messages.cache.set(newMessage.id, newMessage); - return this.client.emit(constants.clientEvents.MESSAGE_CREATED, newMessage); - } - messageUpdated(data: WSChatMessageUpdatedPayload): boolean { - const getCachedMessage = this.client.messages.cache.get(data.d.message.id); - if (!getCachedMessage) { - const newMessage = new Message(this.client, data.d.message); - return this.client.emit( - constants.clientEvents.MESSAGE_UPDATED, - newMessage, - null - ); - } - const frozenOldMessage = Object.freeze(getCachedMessage._clone()); - getCachedMessage._update(data.d.message); - return this.client.emit( - constants.clientEvents.MESSAGE_UPDATED, - getCachedMessage, - frozenOldMessage - ); - } - messageDeleted(data: WSChatMessageDeletedPayload): boolean { - this.client.messages.cache - .get(data.d.message.id) - ?._update({ deletedAt: data.d.message.deletedAt }); - return this.client.emit(constants.clientEvents.MESSAGE_DELETED, { - ...data.d.message, - }); - } + const newMessage = new Message(this.client, data.d.message); + if (this.client.messages.shouldCacheMessage) + this.client.messages.cache.set(newMessage.id, newMessage); + return this.client.emit(constants.clientEvents.MESSAGE_CREATED, newMessage); + } + messageUpdated(data: WSPacket<"ChatMessageUpdated">): boolean { + const getCachedMessage = this.client.messages.cache.get(data.d.message.id); + if (!getCachedMessage) { + const newMessage = new Message(this.client, data.d.message); + return this.client.emit( + constants.clientEvents.MESSAGE_UPDATED, + newMessage, + null + ); + } + const frozenOldMessage = Object.freeze(getCachedMessage._clone()); + getCachedMessage._update(data.d.message); + return this.client.emit( + constants.clientEvents.MESSAGE_UPDATED, + getCachedMessage, + frozenOldMessage + ); + } + messageDeleted(data: WSPacket<"ChatMessageDeleted">): boolean { + this.client.messages.cache + .get(data.d.message.id) + ?._update({ deletedAt: data.d.message.deletedAt }); + + return this.client.emit(constants.clientEvents.MESSAGE_DELETED, { + ...data.d.message, + serverId: data.d.serverId + }); + } } diff --git a/packages/guilded.js/lib/gateway/handler/ReactionEventHandler.ts b/packages/guilded.js/lib/gateway/handler/ReactionEventHandler.ts index 8a9b6c34..1e3dd766 100644 --- a/packages/guilded.js/lib/gateway/handler/ReactionEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/ReactionEventHandler.ts @@ -1,56 +1,53 @@ -import type { - WSChannelMessageReactionCreatedPayload, - WSChannelMessageReactionDeletedPayload, -} from "@guildedjs/guilded-api-typings"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { MessageReaction } from "../../structures"; import { buildMessageReactionKey } from "../../util"; import { GatewayEventHandler } from "./GatewayEventHandler"; export class ReactionEventHandler extends GatewayEventHandler { - messageReactionCreated( - data: WSChannelMessageReactionCreatedPayload - ): boolean { - const { - d: { reaction, serverId }, - } = data; + messageReactionCreated( + data: WSPacket<"ChannelMessageReactionCreated"> + ): boolean { + const { + d: { reaction, serverId }, + } = data; - const newReaction = new MessageReaction(this.client, { - ...reaction, - serverId, - }); - if (this.client.reactions.shouldCacheReaction) - this.client.reactions.cache.set( - buildMessageReactionKey( - reaction.messageId, - reaction.createdBy, - reaction.emote.id - ), - newReaction - ); - return this.client.emit( - constants.clientEvents.MESSAGE_REACTION_CREATED, - newReaction - ); - } - messageReactionDeleted( - data: WSChannelMessageReactionDeletedPayload - ): boolean { - const { - d: { reaction, serverId }, - } = data; + const newReaction = new MessageReaction(this.client, { + ...reaction, + serverId, + }); + if (this.client.reactions.shouldCacheReaction) + this.client.reactions.cache.set( + buildMessageReactionKey( + reaction.messageId, + reaction.createdBy, + reaction.emote.id + ), + newReaction + ); + return this.client.emit( + constants.clientEvents.MESSAGE_REACTION_CREATED, + newReaction + ); + } + messageReactionDeleted( + data: WSPacket<"ChannelMessageReactionDeleted"> + ): boolean { + const { + d: { reaction, serverId }, + } = data; - if (this.client.reactions.shouldCacheReaction) - this.client.reactions.cache.delete( - buildMessageReactionKey( - reaction.messageId, - reaction.createdBy, - reaction.emote.id - ) - ); - return this.client.emit(constants.clientEvents.MESSAGE_REACTION_DELETED, { - ...reaction, - serverId, - }); - } + if (this.client.reactions.shouldCacheReaction) + this.client.reactions.cache.delete( + buildMessageReactionKey( + reaction.messageId, + reaction.createdBy, + reaction.emote.id + ) + ); + return this.client.emit(constants.clientEvents.MESSAGE_REACTION_DELETED, { + ...reaction, + serverId, + }); + } } diff --git a/packages/guilded.js/lib/gateway/handler/ServerChannelEventHandler.ts b/packages/guilded.js/lib/gateway/handler/ServerChannelEventHandler.ts index 3a733d41..1464ce9d 100644 --- a/packages/guilded.js/lib/gateway/handler/ServerChannelEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/ServerChannelEventHandler.ts @@ -1,57 +1,53 @@ -import type { - WSServerChannelCreated, - WSServerChannelDeleted, - WSServerChannelUpdated, -} from "@guildedjs/guilded-api-typings"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { transformTypeToChannel } from "../../managers/global/ChannelManager"; import { GatewayEventHandler } from "./GatewayEventHandler"; export class ServerChannelEventHandler extends GatewayEventHandler { - serverChannelCreated(data: WSServerChannelCreated): boolean { - const existingChannel = this.client.channels.cache.get(data.d.channel.id); - if (existingChannel) - return this.client.emit( - constants.clientEvents.CHANNEL_CREATED, - existingChannel - ); + serverChannelCreated(data: WSPacket<"ServerChannelCreated">): boolean { + const existingChannel = this.client.channels.cache.get(data.d.channel.id); + if (existingChannel) + return this.client.emit( + constants.clientEvents.CHANNEL_CREATED, + existingChannel + ); - const newChannel = new (transformTypeToChannel(data.d.channel.type))( - this.client, - data.d.channel - ); - if (this.client.channels.shouldCacheChannel) - this.client.channels.cache.set(newChannel.id, newChannel); - return this.client.emit(constants.clientEvents.CHANNEL_CREATED, newChannel); - } - serverChannelUpdated(data: WSServerChannelUpdated): boolean { - const existingChannel = this.client.channels.cache.get(data.d.channel.id); - const oldChannel = existingChannel?._clone(); - const updatedChannel = - existingChannel?._update(data.d.channel) ?? - new (transformTypeToChannel(data.d.channel.type))( - this.client, - data.d.channel - ); - return this.client.emit( - constants.clientEvents.CHANNEL_UPDATED, - updatedChannel, - oldChannel ?? null - ); - } - serverChannelDeleted(data: WSServerChannelDeleted): boolean { - const existingChannel = this.client.channels.cache.get(data.d.channel.id); - const deletedChannel = - existingChannel?._update({ ...data.d.channel, deleted: true }) ?? - new (transformTypeToChannel(data.d.channel.type))( - this.client, - data.d.channel - ); - if (this.client.options.cache?.removeChannelOnDelete) - this.client.channels.cache.delete(deletedChannel.id); - return this.client.emit( - constants.clientEvents.CHANNEL_DELETED, - deletedChannel - ); - } + const newChannel = new (transformTypeToChannel(data.d.channel.type))( + this.client, + data.d.channel + ); + if (this.client.channels.shouldCacheChannel) + this.client.channels.cache.set(newChannel.id, newChannel); + return this.client.emit(constants.clientEvents.CHANNEL_CREATED, newChannel); + } + serverChannelUpdated(data: WSPacket<"ServerChannelUpdated">): boolean { + const existingChannel = this.client.channels.cache.get(data.d.channel.id); + const oldChannel = existingChannel?._clone(); + const updatedChannel = + existingChannel?._update(data.d.channel) ?? + new (transformTypeToChannel(data.d.channel.type))( + this.client, + data.d.channel + ); + return this.client.emit( + constants.clientEvents.CHANNEL_UPDATED, + updatedChannel, + oldChannel ?? null + ); + } + serverChannelDeleted(data: WSPacket<"ServerChannelDeleted">): boolean { + const existingChannel = this.client.channels.cache.get(data.d.channel.id); + const deletedChannel = + existingChannel?._update({ ...data.d.channel, deleted: true }) ?? + new (transformTypeToChannel(data.d.channel.type))( + this.client, + data.d.channel + ); + if (this.client.options.cache?.removeChannelOnDelete) + this.client.channels.cache.delete(deletedChannel.id); + return this.client.emit( + constants.clientEvents.CHANNEL_DELETED, + deletedChannel + ); + } } diff --git a/packages/guilded.js/lib/gateway/handler/ServerEventHandler.ts b/packages/guilded.js/lib/gateway/handler/ServerEventHandler.ts index 9770436e..432bbdbd 100644 --- a/packages/guilded.js/lib/gateway/handler/ServerEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/ServerEventHandler.ts @@ -1,26 +1,26 @@ -import type { WSServerRolesUpdatedPayload } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { GatewayEventHandler } from "./GatewayEventHandler"; import { buildMemberKey } from "../../util"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; export class ServerEventHandler extends GatewayEventHandler { - serverRolesUpdated(data: WSServerRolesUpdatedPayload): boolean { - const oldMembers = []; - // update members cache - for (const m of data.d.memberRoleIds) { - const member = this.client.members.cache.get( - buildMemberKey(data.d.serverId, m.userId) - ); - if (member) { - oldMembers.push(member._clone()); - member._update({ roleIds: m.roleIds }); - } - } + serverRolesUpdated(data: WSPacket<"ServerRolesUpdated">): boolean { + const oldMembers = []; + // update members cache + for (const m of data.d.memberRoleIds) { + const member = this.client.members.cache.get( + buildMemberKey(data.d.serverId, m.userId) + ); + if (member) { + oldMembers.push(member._clone()); + member._update({ roleIds: m.roleIds }); + } + } - return this.client.emit( - constants.clientEvents.ROLES_UPATED, - { serverId: data.d.serverId, members: data.d.memberRoleIds }, - oldMembers - ); - } + return this.client.emit( + constants.clientEvents.ROLES_UPATED, + { serverId: data.d.serverId, members: data.d.memberRoleIds }, + oldMembers + ); + } } diff --git a/packages/guilded.js/lib/gateway/handler/ServerMemberEventHandler.ts b/packages/guilded.js/lib/gateway/handler/ServerMemberEventHandler.ts index aada0648..74ef46ae 100644 --- a/packages/guilded.js/lib/gateway/handler/ServerMemberEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/ServerMemberEventHandler.ts @@ -1,20 +1,11 @@ -import type { - WSServerMemberUpdatedPayload, - WSServerMemberJoinedPayload, - WSServerMemberRemovedPayload, - WSServerMemberBannedPayload, - WSServerMemberUnbannedPayload, - WSServerMemberSocialLinkCreated, - WSServerMemberSocialLinkDeleted, - WSServerMemberSocialLinkUpdated, -} from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { Member, MemberBan, User } from "../../structures"; import { GatewayEventHandler } from "./GatewayEventHandler"; import { buildMemberKey } from "../../util"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; export class ServerMemberEventHandler extends GatewayEventHandler { - serverMemberUpdated(data: WSServerMemberUpdatedPayload): boolean { + serverMemberUpdated(data: WSPacket<"ServerMemberUpdated">): boolean { const { d: { userInfo: { id, nickname }, @@ -25,16 +16,16 @@ export class ServerMemberEventHandler extends GatewayEventHandler { const member = this.client.members.cache.get(buildMemberKey(serverId, id)); const oldMember = member?._clone(); - member?._update({ nickname: data.d.userInfo.nickname }); + member?._update({ nickname: data.d.userInfo.nickname ?? undefined }); return this.client.emit(constants.clientEvents.MEMBER_UPDATED, { serverId, userId: id, - nickname, + nickname: nickname ?? null, oldMember: oldMember ?? null, }); } - serverMemberJoined(data: WSServerMemberJoinedPayload): boolean { + serverMemberJoined(data: WSPacket<"ServerMemberJoined">): boolean { const newMember = new Member(this.client, { ...data.d.member, serverId: data.d.serverId, @@ -53,7 +44,7 @@ export class ServerMemberEventHandler extends GatewayEventHandler { }); return this.client.emit(constants.clientEvents.MEMBER_JOINED, newMember); } - serverMemberRemoved(data: WSServerMemberRemovedPayload): boolean { + serverMemberRemoved(data: WSPacket<"ServerMemberRemoved">): boolean { const memberKey = buildMemberKey(data.d.serverId, data.d.userId); const existingMember = this.client.members.cache.get(memberKey); if (this.client.options.cache?.removeMemberOnLeave) @@ -65,7 +56,7 @@ export class ServerMemberEventHandler extends GatewayEventHandler { }); return this.client.emit(constants.clientEvents.MEMBER_REMOVED, data.d); } - serverMemberBanned(data: WSServerMemberBannedPayload): boolean { + serverMemberBanned(data: WSPacket<"ServerMemberBanned">): boolean { const newMemberBan = new MemberBan(this.client, { serverId: data.d.serverId, ...data.d.serverMemberBan, @@ -77,7 +68,7 @@ export class ServerMemberEventHandler extends GatewayEventHandler { ); return this.client.emit(constants.clientEvents.MEMBER_BANNED, newMemberBan); } - serverMemberUnbanned(data: WSServerMemberUnbannedPayload): boolean { + serverMemberUnbanned(data: WSPacket<"ServerMemberUnbanned">): boolean { const { d: { serverId, @@ -101,7 +92,7 @@ export class ServerMemberEventHandler extends GatewayEventHandler { }); } serverMemberSocialLinkCreated( - data: WSServerMemberSocialLinkCreated + data: WSPacket<"ServerMemberSocialLinkCreated"> ): boolean { const { d: { serverId, socialLink }, @@ -120,7 +111,7 @@ export class ServerMemberEventHandler extends GatewayEventHandler { ); } serverMemberSocialLinkUpdated( - data: WSServerMemberSocialLinkUpdated + data: WSPacket<"ServerMemberSocialLinkUpdated"> ): boolean { const { d: { serverId, socialLink }, @@ -139,7 +130,7 @@ export class ServerMemberEventHandler extends GatewayEventHandler { ); } serverMemberSocialLinkDeleted( - data: WSServerMemberSocialLinkDeleted + data: WSPacket<"ServerMemberSocialLinkDeleted"> ): boolean { const { d: { serverId, socialLink }, diff --git a/packages/guilded.js/lib/gateway/handler/ServerWebhookEventHandler.ts b/packages/guilded.js/lib/gateway/handler/ServerWebhookEventHandler.ts index d55f410c..f7520155 100644 --- a/packages/guilded.js/lib/gateway/handler/ServerWebhookEventHandler.ts +++ b/packages/guilded.js/lib/gateway/handler/ServerWebhookEventHandler.ts @@ -1,41 +1,38 @@ -import type { - WSServerWebhookCreatedPayload, - WSServerWebhookUpdatedPayload, -} from "@guildedjs/guilded-api-typings"; +import { WSPacket } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { Webhook } from "../../structures/Webhook"; import { GatewayEventHandler } from "./GatewayEventHandler"; export class ServerWebhookEventHandler extends GatewayEventHandler { - serverWebhookCreated(data: WSServerWebhookCreatedPayload): boolean { - const existingWebhook = this.client.webhooks.cache.get(data.d.webhook.id); - if (existingWebhook) - return this.client.emit( - constants.clientEvents.WEBHOOK_CREATED, - existingWebhook - ); + serverWebhookCreated(data: WSPacket<"ServerWebhookCreated">): boolean { + const existingWebhook = this.client.webhooks.cache.get(data.d.webhook.id); + if (existingWebhook) + return this.client.emit( + constants.clientEvents.WEBHOOK_CREATED, + existingWebhook + ); - const newWebhook = new Webhook(this.client, data.d.webhook); - this.client.webhooks.cache.set(newWebhook.id, newWebhook); - return this.client.emit(constants.clientEvents.WEBHOOK_CREATED, newWebhook); - } + const newWebhook = new Webhook(this.client, data.d.webhook); + this.client.webhooks.cache.set(newWebhook.id, newWebhook); + return this.client.emit(constants.clientEvents.WEBHOOK_CREATED, newWebhook); + } - serverWebhookUpdated(data: WSServerWebhookUpdatedPayload): boolean { - const getCachedWebhook = this.client.webhooks.cache.get(data.d.webhook.id); - if (!getCachedWebhook) { - const newWebhook = new Webhook(this.client, data.d.webhook); - return this.client.emit( - constants.clientEvents.WEBHOOK_UPDATED, - newWebhook, - null - ); - } - const frozenOldWebhook = Object.freeze(getCachedWebhook._clone()); - getCachedWebhook._update(data.d.webhook); - return this.client.emit( - constants.clientEvents.WEBHOOK_UPDATED, - getCachedWebhook, - frozenOldWebhook - ); - } + serverWebhookUpdated(data: WSPacket<"ServerWebhookUpdated">): boolean { + const getCachedWebhook = this.client.webhooks.cache.get(data.d.webhook.id); + if (!getCachedWebhook) { + const newWebhook = new Webhook(this.client, data.d.webhook); + return this.client.emit( + constants.clientEvents.WEBHOOK_UPDATED, + newWebhook, + null + ); + } + const frozenOldWebhook = Object.freeze(getCachedWebhook._clone()); + getCachedWebhook._update(data.d.webhook); + return this.client.emit( + constants.clientEvents.WEBHOOK_UPDATED, + getCachedWebhook, + frozenOldWebhook + ); + } } diff --git a/packages/guilded.js/lib/managers/global/CalendarManager.ts b/packages/guilded.js/lib/managers/global/CalendarManager.ts index 35503684..1a11d87c 100644 --- a/packages/guilded.js/lib/managers/global/CalendarManager.ts +++ b/packages/guilded.js/lib/managers/global/CalendarManager.ts @@ -1,16 +1,10 @@ import { Collection } from "@discordjs/collection"; -import type { - RESTGetCalendarEventsBody, - RESTPatchCalendarEventBody, - RESTPostCalendarEventBody, - RESTPatchCalendarEventRsvpBody, - RESTPatchCalendarEventRsvpManyBody, -} from "@guildedjs/guilded-api-typings"; import { CacheableStructManager } from "./CacheableStructManager"; import { CalendarEvent, CalendarEventRsvp, } from "../../structures/CalendarEvent"; +import { RestBody, RestPath, RestQuery } from "@guildedjs/guilded-api-typings"; /** * The manager is used to interact with calendars on a server. @@ -35,7 +29,7 @@ export class GlobalCalendarManager extends CacheableStructManager< */ create( channelId: string, - options: RESTPostCalendarEventBody + options: RestBody["post"]> ): Promise { return this.client.rest.router .createCalendarEvent(channelId, options) @@ -78,7 +72,7 @@ export class GlobalCalendarManager extends CacheableStructManager< */ fetchMany( channelId: string, - options: RESTGetCalendarEventsBody + options: RestQuery["get"]> ): Promise> { return this.client.rest.router .getCalendarEvents(channelId, options) @@ -104,7 +98,9 @@ export class GlobalCalendarManager extends CacheableStructManager< update( channelId: string, calendarEventId: number, - options: RESTPatchCalendarEventBody + options: RestBody< + RestPath<"/channels/{channelId}/events/{calendarEventId}">["patch"] + > ): Promise { return this.client.rest.router .updateCalendarEvent(channelId, calendarEventId, options) @@ -216,7 +212,9 @@ export class GlobalCalendarManager extends CacheableStructManager< channelId: string, calendarEventId: number, userId: string, - options: RESTPatchCalendarEventRsvpBody + options: RestBody< + RestPath<"/channels/{channelId}/events/{calendarEventId}/rsvps/{userId}">["put"] + > ): Promise { return this.client.rest.router .updateCalendarEventRvsp(channelId, calendarEventId, userId, options) @@ -245,7 +243,9 @@ export class GlobalCalendarManager extends CacheableStructManager< updateManyRsvp( channelId: string, calendarEventId: number, - options: RESTPatchCalendarEventRsvpManyBody + options: RestBody< + RestPath<"/channels/{channelId}/events/{calendarEventId}/rsvps">["put"] + > ): Promise { return this.client.rest.router .updateCalendarEventRsvpMany(channelId, calendarEventId, options) @@ -265,11 +265,13 @@ export class GlobalCalendarManager extends CacheableStructManager< userId: string ): Promise { return this.client.rest.router - .deleteCalendarEventRvsp(channelId, calendarEventId, userId) - .then((data) => { + .deleteCalendarEventRsvp(channelId, calendarEventId, userId) + .then(() => { if (this.shouldCacheCalendar && this.shouldCacheCalendarRsvps) { const cachedCalendar = this.cache.get(calendarEventId); const rsvp = cachedCalendar?.rsvps?.get(userId); + cachedCalendar?.rsvps?.delete(userId); + return rsvp ?? void 0; } return void 0; diff --git a/packages/guilded.js/lib/managers/global/ChannelManager.ts b/packages/guilded.js/lib/managers/global/ChannelManager.ts index 3537e6fc..c1d08245 100644 --- a/packages/guilded.js/lib/managers/global/ChannelManager.ts +++ b/packages/guilded.js/lib/managers/global/ChannelManager.ts @@ -1,15 +1,11 @@ -import type { - RESTPatchChannelBody, - RESTPostChannelsBody, -} from "@guildedjs/guilded-api-typings"; +import { ChannelType, RestBody, RestPath } from "@guildedjs/guilded-api-typings"; import { - Channel, - DocChannel, - ForumChannel, - ListChannel, + Channel, + DocChannel, + ForumChannel, + ListChannel, } from "../../structures"; import { CacheableStructManager } from "./CacheableStructManager"; -import type { ChannelType as APIChannelType } from "@guildedjs/guilded-api-typings"; /** * Manages channels on the global scope. This can hold channels of any type, with all of them extending Channel. @@ -17,85 +13,85 @@ import type { ChannelType as APIChannelType } from "@guildedjs/guilded-api-typin * @extends CacheableStructManager */ export class GlobalChannelManager extends CacheableStructManager< - string, - Channel + string, + Channel > { - /** Determine whether a channel should be cached or not */ - get shouldCacheChannel() { - return this.client.options?.cache?.cacheChannels !== false; - } + /** Determine whether a channel should be cached or not */ + get shouldCacheChannel() { + return this.client.options?.cache?.cacheChannels !== false; + } - /** - * Create a new channel - * @param options Channel creation options - * @returns Promise that resolves with the newly created channel - */ - create(options: RESTPostChannelsBody): Promise { - return this.client.rest.router.createChannel(options).then((data) => { - const newChannel = new (transformTypeToChannel(data.channel.type))( - this.client, - data.channel - ); - return newChannel; - }); - } + /** + * Create a new channel + * @param options Channel creation options + * @returns Promise that resolves with the newly created channel + */ + create(options: RestBody["post"]>): Promise { + return this.client.rest.router.createChannel(options).then((data) => { + const newChannel = new (transformTypeToChannel(data.channel.type))( + this.client, + data.channel + ); + return newChannel; + }); + } - /** - * Fetch a channel by ID - * Notice: if you're using TypeScript, you will need to upcast to your desired channel type. - * @param channelId ID of the channel to fetch - * @param force Whether to force a fetch from the API - * @returns Promise that resolves with the fetched channel - */ - fetch(channelId: string, force?: boolean): Promise { - if (!force) { - const existingChannel = this.client.channels.cache.get(channelId); - if (existingChannel) return Promise.resolve(existingChannel); - } - return this.client.rest.router.getChannel(channelId).then((data) => { - const fetchedChannel = new (transformTypeToChannel(data.channel.type))( - this.client, - data.channel - ); - if (this.shouldCacheChannel) - this.cache.set(fetchedChannel.id, fetchedChannel); - return fetchedChannel; - }); - } + /** + * Fetch a channel by ID + * Notice: if you're using TypeScript, you will need to upcast to your desired channel type. + * @param channelId ID of the channel to fetch + * @param force Whether to force a fetch from the API + * @returns Promise that resolves with the fetched channel + */ + fetch(channelId: string, force?: boolean): Promise { + if (!force) { + const existingChannel = this.client.channels.cache.get(channelId); + if (existingChannel) return Promise.resolve(existingChannel); + } + return this.client.rest.router.getChannel(channelId).then((data) => { + const fetchedChannel = new (transformTypeToChannel(data.channel.type))( + this.client, + data.channel + ); + if (this.shouldCacheChannel) + this.cache.set(fetchedChannel.id, fetchedChannel); + return fetchedChannel; + }); + } - /** - * Update a channel by ID - * @param channelId ID of the channel to update - * @param options Channel update options - * @returns Promise that resolves with the updated channel - */ - update(channelId: string, options: RESTPatchChannelBody): Promise { - return this.client.rest.router - .updateChannel(channelId, options) - .then((data) => { - const existingChannel = this.cache.get(channelId); - if (existingChannel) return existingChannel._update(data.channel); + /** + * Update a channel by ID + * @param channelId ID of the channel to update + * @param options Channel update options + * @returns Promise that resolves with the updated channel + */ + update(channelId: string, options: RestBody["patch"]>): Promise { + return this.client.rest.router + .updateChannel(channelId, options) + .then((data) => { + const existingChannel = this.cache.get(channelId); + if (existingChannel) return existingChannel._update(data.channel); - const newChannel = new (transformTypeToChannel(data.channel.type))( - this.client, - data.channel - ); - if (this.shouldCacheChannel) this.cache.set(newChannel.id, newChannel); - return newChannel; - }); - } + const newChannel = new (transformTypeToChannel(data.channel.type))( + this.client, + data.channel + ); + if (this.shouldCacheChannel) this.cache.set(newChannel.id, newChannel); + return newChannel; + }); + } - /** - * Delete a channel by ID - * @param channelId ID of the channel to delete - * @returns Promise that resolves with the deleted channel, or void if not cached. - */ - delete(channelId: string): Promise { - return this.client.rest.router.deleteChannel(channelId).then((data) => { - const cachedChannel = this.cache.get(channelId); - return cachedChannel ?? void 0; - }); - } + /** + * Delete a channel by ID + * @param channelId ID of the channel to delete + * @returns Promise that resolves with the deleted channel, or void if not cached. + */ + delete(channelId: string): Promise { + return this.client.rest.router.deleteChannel(channelId).then((data) => { + const cachedChannel = this.cache.get(channelId); + return cachedChannel ?? void 0; + }); + } } /** @@ -103,12 +99,12 @@ export class GlobalChannelManager extends CacheableStructManager< * @param str String representing the channel type * @returns Channel class for the given channel type */ -export const transformTypeToChannel = (str: APIChannelType) => - typeToChannel[str as "forums" | "docs" | "list"] ?? Channel; +export const transformTypeToChannel = (str: ChannelType) => + typeToChannel[str as "forums" | "docs" | "list"] ?? Channel; /** Mapping between the string APIChannelType and the corresponding channel class */ export const typeToChannel = { - forums: ForumChannel, - docs: DocChannel, - list: ListChannel, + forums: ForumChannel, + docs: DocChannel, + list: ListChannel, }; diff --git a/packages/guilded.js/lib/managers/global/DocManager.ts b/packages/guilded.js/lib/managers/global/DocManager.ts index 63a3f0ca..fcae5106 100644 --- a/packages/guilded.js/lib/managers/global/DocManager.ts +++ b/packages/guilded.js/lib/managers/global/DocManager.ts @@ -1,8 +1,4 @@ -import type { - DocPayload, - RESTPostDocsBody, - RESTPutDocBody, -} from "@guildedjs/guilded-api-typings"; +import { RestBody, RestPath, Schema } from "@guildedjs/guilded-api-typings"; import { GlobalManager } from "./GlobalManager"; /** @@ -15,7 +11,10 @@ export class GlobalDocManager extends GlobalManager { * @param options - The options for the Doc to be created. * @returns A Promise that resolves with the Doc payload of the newly created Doc. */ - create(channelId: string, options: RESTPostDocsBody): Promise { + create( + channelId: string, + options: RestBody["post"]> + ): Promise> { return this.client.rest.router .createDoc(channelId, options) .then((data) => data.doc); @@ -26,7 +25,7 @@ export class GlobalDocManager extends GlobalManager { * @param channelId - The ID of the channel where the Docs are located. * @returns A Promise that resolves with an array of Doc payloads. */ - fetchMany(channelId: string): Promise { + fetchMany(channelId: string): Promise[]> { return this.client.rest.router.getDocs(channelId).then((data) => data.docs); } @@ -36,7 +35,7 @@ export class GlobalDocManager extends GlobalManager { * @param docId - The ID of the Doc to fetch. * @returns A Promise that resolves with the Doc payload of the fetched Doc. */ - fetch(channelId: string, docId: number): Promise { + fetch(channelId: string, docId: number): Promise> { return this.client.rest.router .getDoc(channelId, docId) .then((data) => data.doc); @@ -52,8 +51,8 @@ export class GlobalDocManager extends GlobalManager { update( channelId: string, docId: number, - options: RESTPutDocBody - ): Promise { + options: RestBody["put"]> + ): Promise> { return this.client.rest.router .updateDoc(channelId, docId, options) .then((data) => data.doc); diff --git a/packages/guilded.js/lib/managers/global/ForumManager.ts b/packages/guilded.js/lib/managers/global/ForumManager.ts index 57e92482..dc9e6cfe 100644 --- a/packages/guilded.js/lib/managers/global/ForumManager.ts +++ b/packages/guilded.js/lib/managers/global/ForumManager.ts @@ -1,8 +1,4 @@ -import type { - RESTGetForumTopicsQuery, - RESTPatchForumTopicBody, - RESTPostForumTopicBody, -} from "@guildedjs/guilded-api-typings"; +import { RestBody, RestPath, RestQuery } from "@guildedjs/guilded-api-typings"; import { ForumTopic, PartialForumTopic } from "../../structures/Forum"; import { CacheableStructManager } from "./CacheableStructManager"; import { Collection } from "@discordjs/collection"; @@ -27,7 +23,7 @@ export class GlobalForumTopicManager extends CacheableStructManager< */ create( channelId: string, - options: RESTPostForumTopicBody + options: RestBody["post"]> ): Promise { return this.client.rest.router .createForumTopic(channelId, options) @@ -43,7 +39,7 @@ export class GlobalForumTopicManager extends CacheableStructManager< */ fetchMany( channelId: string, - options: RESTGetForumTopicsQuery + options: RestQuery["get"]> ): Promise> { return this.client.rest.router .getForumTopics(channelId, options) @@ -81,7 +77,9 @@ export class GlobalForumTopicManager extends CacheableStructManager< update( channelId: string, forumThreadId: string, - options: RESTPatchForumTopicBody + options: RestBody< + RestPath<"/channels/{channelId}/topics/{forumTopicId}">["patch"] + > ): Promise { return this.client.rest.router .updateForumTopic(channelId, forumThreadId, options) diff --git a/packages/guilded.js/lib/managers/global/ListManager.ts b/packages/guilded.js/lib/managers/global/ListManager.ts index 28f74698..6f3c42cf 100644 --- a/packages/guilded.js/lib/managers/global/ListManager.ts +++ b/packages/guilded.js/lib/managers/global/ListManager.ts @@ -1,9 +1,4 @@ -import type { - ListItemPayload, - ListItemSummaryPayload, - RESTPostListItemBody, - RESTPutListItemBody, -} from "@guildedjs/guilded-api-typings"; +import { RestBody, RestPath, Schema } from "@guildedjs/guilded-api-typings"; import { GlobalManager } from "./GlobalManager"; /** @@ -18,8 +13,8 @@ export class GlobalListItemManager extends GlobalManager { */ create( channelId: string, - options: RESTPostListItemBody - ): Promise { + options: RestBody["post"]> + ): Promise> { return this.client.rest.router .createListItem(channelId, options) .then((data) => data.listItem); @@ -30,7 +25,7 @@ export class GlobalListItemManager extends GlobalManager { * @param channelId The ID of the channel to fetch the list items from. * @returns A Promise that resolves with an array of list item summaries. */ - fetchMany(channelId: string): Promise { + fetchMany(channelId: string): Promise[]> { return this.client.rest.router .getListItems(channelId) .then((data) => data.listItems); @@ -42,7 +37,7 @@ export class GlobalListItemManager extends GlobalManager { * @param itemId The ID of the list item to fetch. * @returns A Promise that resolves with the requested list item. */ - fetch(channelId: string, itemId: string): Promise { + fetch(channelId: string, itemId: string): Promise> { return this.client.rest.router .getListItem(channelId, itemId) .then((data) => data.listItem); @@ -58,8 +53,10 @@ export class GlobalListItemManager extends GlobalManager { update( channelId: string, itemId: string, - options: RESTPutListItemBody - ): Promise { + options: RestBody< + RestPath<"/channels/{channelId}/items/{listItemId}">["put"] + > + ): Promise> { return this.client.rest.router .updateListItem(channelId, itemId, options) .then((data) => data.listItem); diff --git a/packages/guilded.js/lib/managers/global/MemberManager.ts b/packages/guilded.js/lib/managers/global/MemberManager.ts index 0addfdba..310f88f0 100644 --- a/packages/guilded.js/lib/managers/global/MemberManager.ts +++ b/packages/guilded.js/lib/managers/global/MemberManager.ts @@ -2,11 +2,8 @@ import { User } from "../../structures"; import { Member, MemberBan, PartialMember } from "../../structures/Member"; import { CacheableStructManager } from "./CacheableStructManager"; import { Collection } from "@discordjs/collection"; -import type { - SocialLink, - UserSocialLink, -} from "@guildedjs/guilded-api-typings"; import { buildMemberKey } from "../../util"; +import { Schema } from "@guildedjs/guilded-api-typings"; /** * A class representing a manager for Discord server members. @@ -178,8 +175,8 @@ export class GlobalMemberManager extends CacheableStructManager< fetchSocialLinks( serverId: string, memberId: string, - type: UserSocialLink - ): Promise { + type: Schema<"SocialLink">["type"] + ): Promise> { return this.client.rest.router .getMemberSocialLinks(serverId, memberId, type) .then((data) => { diff --git a/packages/guilded.js/lib/managers/global/MessageManager.ts b/packages/guilded.js/lib/managers/global/MessageManager.ts index f10fd7b9..9c72706b 100644 --- a/packages/guilded.js/lib/managers/global/MessageManager.ts +++ b/packages/guilded.js/lib/managers/global/MessageManager.ts @@ -1,8 +1,3 @@ -import type { - RESTPostChannelMessagesBody, - RESTGetChannelMessagesQuery, - EmbedPayload, -} from "@guildedjs/guilded-api-typings"; import { Message } from "../../structures/Message"; import { CacheableStructManager } from "./CacheableStructManager"; import { Collection } from "@discordjs/collection"; @@ -10,6 +5,7 @@ import type { Embed } from "../../structures/Embed"; import { resolveContentToData } from "../../util"; import type { MessageContent } from "../../typings"; import { CollectorOptions, MessageCollector } from "../../structures"; +import { RestBody, RestPath, RestQuery } from "@guildedjs/guilded-api-typings"; /** * Manager for handling caching and interactions for Messages @@ -33,7 +29,7 @@ export class GlobalMessageManager extends CacheableStructManager< */ fetchMany( channelId: string, - options: RESTGetChannelMessagesQuery + options: RestQuery["get"]> ): Promise> { return this.client.rest.router .getChannelMessages(channelId, options) @@ -140,7 +136,7 @@ export class GlobalMessageManager extends CacheableStructManager< update( channelId: string, messageId: string, - content: RESTPostChannelMessagesBody | Embed | string + content: MessageContent ): Promise { return this.client.rest.router .updateChannelMessage(channelId, messageId, resolveContentToData(content)) diff --git a/packages/guilded.js/lib/managers/global/RoleManager.ts b/packages/guilded.js/lib/managers/global/RoleManager.ts index be0888d0..8afe2234 100644 --- a/packages/guilded.js/lib/managers/global/RoleManager.ts +++ b/packages/guilded.js/lib/managers/global/RoleManager.ts @@ -12,9 +12,11 @@ export class GlobalRoleManager extends GlobalManager { * @returns A Promise that resolves with the total XP awarded to the role. */ giveXP(serverId: string, roleId: number, amount: number): Promise { - return this.client.rest.router - .awardRoleXP(serverId, roleId.toString(), amount) - .then((data) => data.total); + return this.client.rest.router.awardRoleXP( + serverId, + roleId.toString(), + amount + ); } /** diff --git a/packages/guilded.js/lib/managers/global/WebhookManager.ts b/packages/guilded.js/lib/managers/global/WebhookManager.ts index 39d3eb7f..30e5a712 100644 --- a/packages/guilded.js/lib/managers/global/WebhookManager.ts +++ b/packages/guilded.js/lib/managers/global/WebhookManager.ts @@ -1,10 +1,7 @@ import { Collection } from "@discordjs/collection"; -import type { - RESTPostServerWebhooksBody, - RESTPutServerWebhookBody, -} from "@guildedjs/guilded-api-typings"; import { Webhook } from "../../structures/Webhook"; import { CacheableStructManager } from "./CacheableStructManager"; +import { RestBody, RestPath } from "@guildedjs/guilded-api-typings"; /** * A manager for interacting with global webhooks. You can retrieve webhooks from the .cache property @@ -26,7 +23,7 @@ export class GlobalWebhookManager extends CacheableStructManager< */ create( serverId: string, - options: RESTPostServerWebhooksBody + options: RestBody["post"]> ): Promise { return this.client.rest.router .createWebhook(serverId, options) @@ -98,7 +95,9 @@ export class GlobalWebhookManager extends CacheableStructManager< update( serverId: string, webhookId: string, - options: RESTPutServerWebhookBody + options: RestBody< + RestPath<"/servers/{serverId}/webhooks/{webhookId}">["put"] + > ): Promise { return this.client.rest.router .updateWebhook(serverId, webhookId, options) diff --git a/packages/guilded.js/lib/structures/CalendarEvent.ts b/packages/guilded.js/lib/structures/CalendarEvent.ts index 459699d5..fb1aba1c 100644 --- a/packages/guilded.js/lib/structures/CalendarEvent.ts +++ b/packages/guilded.js/lib/structures/CalendarEvent.ts @@ -1,9 +1,4 @@ -import type { - CalendarEventCancellationPayload, - CalendarEventPayload, - MentionsPayload, - CalendarEventRsvpPayload, -} from "@guildedjs/guilded-api-typings"; +import type { Schema } from "@guildedjs/guilded-api-typings"; import { Base } from "./Base"; import type { Client } from "./Client"; import type { User } from "./User"; @@ -12,203 +7,200 @@ import { Collection } from "@discordjs/collection"; /** * Represents a calendar event on Guilded */ -export class CalendarEvent extends Base { - /** The ID of the calendar event (min 1) */ - readonly id: number; - /** The ID of the server */ - readonly serverId: string; - /** The ID of the channel */ - readonly channelId: string; - /** The name of the event (min length 1; max length 60) */ - name: string; - /** The description of the event (min length 1; max length 8000) */ - description?: string | null; - /** The location of the event (min length 1; max length 8000) */ - location?: string | null; - /** A URL to associate with the event */ - url?: string | null; - /** The color of the event when viewing in the calendar (min 0; max 16777215) */ - color?: number | null; - /** The ISO 8601 timestamp that the event starts at */ - startsAt: string; - /** The duration of the event in minutes (min 1) */ - duration?: number | null; - /** Whether this event is private or not */ - isPrivate?: boolean; - /** The mentions in this calendar event */ - mentions?: MentionsPayload; - /** The cancellations for this event */ - cancellation?: CalendarEventCancellationPayload; - /** The number of rsvps to allow before waitlisting rsvps (min 1) */ - rsvpLimit?: number | null; - /** A collection of cached rsvps for this calendar event */ - rsvps: Collection; - /** The role IDs to restrict the event to (min items 1; must have unique items true) */ - roleIds?: number[] | null; - /** The ID of the calendar event series. Only shows if the event is repeating */ - seriesId?: string | null; - /** Whether this event is repeating */ - repeats?: boolean | null; - /** Whether this event lasts all day */ - isAllDay?: boolean | null; - /** When rsvpLimit is set, users from the waitlist will be added as space becomes available in the event */ - autofillWaitlist?: boolean | null; - /** The ISO 8601 timestamp that the event was created at */ - readonly _createdAt: number; - /** The ID of the user who created this event */ - readonly createdBy: string; - - constructor(client: Client, data: CalendarEventPayload) { - super(client, data); - - this.id = data.id; - this.serverId = data.serverId; - this.channelId = data.channelId; - this.name = data.name; - this.description = data.description ?? null; - this.location = data.location ?? null; - this.url = data.url ?? null; - this.color = data.color ?? null; - this.startsAt = data.startsAt; - this.duration = data.duration ?? null; - this.isPrivate = data.isPrivate ?? false; - this._createdAt = Date.parse(data.createdAt); - this.createdBy = data.createdBy; - this.rsvpLimit = data.rsvpLimit ?? null; - this.rsvps = new Collection(); - this.roleIds = data.roleIds ?? null; - this.seriesId = data.seriesId ?? null; - this.repeats = data.repeats ?? null; - this.isAllDay = data.isAllDay ?? null; - this.autofillWaitlist = data.autofillWaitlist ?? null; - - this._update(data); - } - - /** - * Get the author of this calendar event - * @returns The author of this calendar event or null if the author is not cached - */ - get author(): User | null { - return this.client.users.cache.get(this.createdBy) ?? null; - } - - /** - * Get the date this calendar event was created - * @returns The date this calendar event was created - */ - get createdAt(): Date { - return new Date(this._createdAt); - } - - _update(data: Partial): this { - if ("name" in data && typeof data.name !== "undefined") { - this.name = data.name; - } - - if ("description" in data && typeof data.description !== "undefined") { - this.description = data.description; - } - - if ("url" in data && typeof data.url !== "undefined") { - this.url = data.url; - } - - if ("color" in data && typeof data.color !== "undefined") { - this.color = data.color; - } - - if ("startsAt" in data && typeof data.startsAt !== "undefined") { - this.startsAt = data.startsAt; - } - - if ("duration" in data && typeof data.duration !== "undefined") { - this.duration = data.duration; - } - - if ("isPrivate" in data && typeof data.isPrivate !== "undefined") { - this.isPrivate = data.isPrivate; - } - - if ("mentions" in data && typeof data.mentions !== "undefined") { - this.mentions = data.mentions; - } - - if ("cancellation" in data && typeof data.cancellation !== "undefined") { - this.cancellation = data.cancellation; - } - - if ("rsvpLimit" in data && typeof data.rsvpLimit !== "undefined") { - this.rsvpLimit = data.rsvpLimit ?? null; - } - - return this; - } +export class CalendarEvent extends Base, number> { + /** The ID of the calendar event (min 1) */ + readonly id: number; + /** The ID of the server */ + readonly serverId: string; + /** The ID of the channel */ + readonly channelId: string; + /** The name of the event (min length 1; max length 60) */ + name: string; + /** The description of the event (min length 1; max length 8000) */ + description?: string | null; + /** The location of the event (min length 1; max length 8000) */ + location?: string | null; + /** A URL to associate with the event */ + url?: string | null; + /** The color of the event when viewing in the calendar (min 0; max 16777215) */ + color?: number | null; + /** The ISO 8601 timestamp that the event starts at */ + startsAt: string; + /** The duration of the event in minutes (min 1) */ + duration?: number | null; + /** Whether this event is private or not */ + isPrivate?: boolean; + /** The mentions in this calendar event */ + mentions?: Schema<"Mentions">; + /** The cancellations for this event */ + cancellation?: Schema<"CalendarEvent">["cancellation"]; + /** The number of rsvps to allow before waitlisting rsvps (min 1) */ + rsvpLimit?: number | null; + /** A collection of cached rsvps for this calendar event */ + rsvps: Collection; + /** The role IDs to restrict the event to (min items 1; must have unique items true) */ + roleIds?: number[] | null; + /** The ID of the calendar event series. Only shows if the event is repeating */ + seriesId?: string | null; + /** Whether this event is repeating */ + repeats?: boolean | null; + /** Whether this event lasts all day */ + isAllDay?: boolean | null; + /** When rsvpLimit is set, users from the waitlist will be added as space becomes available in the event */ + autofillWaitlist?: boolean | null; + /** The ISO 8601 timestamp that the event was created at */ + readonly _createdAt: number; + /** The ID of the user who created this event */ + readonly createdBy: string; + + constructor(client: Client, data: Schema<"CalendarEvent">) { + super(client, data); + + this.id = data.id; + this.serverId = data.serverId; + this.channelId = data.channelId; + this.name = data.name; + this.description = data.description ?? null; + this.location = data.location ?? null; + this.url = data.url ?? null; + this.color = data.color ?? null; + this.startsAt = data.startsAt; + this.duration = data.duration ?? null; + this.isPrivate = data.isPrivate ?? false; + this._createdAt = Date.parse(data.createdAt); + this.createdBy = data.createdBy; + this.rsvpLimit = data.rsvpLimit ?? null; + this.rsvps = new Collection(); + this.roleIds = data.roleIds ?? null; + this.seriesId = data.seriesId ?? null; + this.repeats = data.repeats ?? null; + this.isAllDay = data.isAllDay ?? null; + this.autofillWaitlist = data.autofillWaitlist ?? null; + + this._update(data); + } + + /** + * Get the author of this calendar event + * @returns The author of this calendar event or null if the author is not cached + */ + get author(): User | null { + return this.client.users.cache.get(this.createdBy) ?? null; + } + + /** + * Get the date this calendar event was created + * @returns The date this calendar event was created + */ + get createdAt(): Date { + return new Date(this._createdAt); + } + + _update(data: Partial>): this { + if ("name" in data && typeof data.name !== "undefined") { + this.name = data.name; + } + + if ("description" in data && typeof data.description !== "undefined") { + this.description = data.description; + } + + if ("url" in data && typeof data.url !== "undefined") { + this.url = data.url; + } + + if ("color" in data && typeof data.color !== "undefined") { + this.color = data.color; + } + + if ("startsAt" in data && typeof data.startsAt !== "undefined") { + this.startsAt = data.startsAt; + } + + if ("duration" in data && typeof data.duration !== "undefined") { + this.duration = data.duration; + } + + if ("isPrivate" in data && typeof data.isPrivate !== "undefined") { + this.isPrivate = data.isPrivate; + } + + if ("mentions" in data && typeof data.mentions !== "undefined") { + this.mentions = data.mentions; + } + + if ("cancellation" in data && typeof data.cancellation !== "undefined") { + this.cancellation = data.cancellation; + } + + if ("rsvpLimit" in data && typeof data.rsvpLimit !== "undefined") { + this.rsvpLimit = data.rsvpLimit ?? null; + } + + return this; + } } /** * Represents a calendar event RSVP */ -export class CalendarEventRsvp extends Base { - /** Custom Id generated for the rsvp */ - readonly id: string; - /** The ID of the calendar event (min 1) */ - readonly calendarEventId: number; - /** The ID of the channel */ - readonly channelId: string; - /** The ID of the server */ - readonly serverId: string; - /** The ID of the user */ - readonly userId: string; - /** The status of the rsvp ("going", "maybe", "declined", "invited", "waitlisted", or "not responded") */ - status: string; - /** The ID of the user who created this rsvp */ - readonly createdBy: string; - /** The ISO 8601 timestamp that the rsvp was created at */ - readonly _createdAt: number; - /** The ID of the user who updated this rsvp */ - updatedBy?: string | null; - /** The ISO 8601 timestamp that the rsvp was updated at, if relevant */ - updatedAt?: string | null; - - constructor(client: Client, data: CalendarEventRsvpPayload) { - super(client, data); - - this.id = data.calendarEventId + "-" + data.userId; - this.calendarEventId = data.calendarEventId; - this.channelId = data.channelId; - this.serverId = data.serverId; - this.userId = data.userId; - this.status = data.status; - this.createdBy = data.createdBy; - this._createdAt = Date.parse(data.createdAt); - this.updatedBy = null; - this.updatedAt = null; - - this._update(data); - } - - get author(): User | null { - return this.client.users.cache.get(this.createdBy) ?? null; - } - - get createdAt(): Date { - return new Date(this._createdAt); - } - - _update(data: Partial): this { - if ("updatedAt" in data && typeof data.updatedAt !== "undefined") { - this.updatedAt = data.updatedAt ?? null; - } - - if ("updatedBy" in data && typeof data.updatedBy !== "undefined") { - this.updatedBy = data.updatedBy ?? null; - } - - if ("status" in data && typeof data.status !== "undefined") { - this.status = data.status; - } - - return this; - } +export class CalendarEventRsvp extends Base, string> { + /** The ID of the calendar event (min 1) */ + readonly calendarEventId: number; + /** The ID of the channel */ + readonly channelId: string; + /** The ID of the server */ + readonly serverId: string; + /** The ID of the user */ + readonly userId: string; + /** The status of the rsvp ("going", "maybe", "declined", "invited", "waitlisted", or "not responded") */ + status: string; + /** The ID of the user who created this rsvp */ + readonly createdBy: string; + /** The ISO 8601 timestamp that the rsvp was created at */ + readonly _createdAt: number; + /** The ID of the user who updated this rsvp */ + updatedBy?: string | null; + /** The ISO 8601 timestamp that the rsvp was updated at, if relevant */ + updatedAt?: string | null; + + constructor(client: Client, data: Schema<"CalendarEventRsvp">) { + super(client, { ...data, id: data.calendarEventId + "-" + data.userId }); + + this.calendarEventId = data.calendarEventId; + this.channelId = data.channelId; + this.serverId = data.serverId; + this.userId = data.userId; + this.status = data.status; + this.createdBy = data.createdBy; + this._createdAt = Date.parse(data.createdAt); + this.updatedBy = null; + this.updatedAt = null; + + this._update(data); + } + + get author(): User | null { + return this.client.users.cache.get(this.createdBy) ?? null; + } + + get createdAt(): Date { + return new Date(this._createdAt); + } + + _update(data: Partial>): this { + if ("updatedAt" in data && typeof data.updatedAt !== "undefined") { + this.updatedAt = data.updatedAt ?? null; + } + + if ("updatedBy" in data && typeof data.updatedBy !== "undefined") { + this.updatedBy = data.updatedBy ?? null; + } + + if ("status" in data && typeof data.status !== "undefined") { + this.status = data.status; + } + + return this; + } } diff --git a/packages/guilded.js/lib/structures/Embed.ts b/packages/guilded.js/lib/structures/Embed.ts index f683ece5..8a292410 100644 --- a/packages/guilded.js/lib/structures/Embed.ts +++ b/packages/guilded.js/lib/structures/Embed.ts @@ -1,4 +1,8 @@ -import type { APIEmbed, EmbedPayload } from "@guildedjs/guilded-api-typings"; +import type { + APIEmbed, + EmbedPayload, + Schema, +} from "@guildedjs/guilded-api-typings"; import { resolveColor } from "@guildedjs/rest"; export class Embed { @@ -26,7 +30,7 @@ export class Embed { } | null; private timestampString: string | null; - constructor(data?: Partial) { + constructor(data?: Partial>) { this.footer = null; this.image = null; this.thumbnail = null; @@ -43,7 +47,7 @@ export class Embed { if (data) this._update(data); } - _update(data: Partial): void { + _update(data: Partial>): void { if ("color" in data) this.setColor(data.color); if ("timestamp" in data) this.setTimestamp(data.timestamp); if ("title" in data) this.setTitle(data.title); diff --git a/packages/guilded.js/lib/structures/Forum.ts b/packages/guilded.js/lib/structures/Forum.ts index e975030a..62e899a0 100644 --- a/packages/guilded.js/lib/structures/Forum.ts +++ b/packages/guilded.js/lib/structures/Forum.ts @@ -1,15 +1,11 @@ -import type { - ForumTopicPayload, - ForumTopicSummaryPayload, - MentionsPayload, -} from "@guildedjs/guilded-api-typings"; +import { Schema } from "@guildedjs/guilded-api-typings"; import { Base } from "./Base"; import type { Client } from "./Client"; /** * Represents a forum topic in Guilded. */ -export class ForumTopic extends Base { +export class ForumTopic extends Base, number> { /** * The server ID of the forum topic. */ @@ -30,10 +26,6 @@ export class ForumTopic extends Base { * The user ID of the user who created the forum topic. */ readonly createdBy: string; - /** - * The webhook ID of the webhook that created the forum topic, or null if it was created by a user. - */ - readonly createdByWebhookId: string | null; /** * The date time the forum topic was last updated, or null if it hasn't been updated. */ @@ -61,14 +53,13 @@ export class ForumTopic extends Base { /** * The mentions in the forum topic. */ - mentions!: MentionsPayload; + mentions!: Schema<"Mentions">; - constructor(client: Client, data: ForumTopicPayload) { + constructor(client: Client, data: Schema<"ForumTopic">) { super(client, data); this.serverId = data.serverId; this.channelId = data.channelId; this._createdAt = Date.parse(data.createdAt); - this.createdByWebhookId = data.createdByWebhookId ?? null; this.createdBy = data.createdBy; this.isPinned = false; this.isLocked = false; @@ -101,7 +92,7 @@ export class ForumTopic extends Base { return this._updatedAt ? new Date(this._updatedAt) : null; } - _update(data: Partial) { + _update(data: Partial & { _deletedAt?: Date }>) { if ("updatedAt" in data && typeof data.updatedAt !== "undefined") { this._updatedAt = data.updatedAt ? Date.parse(data.updatedAt) : null; } @@ -140,7 +131,10 @@ export class ForumTopic extends Base { // ""channelId" /** A partial summary representation of a forum topic. Can fetch this topic to get full data */ -export class PartialForumTopic extends Base { +export class PartialForumTopic extends Base< + Schema<"ForumTopicSummary">, + number +> { /** * The ID of the server this role belongs to */ @@ -161,10 +155,6 @@ export class PartialForumTopic extends Base { * Whether the forum topic is pinned. */ isPinned: boolean; - /** - * The webhook ID of the webhook that created the forum topic, or null if it was created by a user. - */ - readonly createdByWebhookId: string | null; /** * The creation date of the forum topic. */ @@ -178,19 +168,18 @@ export class PartialForumTopic extends Base { */ readonly channelId: string; - constructor(client: Client, data: ForumTopicSummaryPayload) { + constructor(client: Client, data: Schema<"ForumTopicSummary">) { super(client, data); this.serverId = data.serverId; this.channelId = data.channelId; this._createdAt = Date.parse(data.createdAt); - this.createdByWebhookId = data.createdByWebhookId ?? null; this.createdBy = data.createdBy; this.isPinned = false; this._update(data); } - _update(data: Partial) { + _update(data: Partial & { _deletedAt?: Date }>) { if ("updatedAt" in data && typeof data.updatedAt !== "undefined") { this._updatedAt = data.updatedAt ? Date.parse(data.updatedAt) : null; } diff --git a/packages/guilded.js/lib/structures/Member.ts b/packages/guilded.js/lib/structures/Member.ts index 0b5f27db..bd32426a 100644 --- a/packages/guilded.js/lib/structures/Member.ts +++ b/packages/guilded.js/lib/structures/Member.ts @@ -5,15 +5,10 @@ import type { UpgradedServerMemberPayload, UpgradedServerMemberSummaryPayload, } from "../typings"; -import type { - ServerMemberPayload, - SocialLink, - UserSocialLink, - UserSummaryPayload, -} from "@guildedjs/guilded-api-typings"; import type { User } from "./User"; import { buildMemberKey } from "../util"; import { Collection } from "@discordjs/collection"; +import { Schema } from "@guildedjs/guilded-api-typings"; export class Member extends Base { /** The ID of the server this role belongs to */ @@ -31,7 +26,7 @@ export class Member extends Base { /** Whether this member owns the server */ isOwner: boolean; /** Cached social links of this member */ - socialLinks: Collection; + socialLinks: Collection["type"], Schema<"SocialLink">>; constructor(client: Client, data: UpgradedServerMemberPayload) { super(client, data); @@ -50,7 +45,7 @@ export class Member extends Base { } _update( - data: Partial + data: Partial & { kicked: boolean; banned: boolean }> ): this { if ("nickname" in data) { this.nickname = data.nickname ?? null; @@ -177,7 +172,7 @@ export class PartialMember extends Base { /** The ID of the server this role belongs to */ readonly serverId: string; /** The user information of this member */ - readonly user: UserSummaryPayload; + readonly user: Schema<"UserSummary">; /** Roles this member has by ID (TODO: role object when Guilded API has one) */ readonly roleIds: number[] = []; @@ -210,7 +205,7 @@ export class MemberBan extends Base { /** The reason this user was banned */ reason: string | null; /** Information about the target user */ - target: UserSummaryPayload; + target: Schema<"UserSummary">; /** * Creates a new instance of `MemberBan`. diff --git a/packages/guilded.js/lib/structures/Message.ts b/packages/guilded.js/lib/structures/Message.ts index 90ee9652..6daba9bc 100644 --- a/packages/guilded.js/lib/structures/Message.ts +++ b/packages/guilded.js/lib/structures/Message.ts @@ -1,10 +1,3 @@ -import type { - ChatMessagePayload, - RESTPostChannelMessagesBody, - MentionsPayload, - WSChannelMessageReactionCreatedPayload, - EmotePayload, -} from "@guildedjs/guilded-api-typings"; import type { Client } from "./Client"; import { Base } from "./Base"; import type { User } from "./User"; @@ -14,13 +7,19 @@ import { Embed } from "./Embed"; import type { Server } from "./Server"; import type { Channel } from "./channels"; import type { MessageContent } from "../typings"; +import { + RestBody, + RestPath, + Schema, + WSPayload, +} from "@guildedjs/guilded-api-typings"; export enum MessageType { Default, System, } -export class Message extends Base { +export class Message extends Base> { /** The ID of the channel */ readonly channelId: string; /** The ID of the server this message belongs to */ @@ -30,7 +29,7 @@ export class Message extends Base { /** The content of the message */ content: string; /** The mentions within this message */ - mentions?: MentionsPayload; + mentions?: Schema<"Mentions">; /** The ID of the messages that this is replying to. */ readonly replyMessageIds: string[] = []; /** If set, this message will only be seen by those mentioned or replied to. */ @@ -41,8 +40,6 @@ export class Message extends Base { readonly createdById: string; /** Bool value to wether message is a reply or not */ readonly isReply: boolean; - /** The ID of the bot who created this message, if it was created by a bot */ - readonly createdByBotId: string | null; /** The ID of the webhook who created this message, if it was created by a webhook */ readonly createdByWebhookId: string | null; /** The timestamp that the message was created at. */ @@ -56,7 +53,7 @@ export class Message extends Base { /** Embeds contained within this message */ embeds: Embed[] = []; - constructor(client: Client, data: ChatMessagePayload) { + constructor(client: Client, data: Schema<"ChatMessage">) { super(client, data); this.isReply = !!data.replyMessageIds; this.channelId = data.channelId; @@ -64,7 +61,6 @@ export class Message extends Base { this.serverId = data.serverId ?? null; this.replyMessageIds = data.replyMessageIds ?? []; this.createdById = data.createdBy; - this.createdByBotId = data.createdByBotId ?? null; this.createdByWebhookId = data.createdByWebhookId ?? null; this._createdAt = Date.parse(data.createdAt); this._updatedAt = null; @@ -77,7 +73,7 @@ export class Message extends Base { } /** Update details of this structure */ - _update(data: Partial | { deletedAt: string }): this { + _update(data: Partial> | { deletedAt: string }): this { if ("content" in data && typeof data.content !== "undefined") { this.content = data.content; } @@ -137,7 +133,7 @@ export class Message extends Base { * Returns the ID of the user who sent this message. */ get authorId(): string { - return this.createdByBotId ?? this.createdByWebhookId ?? this.createdById; + return this.createdByWebhookId ?? this.createdById; } /** @@ -169,9 +165,7 @@ export class Message extends Base { * @param newContent - The new content of the message. * @returns A promise that resolves with the updated message. */ - edit( - newContent: RESTPostChannelMessagesBody | Embed | string - ): Promise { + edit(newContent: MessageContent): Promise { return this.client.messages .update(this.channelId, this.id, newContent) .then(() => this); @@ -276,7 +270,7 @@ export class MessageReaction extends Base { /** * The emote associated with this reaction. */ - readonly emote: EmotePayload; + readonly emote: Schema<"Emote">; /** * The ID of the server where the reaction was made. @@ -302,6 +296,6 @@ export class MessageReaction extends Base { } type FlattenedReactionData = - WSChannelMessageReactionCreatedPayload["d"]["reaction"] & { + WSPayload<"ChannelMessageReactionCreated">["reaction"] & { serverId: string; }; diff --git a/packages/guilded.js/lib/structures/Server.ts b/packages/guilded.js/lib/structures/Server.ts index 4c941541..fefbbc7a 100644 --- a/packages/guilded.js/lib/structures/Server.ts +++ b/packages/guilded.js/lib/structures/Server.ts @@ -1,17 +1,17 @@ import type { Client } from "./Client"; import { Base } from "./Base"; -import type { - ServerPayload, - ServerType as APIServerType, -} from "@guildedjs/guilded-api-typings"; import type { Channel } from "./channels"; import { buildMemberKey } from "../util"; import type { Member } from "./Member"; +import { + Schema, + ServerType as APIServerType, +} from "@guildedjs/guilded-api-typings"; /** * A class representing a Guilded server. */ -export class Server extends Base { +export class Server extends Base> { /** The ID of the owner of this server */ ownerId: string; /** The type of this server */ @@ -35,7 +35,7 @@ export class Server extends Base { /** The date this server was created */ _createdAt!: number; - constructor(client: Client, data: ServerPayload) { + constructor(client: Client, data: Schema<"Server">) { super(client, data); this.ownerId = data.ownerId; this._createdAt = Date.parse(data.createdAt); @@ -67,7 +67,7 @@ export class Server extends Base { : null; } - _update(data: Partial): this { + _update(data: Partial>): this { if ("name" in data && typeof data.name !== "undefined") { this.name = data.name; } diff --git a/packages/guilded.js/lib/structures/User.ts b/packages/guilded.js/lib/structures/User.ts index 182ef433..0bd1f4c2 100644 --- a/packages/guilded.js/lib/structures/User.ts +++ b/packages/guilded.js/lib/structures/User.ts @@ -1,11 +1,8 @@ +import { Schema, WSPayload } from "@guildedjs/guilded-api-typings"; import { Base } from "./Base"; -import type { - UserPayload, - WSWelcomePayload, -} from "@guildedjs/guilded-api-typings"; import type { Client } from "./Client"; -export class User extends Base { +export class User extends Base> { /** The name for this user */ name: string; /** The type of this user */ @@ -17,7 +14,7 @@ export class User extends Base { /** When this user was created */ readonly _createdAt: number | null; - constructor(client: Client, data: UserPayload) { + constructor(client: Client, data: Schema<"User">) { super(client, data); this.name = data.name; this._createdAt = Date.parse(data.createdAt); @@ -30,7 +27,7 @@ export class User extends Base { return this._createdAt ? new Date(this._createdAt) : null; } - _update(data: Partial): this { + _update(data: Partial>): this { if ("avatar" in data) { this.avatar = data.avatar ?? null; } @@ -49,7 +46,13 @@ export class ClientUser extends User { // The bot ID (not to be confused with the user ID) of this bot readonly botId: string; - constructor(client: Client, data: WSWelcomePayload["d"]["user"]) { + constructor( + client: Client, + data: WSPayload<"_WelcomeMessage">["user"] & { + createdBy: string; + botId: string; + } + ) { super(client, { ...data, type: "bot" }); this.createdBy = data.createdBy; this.botId = data.botId; diff --git a/packages/guilded.js/lib/structures/Webhook.ts b/packages/guilded.js/lib/structures/Webhook.ts index 8b680313..824cb017 100644 --- a/packages/guilded.js/lib/structures/Webhook.ts +++ b/packages/guilded.js/lib/structures/Webhook.ts @@ -1,8 +1,8 @@ -import type { RESTPutServerWebhookBody } from "@guildedjs/guilded-api-typings"; import type { WebhookPayload } from "@guildedjs/guilded-api-typings/dist/v1/structs/Webhook"; import { Base } from "./Base"; import type { Client } from "./Client"; import type { User } from "./User"; +import { RestBody, RestPath } from "@guildedjs/guilded-api-typings"; /** * Object representing received webhook data. This object is NOT to be used to send data to webhooks. That would be WebhookClient @@ -80,7 +80,11 @@ export class Webhook extends Base { * @param options The new options for this webhook * @returns A promise that resolves with the updated webhook */ - update(options: RESTPutServerWebhookBody): Promise { + update( + options: RestBody< + RestPath<"/servers/{serverId}/webhooks/{webhookId}">["put"] + > + ): Promise { return this.client.webhooks.update(this.serverId, this.id, options); } diff --git a/packages/guilded.js/lib/structures/channels/Channel.ts b/packages/guilded.js/lib/structures/channels/Channel.ts index 85be673b..3347a968 100644 --- a/packages/guilded.js/lib/structures/channels/Channel.ts +++ b/packages/guilded.js/lib/structures/channels/Channel.ts @@ -1,13 +1,14 @@ import type { Collection } from "@discordjs/collection"; -import type { - RESTGetChannelMessagesQuery, - RESTPatchChannelBody, - ServerChannelPayload, -} from "@guildedjs/guilded-api-typings"; import { Base } from "../Base"; import type { Client } from "../Client"; import type { Message } from "../Message"; -import type { ChannelType as APIChannelType } from "@guildedjs/guilded-api-typings"; +import type { + ChannelType as APIChannelType, + RestBody, + RestPath, + RestQuery, + Schema, +} from "@guildedjs/guilded-api-typings"; import type { MessageContent } from "../../typings"; /** @@ -49,7 +50,7 @@ export class Channel extends Base { /** * The ID of the category that the channel belongs to. */ - categoryId!: string | null; + categoryId!: number | null; /** * The ID of the group that the channel belongs to. */ @@ -69,7 +70,7 @@ export class Channel extends Base { constructor( client: Client, - data: ServerChannelPayload & { deleted?: boolean } + data: Schema<"ServerChannel"> & { deleted?: boolean } ) { super(client, data); this.serverId = data.serverId; @@ -102,7 +103,9 @@ export class Channel extends Base { return this._updatedAt ? new Date(this._updatedAt) : null; } - _update(data: Partial): this { + _update( + data: Partial & { deleted?: boolean }> + ): this { if ("name" in data && typeof data.name !== "undefined") { this.name = data.name; } @@ -143,7 +146,7 @@ export class Channel extends Base { * @param options - Additional options for the message fetch. */ fetchMessages( - options?: RESTGetChannelMessagesQuery + options?: RestQuery["get"]> ): Promise> { return this.client.messages.fetchMany(this.id, options ?? {}); } @@ -160,7 +163,7 @@ export class Channel extends Base { * Update the channel with new data. * @param options - The new data for the channel. */ - update(options: RESTPatchChannelBody) { + update(options: RestBody["patch"]>) { return this.client.channels.update(this.id, options); } diff --git a/packages/guilded.js/lib/structures/channels/ChatChannel.ts b/packages/guilded.js/lib/structures/channels/ChatChannel.ts index 40c03c20..d707b937 100644 --- a/packages/guilded.js/lib/structures/channels/ChatChannel.ts +++ b/packages/guilded.js/lib/structures/channels/ChatChannel.ts @@ -1,4 +1,4 @@ -import type { RESTPostServerWebhooksBody } from "@guildedjs/guilded-api-typings"; +import { RestBody, RestPath } from "@guildedjs/guilded-api-typings"; import type { Webhook } from "../Webhook"; import { Channel } from "./Channel"; @@ -13,7 +13,9 @@ export class ChatChannel extends Channel { * @param options - The options for creating the webhook. * @returns A promise that resolves with the created webhook. */ - createWebhook(options: RESTPostServerWebhooksBody): Promise { + createWebhook( + options: RestBody["post"]> + ): Promise { return this.client.webhooks.create(this.serverId, options); } } diff --git a/packages/guilded.js/lib/structures/channels/DocChannel.ts b/packages/guilded.js/lib/structures/channels/DocChannel.ts index 3665131e..204f21af 100644 --- a/packages/guilded.js/lib/structures/channels/DocChannel.ts +++ b/packages/guilded.js/lib/structures/channels/DocChannel.ts @@ -1,11 +1,6 @@ import { Collection } from "@discordjs/collection"; -import type { - DocPayload, - RESTPostDocsBody, - RESTPutDocBody, - ChannelType, -} from "@guildedjs/guilded-api-typings"; import { Channel } from "./Channel"; +import { RestBody, RestPath, Schema } from "@guildedjs/guilded-api-typings"; /** * Represents a doc channel on Guilded @@ -15,14 +10,16 @@ export class DocChannel extends Channel { /** * The docs in this channel. */ - readonly docs = new Collection(); + readonly docs = new Collection>(); /** * Create a new doc in this channel. * @param options - The options for creating the doc. * @returns A promise that resolves with the created doc. */ - createDoc(options: RESTPostDocsBody): Promise { + createDoc( + options: RestBody["post"]> + ): Promise> { return this.client.docs.create(this.id, options); } @@ -30,16 +27,16 @@ export class DocChannel extends Channel { * Get all the docs from this channel. * @returns A promise that resolves with an array of all docs. */ - getDocs(): Promise { + getDocs(): Promise[]> { return this.client.docs.fetchMany(this.id); } /** * Get a specific doc from this channel. - * @param docId - The ID of the doc to fetch. + * @param docId - The ID ofSchema<"Doc"> the doc to fetch. * @returns A promise that resolves with the fetched doc. */ - getDoc(docId: number): Promise { + getDoc(docId: number): Promise> { return this.client.docs.fetch(this.id, docId); } @@ -49,7 +46,10 @@ export class DocChannel extends Channel { * @param options - The options for updating the doc. * @returns A promise that resolves with the updated doc. */ - updateDoc(docId: number, options: RESTPutDocBody): Promise { + updateDoc( + docId: number, + options: RestBody["put"]> + ): Promise> { return this.client.docs.update(this.id, docId, options); } diff --git a/packages/guilded.js/lib/structures/channels/ForumChannel.ts b/packages/guilded.js/lib/structures/channels/ForumChannel.ts index 181d9912..4a9a70dc 100644 --- a/packages/guilded.js/lib/structures/channels/ForumChannel.ts +++ b/packages/guilded.js/lib/structures/channels/ForumChannel.ts @@ -1,7 +1,7 @@ import { Collection } from "@discordjs/collection"; -import type { ForumTopicPayload } from "@guildedjs/guilded-api-typings"; import { Channel } from "./Channel"; import type { ForumTopic } from "../Forum"; +import { Schema } from "@guildedjs/guilded-api-typings"; /** * Represents a forum channel in Guilded. @@ -9,7 +9,7 @@ import type { ForumTopic } from "../Forum"; */ export class ForumChannel extends Channel { /** The topics in this channel. */ - readonly topics = new Collection(); + readonly topics = new Collection>(); /** * Creates a topic in this forum channel. diff --git a/packages/guilded.js/lib/structures/channels/ListChannel.ts b/packages/guilded.js/lib/structures/channels/ListChannel.ts index db90f8e4..50eb1d94 100644 --- a/packages/guilded.js/lib/structures/channels/ListChannel.ts +++ b/packages/guilded.js/lib/structures/channels/ListChannel.ts @@ -1,9 +1,6 @@ import { Collection } from "@discordjs/collection"; -import type { - ListItemPayload, - ListItemSummaryPayload, -} from "@guildedjs/guilded-api-typings"; import { Channel } from "./Channel"; +import { Schema } from "@guildedjs/guilded-api-typings"; /** * Represents a list channel in Guilded. @@ -15,7 +12,7 @@ export class ListChannel extends Channel { */ readonly items = new Collection< string, - ListItemPayload | ListItemSummaryPayload + Schema<"ListItem"> | Schema<"ListItemSummary"> >(); /** @@ -24,8 +21,11 @@ export class ListChannel extends Channel { * @param note - Optional note for the new list item. * @returns A Promise that resolves with the newly created list item payload. */ - createItem(message: string, note?: string): Promise { - return this.client.lists.create(this.id, { message, note }); + createItem(message: string, note?: string): Promise> { + return this.client.lists.create(this.id, { + message, + note: note ? { content: note } : undefined, + }); } /** @@ -33,7 +33,7 @@ export class ListChannel extends Channel { * @param itemId - The ID of the list item to fetch. * @returns A Promise that resolves with the list item payload. */ - getItem(itemId: string): Promise { + getItem(itemId: string): Promise> { return this.client.lists.fetch(this.id, itemId).then((data) => { this.items.set(data.id, data); return data; @@ -44,7 +44,7 @@ export class ListChannel extends Channel { * Fetches all list items in this channel. * @returns A Promise that resolves with an array of list item summary payloads. */ - getItems(): Promise { + getItems(): Promise[]> { return this.client.lists.fetchMany(this.id).then((data) => { for (const item of data) { this.items.set(item.id, item); diff --git a/packages/guilded.js/lib/structures/collectors/ReactionCollector.ts b/packages/guilded.js/lib/structures/collectors/ReactionCollector.ts index 1c40e51d..bfa925b2 100644 --- a/packages/guilded.js/lib/structures/collectors/ReactionCollector.ts +++ b/packages/guilded.js/lib/structures/collectors/ReactionCollector.ts @@ -1,29 +1,37 @@ -import type { WSChannelMessageReactionCreatedPayload, WSChannelMessageReactionDeletedPayload } from "@guildedjs/guilded-api-typings"; +import { WSPayload } from "@guildedjs/guilded-api-typings"; import { constants } from "../../constants"; import { Collector } from "./Collector"; /** * A collector that collects reactions on messages */ -export class ReactionCollector extends Collector { - /** - * Hooks the necessary events to start collecting reactions - */ - hookEvents() { - this.incrementMaxEventListeners(); - this.client.on(constants.clientEvents.MESSAGE_REACTION_CREATED, this.boundItemReceiver); - } +export class ReactionCollector extends Collector< + Reaction["reaction"] & { id: string } +> { + /** + * Hooks the necessary events to start collecting reactions + */ + hookEvents() { + this.incrementMaxEventListeners(); + this.client.on( + constants.clientEvents.MESSAGE_REACTION_CREATED, + this.boundItemReceiver + ); + } - /** - * Cleans up events and listeners after the collector has stopped collecting - */ - _cleanup(): void { - this.decrementMaxEventListeners(); - this.client.removeListener(constants.clientEvents.MESSAGE_REACTION_CREATED, this.boundItemReceiver); - } + /** + * Cleans up events and listeners after the collector has stopped collecting + */ + _cleanup(): void { + this.decrementMaxEventListeners(); + this.client.removeListener( + constants.clientEvents.MESSAGE_REACTION_CREATED, + this.boundItemReceiver + ); + } } /** * Represents a reaction to a message */ -type Reaction = WSChannelMessageReactionCreatedPayload["d"]; +type Reaction = WSPayload<"ChannelMessageReactionCreated">; diff --git a/packages/guilded.js/lib/structures/index.ts b/packages/guilded.js/lib/structures/index.ts index 770ececd..3c94f0e1 100644 --- a/packages/guilded.js/lib/structures/index.ts +++ b/packages/guilded.js/lib/structures/index.ts @@ -15,9 +15,8 @@ export * from "./User"; export * from "./Client"; export { - MentionsPayload, - EmbedField, - EmbedAuthor, - EmbedFooter, - EmbedImage, + EmbedField, + EmbedAuthor, + EmbedFooter, + EmbedImage, } from "@guildedjs/guilded-api-typings"; diff --git a/packages/guilded.js/lib/typings.ts b/packages/guilded.js/lib/typings.ts index 2b92c434..1702eeb7 100644 --- a/packages/guilded.js/lib/typings.ts +++ b/packages/guilded.js/lib/typings.ts @@ -1,20 +1,8 @@ import type { - DocPayload, EmbedPayload, - ListItemPayload, - ListItemSummaryPayload, - RESTPostChannelMessagesBody, - ServerMemberBanPayload, - ServerMemberPayload, - ServerMemberRoleIdsPayload, - ServerMemberSummaryPayload, - SocialLink, - WSChannelMessageReactionDeletedPayload, - WSChatMessageDeletedPayload, - WSServerMemberBannedPayload, - WSServerMemberRemovedPayload, - WSServerMemberUnbannedPayload, - WSServerMemberUpdatedPayload, + RestBody, + RestPath, + Schema, } from "@guildedjs/guilded-api-typings"; import type { Channel, @@ -23,7 +11,6 @@ import type { MemberBan, Message, MessageReaction, - User, Webhook, } from "./structures"; import type { @@ -46,18 +33,22 @@ export interface BareStructureBaseData { } export type UpgradedServerMemberPayload = IDUpgradePayload< - ServerUpgradePayload + ServerUpgradePayload> +>; +export type UpgradedServerMemberBanPayload = ServerUpgradePayload< + Schema<"ServerMemberBan"> >; -export type UpgradedServerMemberBanPayload = - ServerUpgradePayload; export type UpgradedServerMemberSummaryPayload = IDUpgradePayload< - ServerUpgradePayload + ServerUpgradePayload> >; export type ServerUpgradePayload = T & { serverId: string }; export type IDUpgradePayload = T & { id: string }; export type MessageContent = - | (Omit & { + | (Omit< + RestBody["post"]>, + "embeds" + > & { embeds?: Embed[] | EmbedPayload[]; }) | string @@ -91,17 +82,17 @@ export type ClientEvents = { channelCreated: (channel: Channel) => unknown; channelUpdated: (channel: Channel, oldChannel: Channel | null) => unknown; channelDeleted: (channel: Channel) => unknown; - docCreated: (doc: DocPayload) => unknown; - docUpdated: (newDoc: DocPayload, oldDoc: DocPayload | null) => unknown; - docDeleted: (doc: DocPayload) => unknown; - listItemCreated: (item: ListItemPayload) => unknown; + docCreated: (doc: Schema<"Doc">) => unknown; + docUpdated: (newDoc: Schema<"Doc">, oldDoc: Schema<"Doc"> | null) => unknown; + docDeleted: (doc: Schema<"Doc">) => unknown; + listItemCreated: (item: Schema<"ListItem">) => unknown; listItemUpdated: ( - newItem: ListItemPayload, - oldItem: ListItemPayload | ListItemSummaryPayload | null + newItem: Schema<"ListItem">, + oldItem: Schema<"ListItem"> | Schema<"ListItemSummary"> | null ) => unknown; - listItemDeleted: (item: ListItemPayload) => unknown; - listItemCompleted: (item: ListItemPayload) => unknown; - listItemUncompleted: (item: ListItemPayload) => unknown; + listItemDeleted: (item: Schema<"ListItem">) => unknown; + listItemCompleted: (item: Schema<"ListItem">) => unknown; + listItemUncompleted: (item: Schema<"ListItem">) => unknown; memberJoined: (member: Member) => unknown; memberRemoved: (event: MemberRemovedEvent) => unknown; memberUpdated: (event: MemberUpdatedEvent) => unknown; @@ -109,15 +100,15 @@ export type ClientEvents = { memberUnbanned: (event: MemberUnbannedEvent) => unknown; memberSocialLinkCreated: ( serverId: string, - socialLink: SocialLink + socialLink: Schema<"SocialLink"> ) => unknown; memberSocialLinkUpdated: ( serverId: string, - socialLink: SocialLink + socialLink: Schema<"SocialLink"> ) => unknown; memberSocialLinkDeleted: ( serverId: string, - socialLink: SocialLink + socialLink: Schema<"SocialLink"> ) => unknown; botServerCreated: (server: Server, user: string) => unknown; botServerDeleted: (server: Server, user: string) => unknown; @@ -135,7 +126,10 @@ export type ClientEvents = { webhookCreated: (webhook: Webhook) => unknown; webhookUpdated: (webhook: Webhook, oldWebhook: Webhook | null) => unknown; rolesUpdated: ( - updatedMembers: { serverId: string; members: ServerMemberRoleIdsPayload[] }, + updatedMembers: { + serverId: string; + members: { userId: string; roleIds: number[] }[]; + }, oldMembers: Member[] ) => unknown; unknownGatewayEvent: (data: any) => unknown; diff --git a/packages/guilded.js/lib/util.ts b/packages/guilded.js/lib/util.ts index ea37944d..01420ef0 100644 --- a/packages/guilded.js/lib/util.ts +++ b/packages/guilded.js/lib/util.ts @@ -1,4 +1,4 @@ -import type { RESTPostChannelMessagesBody } from "@guildedjs/guilded-api-typings"; +import { RestBody, RestPath } from "@guildedjs/guilded-api-typings"; import { DOMAINS } from "@guildedjs/rest"; import { Embed } from "./structures/Embed"; import type { MessageContent } from "./typings"; @@ -7,9 +7,9 @@ import type { MessageContent } from "./typings"; * Valid image file extensions */ export enum IMG_EXTENSION { - PNG = "png", - GIF = "gif", - WEBP = "webp", + PNG = "png", + GIF = "gif", + WEBP = "webp", } /** @@ -28,135 +28,134 @@ export type IMG_SIZE = "Small" | "Medium" | "Large"; * @returns A URL string for the asset */ const formAssetURL = ( - route: string, - hash: string, - extension: string, - width?: number, - height?: number, - size?: string + route: string, + hash: string, + extension: string, + width?: number, + height?: number, + size?: string ): string => { - const url = new URL( - `https://${ - DOMAINS.IMAGE_CDN_DOMAIN - }/${route}/${hash}-${size}.${extension.toLowerCase()}` - ); - if (width) url.searchParams.append("w", width.toString()); - if (height) url.searchParams.append("h", height.toString()); - return url.toString(); + const url = new URL( + `https://${DOMAINS.IMAGE_CDN_DOMAIN + }/${route}/${hash}-${size}.${extension.toLowerCase()}` + ); + if (width) url.searchParams.append("w", width.toString()); + if (height) url.searchParams.append("h", height.toString()); + return url.toString(); }; /** * Object containing functions to build Guilded asset URLs */ export const ASSET_BUILDER = { - /** - * Function to build a Guilded user avatar URL - * @param hash - The hash of the user's avatar - * @param size - The size of the avatar (optional) - * @returns A URL string for the user avatar - */ - AVATAR_URL: (hash: string, size: IMG_SIZE = "Medium"): string => - formAssetURL( - "UserAvatar", - hash, - IMG_EXTENSION.PNG, - undefined, - undefined, - size - ), - /** - * Function to build a Guilded chat message image URL - * @param hash - The hash of the image - * @param size - The size of the image (optional) - * @param width - The width of the image (optional) - * @param height - The height of the image (optional) - * @returns A URL string for the image in a chat message - */ - IMAGE_IN_CHAT: ( - hash: string, - size = "Full", - width?: number, - height?: number - ): string => - formAssetURL("ContentMedia", hash, IMG_EXTENSION.WEBP, width, height, size), - /** - * Function to build a Guilded user profile banner URL - * @param hash - The hash of the user's banner - * @param size - The size of the banner (optional) - * @param width - The width of the banner (optional) - * @param height - The height of the banner (optional) - * @returns A URL string for the user profile banner - */ - PROFILE_BANNER: ( - hash: string, - size = "Hero", - width?: number, - height?: number - ): string => - formAssetURL("UserBanner", hash, IMG_EXTENSION.PNG, width, height, size), - /** - * Builds a URL for a server banner asset. - * - * @param hash - The hash of the banner asset. - * @param size - The size of the banner asset. Default value is "Hero". - * @param width - The width of the banner asset. Defaults to undefined. - * @param height - The height of the banner asset. Defaults to undefined. - * - * @returns The URL of the server banner asset. - */ - SERVER_BANNER: ( - hash: string, - size = "Hero", - width?: number, - height?: number - ): string => - formAssetURL("TeamBanner", hash, IMG_EXTENSION.PNG, width, height, size), - /** - * Builds a URL for a server emoji asset. - * - * @param hash - The hash of the emoji asset. - * @param size - The size of the emoji asset. Default value is "Full". - * @param extension - The extension of the emoji asset. Default value is "WEBP". - * @param width - The width of the emoji asset. Defaults to undefined. - * @param height - The height of the emoji asset. Defaults to undefined. - * - * @returns The URL of the server emoji asset. - */ - SERVER_EMOJI: ( - hash: string, - size = "Full", - extension: "WEBP" | "APNG" = "WEBP", - width?: number, - height?: number - ): string => - formAssetURL( - "CustomReaction", - hash, - extension.toLowerCase(), - width, - height, - size - ), - /** - * Builds a URL for a server icon asset. - * - * @param hash - The hash of the icon asset. - * @param size - The size of the icon asset. Default value is "Medium". - * - * @returns The URL of the server icon asset. - */ - SERVER_ICON: ( - hash: string, - size: "Small" | "Medium" | "Large" = "Medium" - ): string => - formAssetURL( - "TeamAvatar", - hash, - IMG_EXTENSION.PNG, - undefined, - undefined, - size - ), + /** + * Function to build a Guilded user avatar URL + * @param hash - The hash of the user's avatar + * @param size - The size of the avatar (optional) + * @returns A URL string for the user avatar + */ + AVATAR_URL: (hash: string, size: IMG_SIZE = "Medium"): string => + formAssetURL( + "UserAvatar", + hash, + IMG_EXTENSION.PNG, + undefined, + undefined, + size + ), + /** + * Function to build a Guilded chat message image URL + * @param hash - The hash of the image + * @param size - The size of the image (optional) + * @param width - The width of the image (optional) + * @param height - The height of the image (optional) + * @returns A URL string for the image in a chat message + */ + IMAGE_IN_CHAT: ( + hash: string, + size = "Full", + width?: number, + height?: number + ): string => + formAssetURL("ContentMedia", hash, IMG_EXTENSION.WEBP, width, height, size), + /** + * Function to build a Guilded user profile banner URL + * @param hash - The hash of the user's banner + * @param size - The size of the banner (optional) + * @param width - The width of the banner (optional) + * @param height - The height of the banner (optional) + * @returns A URL string for the user profile banner + */ + PROFILE_BANNER: ( + hash: string, + size = "Hero", + width?: number, + height?: number + ): string => + formAssetURL("UserBanner", hash, IMG_EXTENSION.PNG, width, height, size), + /** + * Builds a URL for a server banner asset. + * + * @param hash - The hash of the banner asset. + * @param size - The size of the banner asset. Default value is "Hero". + * @param width - The width of the banner asset. Defaults to undefined. + * @param height - The height of the banner asset. Defaults to undefined. + * + * @returns The URL of the server banner asset. + */ + SERVER_BANNER: ( + hash: string, + size = "Hero", + width?: number, + height?: number + ): string => + formAssetURL("TeamBanner", hash, IMG_EXTENSION.PNG, width, height, size), + /** + * Builds a URL for a server emoji asset. + * + * @param hash - The hash of the emoji asset. + * @param size - The size of the emoji asset. Default value is "Full". + * @param extension - The extension of the emoji asset. Default value is "WEBP". + * @param width - The width of the emoji asset. Defaults to undefined. + * @param height - The height of the emoji asset. Defaults to undefined. + * + * @returns The URL of the server emoji asset. + */ + SERVER_EMOJI: ( + hash: string, + size = "Full", + extension: "WEBP" | "APNG" = "WEBP", + width?: number, + height?: number + ): string => + formAssetURL( + "CustomReaction", + hash, + extension.toLowerCase(), + width, + height, + size + ), + /** + * Builds a URL for a server icon asset. + * + * @param hash - The hash of the icon asset. + * @param size - The size of the icon asset. Default value is "Medium". + * + * @returns The URL of the server icon asset. + */ + SERVER_ICON: ( + hash: string, + size: "Small" | "Medium" | "Large" = "Medium" + ): string => + formAssetURL( + "TeamAvatar", + hash, + IMG_EXTENSION.PNG, + undefined, + undefined, + size + ), }; /** @@ -168,7 +167,7 @@ export const ASSET_BUILDER = { * @returns The key for the member object. */ export const buildMemberKey = (serverId: string, memberId: string): string => { - return `${serverId}:${memberId}`; + return `${serverId}:${memberId}`; }; /** @@ -181,11 +180,11 @@ export const buildMemberKey = (serverId: string, memberId: string): string => { * @returns The key for the reaction object. */ export const buildMessageReactionKey = ( - messageId: string, - userId: string, - emoteId: number + messageId: string, + userId: string, + emoteId: number ) => { - return `${messageId}:${userId}:${emoteId}`; + return `${messageId}:${userId}:${emoteId}`; }; /** @@ -197,9 +196,13 @@ export const buildMessageReactionKey = ( * @returns The key for the reaction object. */ export const buildReactionKey = (userId: string, emoteId: number) => { - return `${userId}:${emoteId}`; + return `${userId}:${emoteId}`; }; +export const buildCalendarRsvpKey = (calendarEventId: number, userId: string) => { + return `${calendarEventId}:${userId}` +} + /** * Resolves message content to REST message data. * @@ -208,13 +211,13 @@ export const buildReactionKey = (userId: string, emoteId: number) => { * @returns REST message data. */ export const resolveContentToData = ( - content: MessageContent -): RESTPostChannelMessagesBody => { - if (typeof content === "string") return { content }; - if (content instanceof Embed) return { embeds: [content.toJSON()] }; + content: MessageContent +): RestBody["post"]> => { + if (typeof content === "string") return { content }; + if (content instanceof Embed) return { embeds: [content.toJSON()] }; - return { - ...content, - embeds: content.embeds?.map((x) => (x instanceof Embed ? x.toJSON() : x)), - }; + return { + ...content, + embeds: content.embeds?.map((x) => (x instanceof Embed ? x.toJSON() : x)), + }; }; diff --git a/packages/rest/lib/util/Router.ts b/packages/rest/lib/util/Router.ts index a77ead17..9df43432 100644 --- a/packages/rest/lib/util/Router.ts +++ b/packages/rest/lib/util/Router.ts @@ -1,94 +1,10 @@ import type { - RESTDeleteCalendarEventResult, - RESTDeleteCalendarEventRsvpResult, - RESTDeleteChannelMessageResult, - RESTDeleteChannelResult, - RESTDeleteDocResult, - RESTDeleteForumTopicLockResult, - RESTDeleteForumTopicPinResult, - RESTDeleteForumTopicResult, - RESTDeleteGroupMemberResult, - RESTDeleteListItemCompleteResult, - RESTDeleteListItemResult, - RESTDeleteMemberBanResult, - RESTDeleteMemberNicknameResult, - RESTDeleteMemberResult, - RESTDeleteMemberRoleResult, - RESTDeleteReactionResult, - RESTDeleteServerWebhookResult, - RESTGetCalendarEventResult, - RESTGetCalendarEventRsvpResult, - RESTGetCalendarEventRsvpsResult, - RESTGetCalendarEventsBody, - RESTGetCalendarEventsResult, - RESTGetChannelMessageResult, - RESTGetChannelMessagesQuery, - RESTGetChannelMessagesResult, - RESTGetChannelResult, - RESTGetDocResult, - RESTGetDocsResult, - RESTGetForumTopicResult, - RESTGetForumTopicsQuery, - RESTGetForumTopicsResult, - RESTGetListItemResult, - RESTGetListItemsResult, - RESTGetMemberBanResult, - RESTGetMemberBansResult, - RESTGetMemberResult, - RESTGetMemberRolesResult, - RESTGetMemberSocialLinkResult, - RESTGetMembersResult, - RESTGetServerResult, - RESTGetServerWebhookResult, - RESTGetServerWebhooksQuery, - RESTGetServerWebhooksResult, - RESTGetUserResult, - RESTPatchCalendarEventBody, - RESTPatchCalendarEventResult, - RESTPatchCalendarEventRsvpBody, - RESTPatchCalendarEventRsvpResult, - RESTPatchCalendarEventRsvpManyBody, - RESTPatchCalendarEventRsvpManyResult, - RESTPatchChannelBody, - RESTPatchChannelResult, - RESTPatchForumTopicBody, - RESTPatchForumTopicResult, - RESTPostCalendarEventBody, - RESTPostCalendarEventResult, - RESTPostChannelMessagesBody, - RESTPostChannelMessagesResult, - RESTPostChannelsBody, - RESTPostChannelsResult, - RESTPostDocsBody, - RESTPostDocsResult, - RESTPostForumTopicBody, - RESTPostForumTopicResult, - RESTPostListItemBody, - RESTPostListItemCompleteResult, - RESTPostListItemResult, - RESTPostMemberBanBody, - RESTPostMemberBanResult, - RESTPostRoleXpResult, - RESTPostServerWebhooksBody, - RESTPostServerWebhooksResult, - RESTPostUserXPBody, - RESTPostUserXpResult, - RESTPutChannelMessageBody, - RESTPutChannelMessageResult, - RESTPutDocBody, - RESTPutDocResult, - RESTPutForumTopicLockResult, - RESTPutForumTopicPinResult, - RESTPutGroupMemberResult, - RESTPutListItemBody, - RESTPutListItemResult, - RESTPutMemberNicknameBody, - RESTPutMemberNicknameResult, - RESTPutMemberRoleResult, - RESTPutReactionResult, - RESTPutServerWebhookBody, - RESTPutServerWebhookResult, - UserSocialLink, + rest, + RestBody, + RestPath, + RestPayload, + RestQuery, + Schema, } from "@guildedjs/guilded-api-typings"; import type { RestManager } from "../RestManager"; import { ROUTES } from "./routes"; @@ -100,19 +16,18 @@ export class Router { * Create a channel */ async createChannel( - data: RESTPostChannelsBody - ): Promise { - return this.rest.post( - ROUTES.channels(), - data - ); + data: RestBody["post"]> + ): Promise["post"], 201>> { + return this.rest.post(ROUTES.channels(), data); } /** * Fetch a channel */ - async getChannel(channelId: string): Promise { - return this.rest.get(ROUTES.channel(channelId)); + async getChannel( + channelId: string + ): Promise["get"], 200>> { + return this.rest.get(ROUTES.channel(channelId)); } /** @@ -120,19 +35,18 @@ export class Router { */ async updateChannel( channelId: string, - data: RESTPatchChannelBody - ): Promise { - return this.rest.patch( - ROUTES.channel(channelId), - data - ); + data: RestBody["patch"]> + ): Promise["patch"], 200>> { + return this.rest.patch(ROUTES.channel(channelId), data); } /** * Delete a channel */ - async deleteChannel(channelId: string): Promise { - return this.rest.delete(ROUTES.channel(channelId)); + async deleteChannel( + channelId: string + ): Promise["delete"], 204>> { + return this.rest.delete(ROUTES.channel(channelId)); } /** @@ -140,12 +54,11 @@ export class Router { */ async createChannelMessage( channelId: string, - content: RESTPostChannelMessagesBody - ): Promise { - return this.rest.post< - RESTPostChannelMessagesResult, - RESTPostChannelMessagesBody - >(ROUTES.channelMessages(channelId), content); + content: RestBody["post"]> + ): Promise< + RestPayload["post"], 201> + > { + return this.rest.post(ROUTES.channelMessages(channelId), content); } /** @@ -153,12 +66,11 @@ export class Router { */ async getChannelMessages( channelId: string, - options: RESTGetChannelMessagesQuery - ): Promise { - return this.rest.get< - RESTGetChannelMessagesResult, - RESTGetChannelMessagesQuery - >(ROUTES.channelMessages(channelId), options); + options: RestQuery["get"]> + ): Promise< + RestPayload["get"], 200> + > { + return this.rest.get(ROUTES.channelMessages(channelId), options); } /** @@ -167,10 +79,13 @@ export class Router { async getChannelMessage( channelId: string, messageId: string - ): Promise { - return this.rest.get( - ROUTES.channelMessage(channelId, messageId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/messages/{messageId}">["get"], + 200 + > + > { + return this.rest.get(ROUTES.channelMessage(channelId, messageId)); } /** @@ -179,12 +94,16 @@ export class Router { async updateChannelMessage( channelId: string, messageId: string, - options: RESTPutChannelMessageBody - ): Promise { - return this.rest.put< - RESTPutChannelMessageResult, - RESTPutChannelMessageBody - >(ROUTES.channelMessage(channelId, messageId), options); + options: RestBody< + RestPath<"/channels/{channelId}/messages/{messageId}">["put"] + > + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/messages/{messageId}">["put"], + 200 + > + > { + return this.rest.put(ROUTES.channelMessage(channelId, messageId), options); } /** @@ -193,10 +112,13 @@ export class Router { async deleteChannelMessage( channelId: string, messageId: string - ): Promise { - return this.rest.delete( - ROUTES.channelMessage(channelId, messageId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/messages/{messageId}">["delete"], + 200 + > + > { + return this.rest.delete(ROUTES.channelMessage(channelId, messageId)); } /** @@ -205,10 +127,13 @@ export class Router { async getCalendarEvent( channelId: string, calendarEventId: number - ): Promise { - return this.rest.get( - ROUTES.calendarEvent(channelId, calendarEventId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/events/{calendarEventId}">["get"], + 200 + > + > { + return this.rest.get(ROUTES.calendarEvent(channelId, calendarEventId)); } /** @@ -216,12 +141,11 @@ export class Router { */ async getCalendarEvents( channelId: string, - options: RESTGetCalendarEventsBody - ): Promise { - return this.rest.get< - RESTGetCalendarEventsResult, - RESTGetCalendarEventsBody - >(ROUTES.calendarEvents(channelId), options); + options: RestQuery["get"]> + ): Promise< + RestPayload["get"], 200> + > { + return this.rest.get(ROUTES.calendarEvents(channelId), options); } /** @@ -229,12 +153,11 @@ export class Router { */ async createCalendarEvent( channelId: string, - options: RESTPostCalendarEventBody - ): Promise { - return this.rest.post< - RESTPostCalendarEventResult, - RESTPostCalendarEventBody - >(ROUTES.calendarEvents(channelId), options); + options: RestBody["post"]> + ): Promise< + RestPayload["post"], 200> + > { + return this.rest.post(ROUTES.calendarEvents(channelId), options); } /** @@ -243,12 +166,19 @@ export class Router { async updateCalendarEvent( channelId: string, calendarEventId: number, - options: RESTPatchCalendarEventBody - ): Promise { - return this.rest.patch< - RESTPatchCalendarEventResult, - RESTPatchCalendarEventBody - >(ROUTES.calendarEvent(channelId, calendarEventId), options); + options: RestBody< + RestPath<"/channels/{channelId}/events/{calendarEventId}">["patch"] + > + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/events/{calendarEventId}">["patch"], + 200 + > + > { + return this.rest.patch( + ROUTES.calendarEvent(channelId, calendarEventId), + options + ); } /** @@ -257,10 +187,13 @@ export class Router { async deleteCalendarEvent( channelId: string, calendarEventId: number - ): Promise { - return this.rest.delete( - ROUTES.calendarEvent(channelId, calendarEventId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/events/{calendarEventId}">["delete"], + 200 + > + > { + return this.rest.delete(ROUTES.calendarEvent(channelId, calendarEventId)); } /** @@ -270,8 +203,13 @@ export class Router { channelId: string, calendarEventId: number, userId: string - ): Promise { - return this.rest.get( + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/events/{calendarEventId}/rsvps/{userId}">["get"], + 200 + > + > { + return this.rest.get( ROUTES.calendarEventRsvp(channelId, calendarEventId, userId) ); } @@ -282,10 +220,13 @@ export class Router { async getCalendarEventRsvps( channelId: string, calendarEventId: number - ): Promise { - return this.rest.get( - ROUTES.calendarEventRsvps(channelId, calendarEventId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/events/{calendarEventId}/rsvps">["get"], + 200 + > + > { + return this.rest.get(ROUTES.calendarEventRsvps(channelId, calendarEventId)); } /** @@ -295,12 +236,19 @@ export class Router { channelId: string, calendarEventId: number, userId: string, - options: RESTPatchCalendarEventRsvpBody - ): Promise { - return this.rest.put< - RESTPatchCalendarEventRsvpResult, - RESTPatchCalendarEventRsvpBody - >(ROUTES.calendarEventRsvp(channelId, calendarEventId, userId), options); + options: RestBody< + RestPath<"/channels/{channelId}/events/{calendarEventId}/rsvps/{userId}">["put"] + > + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/events/{calendarEventId}/rsvps/{userId}">["put"], + 200 + > + > { + return this.rest.put( + ROUTES.calendarEventRsvp(channelId, calendarEventId, userId), + options + ); } /** @@ -309,23 +257,35 @@ export class Router { async updateCalendarEventRsvpMany( channelId: string, calendarEventId: number, - options: RESTPatchCalendarEventRsvpManyBody - ): Promise { - return this.rest.put< - RESTPatchCalendarEventRsvpManyResult, - RESTPatchCalendarEventRsvpManyBody - >(ROUTES.calendarEventRsvpsMany(channelId, calendarEventId), options); + options: RestBody< + RestPath<"/channels/{channelId}/events/{calendarEventId}/rsvps">["put"] + > + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/events/{calendarEventId}/rsvps">["put"], + 200 + > + > { + return this.rest.put( + ROUTES.calendarEventRsvpsMany(channelId, calendarEventId), + options + ); } /** * Delete an rsvp user from a calendar event */ - async deleteCalendarEventRvsp( + async deleteCalendarEventRsvp( channelId: string, calendarEventId: number, userId: string - ): Promise { - return this.rest.delete( + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/events/{calendarEventId}/rsvps/{userId}">["delete"], + 204 + > + > { + return this.rest.delete( ROUTES.calendarEventRsvp(channelId, calendarEventId, userId) ); } @@ -336,10 +296,13 @@ export class Router { async getMemberRoles( serverId: string, userId: string - ): Promise { - return this.rest.get( - ROUTES.memberRoles(serverId, userId) - ); + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/members/{userId}/roles">["get"], + 200 + > + > { + return this.rest.get(ROUTES.memberRoles(serverId, userId)); } /** @@ -349,11 +312,13 @@ export class Router { serverId: string, userId: string, nickname: string - ): Promise { - return this.rest.put< - RESTPutMemberNicknameResult, - RESTPutMemberNicknameBody - >(ROUTES.memberNickname(serverId, userId), { nickname }); + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/members/{userId}/nickname">["put"], + 200 + > + > { + return this.rest.put(ROUTES.memberNickname(serverId, userId), { nickname }); } /** @@ -362,17 +327,22 @@ export class Router { async deleteMemberNickname( serverId: string, userId: string - ): Promise { - return this.rest.delete( - ROUTES.memberNickname(serverId, userId) - ); + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/members/{userId}/nickname">["delete"], + 204 + > + > { + return this.rest.delete(ROUTES.memberNickname(serverId, userId)); } /** * Get a server */ - async getServer(serverId: string): Promise { - return this.rest.get(ROUTES.server(serverId)); + async getServer( + serverId: string + ): Promise["get"], 200>> { + return this.rest.get(ROUTES.server(serverId)); } /** @@ -380,12 +350,11 @@ export class Router { */ async createForumTopic( channelId: string, - options: RESTPostForumTopicBody - ): Promise { - return this.rest.post( - ROUTES.forumTopics(channelId), - options - ); + options: RestBody["post"]> + ): Promise< + RestPayload["post"], 201> + > { + return this.rest.post(ROUTES.forumTopics(channelId), options); } /** @@ -393,12 +362,11 @@ export class Router { */ async getForumTopics( channelId: string, - options: RESTGetForumTopicsQuery - ): Promise { - return this.rest.get( - ROUTES.forumTopics(channelId), - options - ); + options: RestQuery["get"]> + ): Promise< + RestPayload["get"], 200> + > { + return this.rest.get(ROUTES.forumTopics(channelId), options); } /** @@ -407,10 +375,13 @@ export class Router { async getForumTopic( channelId: string, forumThreadId: string - ): Promise { - return this.rest.get( - ROUTES.forumTopic(channelId, forumThreadId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/topics/{forumTopicId}">["get"], + 200 + > + > { + return this.rest.get(ROUTES.forumTopic(channelId, forumThreadId)); } /** @@ -419,9 +390,16 @@ export class Router { async updateForumTopic( channelId: string, forumThreadId: string, - options: RESTPatchForumTopicBody - ): Promise { - return this.rest.patch( + options: RestBody< + RestPath<"/channels/{channelId}/topics/{forumTopicId}">["patch"] + > + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/topics/{forumTopicId}">["patch"], + 201 + > + > { + return this.rest.patch( ROUTES.forumTopic(channelId, forumThreadId), options ); @@ -433,10 +411,13 @@ export class Router { async deleteForumTopic( channelId: string, forumThreadId: string - ): Promise { - return this.rest.delete( - ROUTES.forumTopic(channelId, forumThreadId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/topics/{forumTopicId}">["delete"], + 204 + > + > { + return this.rest.delete(ROUTES.forumTopic(channelId, forumThreadId)); } /** @@ -445,22 +426,28 @@ export class Router { async pinForumTopic( channelId: string, forumThreadId: string - ): Promise { - return this.rest.put( - ROUTES.forumTopic(channelId, forumThreadId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/topics/{forumTopicId}/pin">["put"], + 204 + > + > { + return this.rest.put(ROUTES.forumTopicPin(channelId, forumThreadId)); } /** - * Pin a topic in a forum + * Unpin a topic in a forum */ async unpinForumTopic( channelId: string, forumThreadId: string - ): Promise { - return this.rest.put( - ROUTES.forumTopic(channelId, forumThreadId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/topics/{forumTopicId}/pin">["delete"], + 204 + > + > { + return this.rest.delete(ROUTES.forumTopicPin(channelId, forumThreadId)); } /** @@ -469,10 +456,13 @@ export class Router { async lockForumTopic( channelId: string, forumThreadId: string - ): Promise { - return this.rest.put( - ROUTES.forumTopic(channelId, forumThreadId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/topics/{forumTopicId}/lock">["put"], + 204 + > + > { + return this.rest.put(ROUTES.forumTopicLock(channelId, forumThreadId)); } /** @@ -481,10 +471,13 @@ export class Router { async unlockForumTopic( channelId: string, forumThreadId: string - ): Promise { - return this.rest.put( - ROUTES.forumTopic(channelId, forumThreadId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/topics/{forumTopicId}/lock">["delete"], + 204 + > + > { + return this.rest.delete(ROUTES.forumTopicLock(channelId, forumThreadId)); } /** @@ -492,19 +485,22 @@ export class Router { */ async createListItem( channelId: string, - options: RESTPostListItemBody - ): Promise { - return this.rest.post( - ROUTES.listItems(channelId), - options - ); + options: RestBody["post"]> + ): Promise< + RestPayload["post"], 201> + > { + return this.rest.post(ROUTES.listItems(channelId), options); } /** * Get list items */ - async getListItems(channelId: string): Promise { - return this.rest.get(ROUTES.listItems(channelId)); + async getListItems( + channelId: string + ): Promise["get"], 200>> { + return this.rest.get< + RestPayload["get"], 200> + >(ROUTES.listItems(channelId)); } /** @@ -513,10 +509,13 @@ export class Router { async getListItem( channelId: string, itemId: string - ): Promise { - return this.rest.get( - ROUTES.listItem(channelId, itemId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/items/{listItemId}">["get"], + 200 + > + > { + return this.rest.get(ROUTES.listItem(channelId, itemId)); } /** @@ -525,12 +524,16 @@ export class Router { async updateListItem( channelId: string, itemId: string, - options: RESTPutListItemBody - ): Promise { - return this.rest.put( - ROUTES.listItem(channelId, itemId), - options - ); + options: RestBody< + RestPath<"/channels/{channelId}/items/{listItemId}">["put"] + > + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/items/{listItemId}">["put"], + 200 + > + > { + return this.rest.put(ROUTES.listItem(channelId, itemId), options); } /** @@ -539,28 +542,37 @@ export class Router { async deleteListItem( channelId: string, itemId: string - ): Promise { - return this.rest.delete( - ROUTES.listItem(channelId, itemId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/items/{listItemId}">["delete"], + 204 + > + > { + return this.rest.delete(ROUTES.listItem(channelId, itemId)); } async completeListItem( channelId: string, itemId: string - ): Promise { - return this.rest.post( - ROUTES.listItemComplete(channelId, itemId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/items/{listItemId}/complete">["post"], + 204 + > + > { + return this.rest.post(ROUTES.listItemComplete(channelId, itemId)); } async uncompleteListItem( channelId: string, itemId: string - ): Promise { - return this.rest.delete( - ROUTES.listItemComplete(channelId, itemId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/items/{listItemId}/complete">["delete"], + 204 + > + > { + return this.rest.delete(ROUTES.listItemComplete(channelId, itemId)); } /** @@ -568,26 +580,30 @@ export class Router { */ async createDoc( channelId: string, - options: RESTPostDocsBody - ): Promise { - return this.rest.post( - ROUTES.channelDocs(channelId), - options - ); + options: RestBody["post"]> + ): Promise["post"], 201>> { + return this.rest.post(ROUTES.channelDocs(channelId), options); } /** * Get the docs from a channel. */ - async getDocs(channelId: string): Promise { - return this.rest.get(ROUTES.channelDocs(channelId)); + async getDocs( + channelId: string + ): Promise["get"], 200>> { + return this.rest.get(ROUTES.channelDocs(channelId)); } /** * Get a doc from a channel. */ - async getDoc(channelId: string, docId: number): Promise { - return this.rest.get(ROUTES.channelDoc(channelId, docId)); + async getDoc( + channelId: string, + docId: number + ): Promise< + RestPayload["get"], 200> + > { + return this.rest.get(ROUTES.channelDoc(channelId, docId)); } /** @@ -596,12 +612,11 @@ export class Router { async updateDoc( channelId: string, docId: number, - options: RESTPutDocBody - ): Promise { - return this.rest.put( - ROUTES.channelDoc(channelId, docId), - options - ); + options: RestBody["put"]> + ): Promise< + RestPayload["put"], 200> + > { + return this.rest.put(ROUTES.channelDoc(channelId, docId), options); } /** @@ -610,10 +625,10 @@ export class Router { async deleteDoc( channelId: string, docId: number - ): Promise { - return this.rest.delete( - ROUTES.channelDoc(channelId, docId) - ); + ): Promise< + RestPayload["delete"], 204> + > { + return this.rest.delete(ROUTES.channelDoc(channelId, docId)); } /** @@ -623,10 +638,13 @@ export class Router { channelId: string, contentId: string, emoteId: number - ): Promise { - return this.rest.put( - ROUTES.channelReaction(channelId, contentId, emoteId) - ); + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/messages/{messageId}/emotes/{emoteId}">["put"], + 204 + > + > { + return this.rest.put(ROUTES.channelReaction(channelId, contentId, emoteId)); } /** @@ -636,8 +654,13 @@ export class Router { channelId: string, contentId: string, emoteId: number - ): Promise { - return this.rest.delete( + ): Promise< + RestPayload< + RestPath<"/channels/{channelId}/messages/{messageId}/emotes/{emoteId}">["delete"], + 204 + > + > { + return this.rest.delete( ROUTES.channelReaction(channelId, contentId, emoteId) ); } @@ -649,11 +672,13 @@ export class Router { serverId: string, userId: string, amount: number - ): Promise { - return this.rest.post( - ROUTES.memberXP(serverId, userId), - { amount } - ); + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/members/{userId}/xp">["post"], + 200 + > + > { + return this.rest.post(ROUTES.memberXP(serverId, userId), { amount }); } /** @@ -663,15 +688,14 @@ export class Router { serverId: string, roleId: string, amount: number - ): Promise { - return this.rest.post( - ROUTES.roleXP(serverId, roleId), - { amount } - ); + ): Promise< + RestPayload["post"], 204> + > { + return this.rest.post(ROUTES.roleXP(serverId, roleId), { amount }); } - async getMe(): Promise { - return this.rest.get(ROUTES.me()); + async getMe(): Promise["get"], 200>> { + return this.rest.get(ROUTES.me()); } /** @@ -680,31 +704,41 @@ export class Router { async getMemberSocialLinks( serverId: string, userId: string, - type: UserSocialLink - ): Promise { - return this.rest.get( - ROUTES.memberSocialLinks(serverId, userId, type) - ); + type: Schema<"SocialLink">["type"] + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/members/{userId}/social-links/{socialLinkType}">["get"], + 200 + > + > { + return this.rest.get(ROUTES.memberSocialLinks(serverId, userId, type)); } async getMember( serverId: string, userId: string - ): Promise { - return this.rest.get(ROUTES.member(serverId, userId)); + ): Promise< + RestPayload["get"], 200> + > { + return this.rest.get(ROUTES.member(serverId, userId)); } - async getMembers(serverId: string): Promise { - return this.rest.get(ROUTES.members(serverId)); + async getMembers( + serverId: string + ): Promise["get"], 200>> { + return this.rest.get(ROUTES.members(serverId)); } + /** + * Kick a member from a server + */ async kickMember( serverId: string, userId: string - ): Promise { - return this.rest.delete( - ROUTES.member(serverId, userId) - ); + ): Promise< + RestPayload["delete"], 204> + > { + return this.rest.delete(ROUTES.member(serverId, userId)); } /** @@ -713,10 +747,10 @@ export class Router { async banMember( serverId: string, userId: string - ): Promise { - return this.rest.post( - ROUTES.memberBan(serverId, userId) - ); + ): Promise< + RestPayload["post"], 200> + > { + return this.rest.post(ROUTES.memberBan(serverId, userId)); } /** @@ -725,10 +759,10 @@ export class Router { async getMemberBan( serverId: string, userId: string - ): Promise { - return this.rest.get( - ROUTES.memberBan(serverId, userId) - ); + ): Promise< + RestPayload["get"], 200> + > { + return this.rest.get(ROUTES.memberBan(serverId, userId)); } /** @@ -737,17 +771,19 @@ export class Router { async unbanMember( serverId: string, userId: string - ): Promise { - return this.rest.delete( - ROUTES.memberBan(serverId, userId) - ); + ): Promise< + RestPayload["delete"], 204> + > { + return this.rest.delete(ROUTES.memberBan(serverId, userId)); } /** * Get all bans in a server */ - async getMemberBans(serverId: string): Promise { - return this.rest.get(ROUTES.memberBans(serverId)); + async getMemberBans( + serverId: string + ): Promise["get"], 200>> { + return this.rest.get(ROUTES.memberBans(serverId)); } /** @@ -756,10 +792,10 @@ export class Router { async addMemberToGroup( groupId: string, userId: string - ): Promise { - return this.rest.put( - ROUTES.groupMember(groupId, userId) - ); + ): Promise< + RestPayload["put"], 204> + > { + return this.rest.put(ROUTES.groupMember(groupId, userId)); } /** @@ -768,10 +804,10 @@ export class Router { async removeMemberFromGroup( groupId: string, userId: string - ): Promise { - return this.rest.delete( - ROUTES.groupMember(groupId, userId) - ); + ): Promise< + RestPayload["delete"], 204> + > { + return this.rest.delete(ROUTES.groupMember(groupId, userId)); } /** @@ -781,10 +817,13 @@ export class Router { serverId: string, userId: string, roleId: number - ): Promise { - return this.rest.put( - ROUTES.memberRole(serverId, userId, roleId) - ); + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/members/{userId}/roles/{roleId}">["put"], + 204 + > + > { + return this.rest.put(ROUTES.memberRole(serverId, userId, roleId)); } /** @@ -794,10 +833,13 @@ export class Router { serverId: string, userId: string, roleId: number - ): Promise { - return this.rest.delete( - ROUTES.memberRole(serverId, userId, roleId) - ); + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/members/{userId}/roles/{roleId}">["delete"], + 204 + > + > { + return this.rest.delete(ROUTES.memberRole(serverId, userId, roleId)); } /** @@ -805,12 +847,11 @@ export class Router { */ async createWebhook( serverId: string, - options: RESTPostServerWebhooksBody - ): Promise { - return this.rest.post< - RESTPostServerWebhooksResult, - RESTPostServerWebhooksBody - >(ROUTES.serverWebhooks(serverId), options); + options: RestBody["post"]> + ): Promise< + RestPayload["post"], 201> + > { + return this.rest.post(ROUTES.serverWebhooks(serverId), options); } /** @@ -819,11 +860,13 @@ export class Router { async getWebhooks( serverId: string, channelId?: string - ): Promise { - return this.rest.get< - RESTGetServerWebhooksResult, - RESTGetServerWebhooksQuery - >(ROUTES.serverWebhooks(serverId), channelId ? { channelId } : undefined); + ): Promise< + RestPayload["get"], 200> + > { + return this.rest.get( + ROUTES.serverWebhooks(serverId), + channelId ? { query: { channelId } } : undefined + ); } /** @@ -832,10 +875,13 @@ export class Router { async getWebhook( serverId: string, webhookId: string - ): Promise { - return this.rest.get( - ROUTES.serverWebhook(serverId, webhookId) - ); + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/webhooks/{webhookId}">["get"], + 200 + > + > { + return this.rest.get(ROUTES.serverWebhook(serverId, webhookId)); } /** @@ -844,12 +890,16 @@ export class Router { async updateWebhook( serverId: string, webhookId: string, - options: RESTPutServerWebhookBody - ): Promise { - return this.rest.put( - ROUTES.serverWebhook(serverId, webhookId), - options - ); + options: RestBody< + RestPath<"/servers/{serverId}/webhooks/{webhookId}">["put"] + > + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/webhooks/{webhookId}">["put"], + 200 + > + > { + return this.rest.put(ROUTES.serverWebhook(serverId, webhookId), options); } /** @@ -858,9 +908,12 @@ export class Router { async deleteWebhook( serverId: string, webhookId: string - ): Promise { - return this.rest.delete( - ROUTES.serverWebhook(serverId, webhookId) - ); + ): Promise< + RestPayload< + RestPath<"/servers/{serverId}/webhooks/{webhookId}">["delete"], + 204 + > + > { + return this.rest.delete(ROUTES.serverWebhook(serverId, webhookId)); } } diff --git a/packages/rest/lib/util/routes.ts b/packages/rest/lib/util/routes.ts index 0d9eb844..8a78069e 100644 --- a/packages/rest/lib/util/routes.ts +++ b/packages/rest/lib/util/routes.ts @@ -1,4 +1,4 @@ -import type { UserSocialLink } from "@guildedjs/guilded-api-typings"; +import type { Schema, rest } from "@guildedjs/guilded-api-typings"; export const ROUTES = { // Channel Endpoints @@ -55,6 +55,8 @@ export const ROUTES = { `/channels/${channelId}/topics/${forumTopicId}` as const, forumTopicPin: (channelId: string, forumTopicId: string) => `/channels/${channelId}/topics/${forumTopicId}/pin` as const, + forumTopicLock: (channelId: string, forumTopicId: string) => + `/channels/${channelId}/topics/${forumTopicId}/lock` as const, // List Endpoints listItems: (channelId: string) => `/channels/${channelId}/items` as const, @@ -79,8 +81,11 @@ export const ROUTES = { `/servers/${serverId}/roles/${roleId}/xp` as const, // Social Links Endpoints - memberSocialLinks: (serverId: string, userId: string, type: UserSocialLink) => - `/servers/${serverId}/members/${userId}/social-links/${type}` as const, + memberSocialLinks: ( + serverId: string, + userId: string, + type: Schema<"SocialLink">["type"] + ) => `/servers/${serverId}/members/${userId}/social-links/${type}` as const, // Group Memberships Endpoints groupMember: (groupId: string, userId: string) => diff --git a/packages/rest/lib/webhook/WebhookEmbed.ts b/packages/rest/lib/webhook/WebhookEmbed.ts index 3ae44be0..e6e17bc2 100644 --- a/packages/rest/lib/webhook/WebhookEmbed.ts +++ b/packages/rest/lib/webhook/WebhookEmbed.ts @@ -2,366 +2,366 @@ import type { APIEmbed } from "@guildedjs/guilded-api-typings"; import { resolveColor } from "../util/color"; export class WebhookEmbed { - public title: string | null; - - public description: string | null; - - public url: string | null; - - public timestamp: number | null; - - public timestampString: string | null; - - public color: number | null; - - public footer: { - iconURL: string | null; - proxyIconURL: string | null; - text: string; - } | null; - - public image: APIWebhookEmbedMediaData | null; - - public thumbnail: APIWebhookEmbedMediaData | null; - - public video: APIWebhookEmbedMediaData | null; - - public provider: { - name: string | null; - url: string | null; - } | null; - - public author: { - iconURL: string | null; - name: string | null; - proxyIconURL: string | null; - url: string | null; - } | null; - - public fields: { - inline: boolean | null; - name: string; - value: string; - }[]; - - public constructor(data?: Partial) { - this.footer = null; - this.image = null; - this.thumbnail = null; - this.author = null; - this.fields = []; - this.video = null; - this.provider = null; - this.color = null; - this.timestamp = null; - this.timestampString = null; - this.description = null; - this.url = null; - this.title = null; - - if (data) this.update(data); - } - - /* istanbul ignore next */ - public update(data: Partial): void { - if ("color" in data && data.color !== undefined) { - this.setColor(data.color); - } - - if ("timestamp" in data && data.timestamp !== undefined) { - this.setTimestamp(data.timestamp); - } - - if ("title" in data && data.title !== undefined) { - this.setTitle(data.title); - } - - if ("description" in data && data.description !== undefined) { - this.setDescription(data.description); - } - - if ("url" in data && data.url !== undefined) { - this.setURL(data.url); - } - - if ("provider" in data && data.provider !== undefined) { - this.setProvider(data.provider.name, data.provider.url); - } - - if ("footer" in data && data.footer !== undefined) { - this.setFooter( - data.footer.text, - data.footer.icon_url, - data.footer.proxy_icon_url - ); - } - - if ("image" in data && data.image !== undefined) { - this.setImage( - data.image.url, - data.image.height, - data.image.width, - data.image.proxy_url - ); - } - - if ("thumbnail" in data && data.thumbnail !== undefined) { - this.setThumbnail( - data.thumbnail.url, - data.thumbnail.height, - data.thumbnail.width, - data.thumbnail.proxy_url - ); - } - - if ("author" in data && data.author !== undefined) { - this.setAuthor( - data.author.name, - data.author.icon_url, - data.author.url, - data.author.proxy_icon_url - ); - } - - if ("fields" in data && data.fields !== undefined) { - this.addFields(data.fields); - } - - if ("video" in data && data.video !== undefined) { - this.setVideo( - data.video.url, - data.video.height, - data.video.width, - data.video.proxy_url - ); - } - } - - public setTitle(title?: string | null): this { - this.title = title ?? null; - return this; - } - - public setDescription(description?: string | null): this { - this.description = description ?? null; - return this; - } - - public setURL(url?: string | null): this { - this.url = url ?? null; - return this; - } - - public setTimestamp(timestamp?: Date | number | string | null): this { - if (timestamp === null) { - this.timestamp = null; - this.timestampString = null; - return this; - } - - if (!timestamp) { - return this.setTimestamp(new Date()); - } - - const parsedTimestamp = - timestamp instanceof Date - ? timestamp - : Number.isInteger(timestamp) || typeof timestamp === "string" - ? new Date(timestamp) - : null; - if ( - !parsedTimestamp || - (parsedTimestamp instanceof Date && - Number.isNaN(parsedTimestamp.getTime())) - ) { - throw new TypeError("Invalid DateResolvable passed into setTimestamp."); - } - - this.timestamp = parsedTimestamp.getTime(); - this.timestampString = parsedTimestamp.toISOString(); - return this; - } - - public setColor( - color?: number | string | [number, number, number] | null - ): this { - this.color = color ? resolveColor(color) : null; - return this; - } - - public setFooter( - text?: string, - iconURL?: string | null, - proxyIconURL?: string | null - ): this { - this.footer = text - ? { iconURL: iconURL ?? null, proxyIconURL: proxyIconURL ?? null, text } - : null; - return this; - } - - public setImage( - url?: string, - height?: string | null, - width?: string | null, - proxyURL?: string | null - ): this { - this.image = url - ? { - height: height ?? null, - proxyURL: proxyURL ?? null, - url, - width: width ?? null, - } - : null; - return this; - } - - public setThumbnail( - url?: string, - height?: string | null, - width?: string | null, - proxyURL?: string | null - ): this { - this.thumbnail = url - ? { - height: height ?? null, - proxyURL: proxyURL ?? null, - url, - width: width ?? null, - } - : null; - return this; - } - - public setVideo( - url?: string, - height?: string | null, - width?: string | null, - proxyURL?: string | null - ): this { - this.video = url - ? { - height: height ?? null, - proxyURL: proxyURL ?? null, - url, - width: width ?? null, - } - : null; - return this; - } - - public setProvider(name?: string | null, url?: string | null): this { - this.provider = - name && url ? { name: name ?? null, url: url ?? null } : null; - return this; - } - - public setAuthor( - name?: string, - iconURL?: string | null, - url?: string | null, - proxyIconURL?: string | null - ): this { - this.author = name - ? { - iconURL: iconURL ?? null, - name: name ?? null, - proxyIconURL: proxyIconURL ?? null, - url: url ?? null, - } - : null; - return this; - } - - public addFields( - fields: { inline?: boolean; name: string; value: string }[] - ): this { - this.fields.push( - ...fields.map((field) => ({ - inline: field.inline ?? false, - name: field.name, - value: field.value, - })) - ); - return this; - } - - public addField(name: string, value: string, inline?: boolean): this { - this.addFields([{ inline, name, value }]); - return this; - } - - public clearFields(): this { - this.fields.length = 0; - return this; - } - - public toJSON(): APIEmbed { - return { - author: this.author?.name - ? { - icon_url: this.author.iconURL ?? undefined, - name: this.author.name, - proxy_icon_url: this.author.proxyIconURL ?? undefined, - url: this.author.url ?? undefined, - } - : undefined, - color: this.color ?? undefined, - description: this.description ?? undefined, - fields: - this.fields.map((field) => ({ - inline: field.inline ?? false, - name: field.name, - value: field.value, - })) ?? undefined, - footer: this.footer - ? { - icon_url: this.footer.iconURL ?? undefined, - proxy_icon_url: this.footer.proxyIconURL ?? undefined, - text: this.footer.text ?? undefined, - } - : undefined, - image: this.image - ? { - height: this.image.height ?? undefined, - proxy_url: this.image.proxyURL ?? undefined, - url: this.image.url ?? undefined, - width: this.image.width ?? undefined, - } - : undefined, - provider: this.provider - ? { - name: this.provider.name ?? undefined, - url: this.provider.url ?? undefined, - } - : undefined, - thumbnail: this.thumbnail - ? { - height: this.thumbnail.height ?? undefined, - proxy_url: this.thumbnail.proxyURL ?? undefined, - url: this.thumbnail.url ?? undefined, - width: this.thumbnail.width ?? undefined, - } - : undefined, - timestamp: this.timestampString ?? undefined, - title: this.title ?? undefined, - url: this.url ?? undefined, - video: this.video - ? { - height: this.video.height ?? undefined, - proxy_url: this.video.proxyURL ?? undefined, - url: this.video.url ?? undefined, - width: this.video.width ?? undefined, - } - : undefined, - }; - } + public title: string | null; + + public description: string | null; + + public url: string | null; + + public timestamp: number | null; + + public timestampString: string | null; + + public color: number | null; + + public footer: { + iconURL: string | null; + proxyIconURL: string | null; + text: string; + } | null; + + public image: APIWebhookEmbedMediaData | null; + + public thumbnail: APIWebhookEmbedMediaData | null; + + public video: APIWebhookEmbedMediaData | null; + + public provider: { + name: string | null; + url: string | null; + } | null; + + public author: { + iconURL: string | null; + name: string | null; + proxyIconURL: string | null; + url: string | null; + } | null; + + public fields: { + inline: boolean | null; + name: string; + value: string; + }[]; + + public constructor(data?: Partial) { + this.footer = null; + this.image = null; + this.thumbnail = null; + this.author = null; + this.fields = []; + this.video = null; + this.provider = null; + this.color = null; + this.timestamp = null; + this.timestampString = null; + this.description = null; + this.url = null; + this.title = null; + + if (data) this.update(data); + } + + /* istanbul ignore next */ + public update(data: Partial): void { + if ("color" in data && data.color !== undefined) { + this.setColor(data.color); + } + + if ("timestamp" in data && data.timestamp !== undefined) { + this.setTimestamp(data.timestamp); + } + + if ("title" in data && data.title !== undefined) { + this.setTitle(data.title); + } + + if ("description" in data && data.description !== undefined) { + this.setDescription(data.description); + } + + if ("url" in data && data.url !== undefined) { + this.setURL(data.url); + } + + if ("provider" in data && data.provider !== undefined) { + this.setProvider(data.provider.name, data.provider.url); + } + + if ("footer" in data && data.footer !== undefined) { + this.setFooter( + data.footer.text, + data.footer.icon_url, + data.footer.proxy_icon_url + ); + } + + if ("image" in data && data.image !== undefined) { + this.setImage( + data.image.url, + data.image.height, + data.image.width, + data.image.proxy_url + ); + } + + if ("thumbnail" in data && data.thumbnail !== undefined) { + this.setThumbnail( + data.thumbnail.url, + data.thumbnail.height, + data.thumbnail.width, + data.thumbnail.proxy_url + ); + } + + if ("author" in data && data.author !== undefined) { + this.setAuthor( + data.author.name, + data.author.icon_url, + data.author.url, + data.author.proxy_icon_url + ); + } + + if ("fields" in data && data.fields !== undefined) { + this.addFields(data.fields); + } + + if ("video" in data && data.video !== undefined) { + this.setVideo( + data.video.url, + data.video.height, + data.video.width, + data.video.proxy_url + ); + } + } + + public setTitle(title?: string | null): this { + this.title = title ?? null; + return this; + } + + public setDescription(description?: string | null): this { + this.description = description ?? null; + return this; + } + + public setURL(url?: string | null): this { + this.url = url ?? null; + return this; + } + + public setTimestamp(timestamp?: Date | number | string | null): this { + if (timestamp === null) { + this.timestamp = null; + this.timestampString = null; + return this; + } + + if (!timestamp) { + return this.setTimestamp(new Date()); + } + + const parsedTimestamp = + timestamp instanceof Date + ? timestamp + : Number.isInteger(timestamp) || typeof timestamp === "string" + ? new Date(timestamp) + : null; + if ( + !parsedTimestamp || + (parsedTimestamp instanceof Date && + Number.isNaN(parsedTimestamp.getTime())) + ) { + throw new TypeError("Invalid DateResolvable passed into setTimestamp."); + } + + this.timestamp = parsedTimestamp.getTime(); + this.timestampString = parsedTimestamp.toISOString(); + return this; + } + + public setColor( + color?: number | string | [number, number, number] | null + ): this { + this.color = color ? resolveColor(color) : null; + return this; + } + + public setFooter( + text?: string, + iconURL?: string | null, + proxyIconURL?: string | null + ): this { + this.footer = text + ? { iconURL: iconURL ?? null, proxyIconURL: proxyIconURL ?? null, text } + : null; + return this; + } + + public setImage( + url?: string, + height?: string | null, + width?: string | null, + proxyURL?: string | null + ): this { + this.image = url + ? { + height: height ?? null, + proxyURL: proxyURL ?? null, + url, + width: width ?? null, + } + : null; + return this; + } + + public setThumbnail( + url?: string, + height?: string | null, + width?: string | null, + proxyURL?: string | null + ): this { + this.thumbnail = url + ? { + height: height ?? null, + proxyURL: proxyURL ?? null, + url, + width: width ?? null, + } + : null; + return this; + } + + public setVideo( + url?: string, + height?: string | null, + width?: string | null, + proxyURL?: string | null + ): this { + this.video = url + ? { + height: height ?? null, + proxyURL: proxyURL ?? null, + url, + width: width ?? null, + } + : null; + return this; + } + + public setProvider(name?: string | null, url?: string | null): this { + this.provider = + name && url ? { name: name ?? null, url: url ?? null } : null; + return this; + } + + public setAuthor( + name?: string, + iconURL?: string | null, + url?: string | null, + proxyIconURL?: string | null + ): this { + this.author = name + ? { + iconURL: iconURL ?? null, + name: name ?? null, + proxyIconURL: proxyIconURL ?? null, + url: url ?? null, + } + : null; + return this; + } + + public addFields( + fields: { inline?: boolean; name: string; value: string }[] + ): this { + this.fields.push( + ...fields.map((field) => ({ + inline: field.inline ?? false, + name: field.name, + value: field.value, + })) + ); + return this; + } + + public addField(name: string, value: string, inline?: boolean): this { + this.addFields([{ inline, name, value }]); + return this; + } + + public clearFields(): this { + this.fields.length = 0; + return this; + } + + public toJSON(): APIEmbed { + return { + author: this.author?.name + ? { + icon_url: this.author.iconURL ?? undefined, + name: this.author.name, + proxy_icon_url: this.author.proxyIconURL ?? undefined, + url: this.author.url ?? undefined, + } + : undefined, + color: this.color ?? undefined, + description: this.description ?? undefined, + fields: + this.fields.map((field) => ({ + inline: field.inline ?? false, + name: field.name, + value: field.value, + })) ?? undefined, + footer: this.footer + ? { + icon_url: this.footer.iconURL ?? undefined, + proxy_icon_url: this.footer.proxyIconURL ?? undefined, + text: this.footer.text ?? undefined, + } + : undefined, + image: this.image + ? { + height: this.image.height ?? undefined, + proxy_url: this.image.proxyURL ?? undefined, + url: this.image.url ?? undefined, + width: this.image.width ?? undefined, + } + : undefined, + provider: this.provider + ? { + name: this.provider.name ?? undefined, + url: this.provider.url ?? undefined, + } + : undefined, + thumbnail: this.thumbnail + ? { + height: this.thumbnail.height ?? undefined, + proxy_url: this.thumbnail.proxyURL ?? undefined, + url: this.thumbnail.url ?? undefined, + width: this.thumbnail.width ?? undefined, + } + : undefined, + timestamp: this.timestampString ?? undefined, + title: this.title ?? undefined, + url: this.url ?? undefined, + video: this.video + ? { + height: this.video.height ?? undefined, + proxy_url: this.video.proxyURL ?? undefined, + url: this.video.url ?? undefined, + width: this.video.width ?? undefined, + } + : undefined, + }; + } } export type APIWebhookEmbedMediaData = { - height: string | null; - proxyURL: string | null; - url: string; - width: string | null; + height: string | null; + proxyURL: string | null; + url: string; + width: string | null; }; diff --git a/packages/ws/lib/WebSocketManager.ts b/packages/ws/lib/WebSocketManager.ts index 5706c604..4cf7b966 100644 --- a/packages/ws/lib/WebSocketManager.ts +++ b/packages/ws/lib/WebSocketManager.ts @@ -1,9 +1,12 @@ /* eslint-disable @typescript-eslint/no-base-to-string */ import { EventEmitter } from "node:events"; import type { + ClientUserData, SkeletonWSPayload, + ws, WSEvent, - WSWelcomePayload, + WSEventNames, + WSPayload, } from "@guildedjs/guilded-api-typings"; import { WSOpCodes } from "@guildedjs/guilded-api-typings"; import type TypedEmitter from "typed-emitter"; @@ -192,13 +195,16 @@ export class WebSocketManager { case WSOpCodes.SUCCESS: this.emitter.emit( "gatewayEvent", - EVENT_NAME as keyof WSEvent, + EVENT_NAME as WSEventNames, EVENT_DATA ); break; // Auto handled by ws lib case WSOpCodes.WELCOME: - this.emitter.emit("ready", (EVENT_DATA as WSWelcomePayload).d.user); + this.emitter.emit( + "ready", + (EVENT_DATA.d as WSPayload<"_WelcomeMessage">).user as ClientUserData + ); break; case WSOpCodes.RESUME: this.lastMessageId = null; @@ -261,7 +267,12 @@ export type WebsocketManagerEvents = { exit(info: string): unknown; gatewayEvent(event: keyof WSEvent, data: SkeletonWSPayload): unknown; raw(data: any): unknown; - ready(user: WSWelcomePayload["d"]["user"]): unknown; + ready( + user: WSPayload<"_WelcomeMessage">["user"] & { + createdBy: string; + botId: string; + } + ): unknown; reconnect(): unknown; unknown(reason: string, data: any): unknown; }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4a7beadb..0f246cf9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,8 +96,10 @@ importers: packages/guilded-api-typings: specifiers: + openapi-typescript: ^6.2.4 typescript: 5.0.4 devDependencies: + openapi-typescript: 6.2.4 typescript: 5.0.4 packages/guilded.js: @@ -1612,6 +1614,13 @@ packages: semver: 7.4.0 dev: true + /busboy/1.6.0: + resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} + engines: {node: '>=10.16.0'} + dependencies: + streamsearch: 1.1.0 + dev: true + /bytesish/0.4.4: resolution: {integrity: sha512-i4uu6M4zuMUiyfZN4RU2+i9+peJh//pXhd9x1oSe1LBkZ3LEbCoygu8W0bXTukU1Jme2txKuotpCZRaC3FLxcQ==} dev: true @@ -4134,6 +4143,18 @@ packages: is-wsl: 2.2.0 dev: true + /openapi-typescript/6.2.4: + resolution: {integrity: sha512-P/VK7oJ3TnIS67o1UzuS1pMnry4mzNzeQG0ZjLdPGT04mN9FeeTgHw1bN6MiANFN0tO6BcRavSL5tUFAh6iiwg==} + hasBin: true + dependencies: + ansi-colors: 4.1.3 + fast-glob: 3.2.12 + js-yaml: 4.1.0 + supports-color: 9.3.1 + undici: 5.22.0 + yargs-parser: 21.1.1 + dev: true + /optionator/0.9.1: resolution: {integrity: sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==} engines: {node: '>= 0.8.0'} @@ -4943,6 +4964,11 @@ packages: mixme: 0.5.9 dev: true + /streamsearch/1.1.0: + resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} + engines: {node: '>=10.0.0'} + dev: true + /string-argv/0.3.1: resolution: {integrity: sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==} engines: {node: '>=0.6.19'} @@ -5106,6 +5132,11 @@ packages: has-flag: 4.0.0 dev: true + /supports-color/9.3.1: + resolution: {integrity: sha512-knBY82pjmnIzK3NifMo3RxEIRD9E0kIzV4BKcyTZ9+9kWgLMxd4PrsTSMoFQUabgRBbF8KOLRDCyKgNV+iK44Q==} + engines: {node: '>=12'} + dev: true + /supports-preserve-symlinks-flag/1.0.0: resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} engines: {node: '>= 0.4'} @@ -5405,6 +5436,13 @@ packages: resolution: {integrity: sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==} dev: true + /undici/5.22.0: + resolution: {integrity: sha512-fR9RXCc+6Dxav4P9VV/sp5w3eFiSdOjJYsbtWfd4s5L5C4ogyuVpdKIVHeW0vV1MloM65/f7W45nR9ZxwVdyiA==} + engines: {node: '>=14.0'} + dependencies: + busboy: 1.6.0 + dev: true + /universalify/0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'}