diff --git a/assets/openapi.json b/assets/openapi.json index 25833b9..3046048 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -2006,6 +2006,97 @@ "valid_rules_channel" ] }, + "MessageSnapshot": { + "type": "object", + "properties": { + "message": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "edited_timestamp": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ] + }, + "mentions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PartialUser" + } + }, + "mention_roles": { + "type": "array", + "items": { + "type": "string" + } + }, + "attachments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PublicAttachment" + } + }, + "embeds": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Embed" + } + }, + "type": { + "$ref": "#/components/schemas/MessageType" + }, + "flags": { + "type": "integer" + }, + "components": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MessageComponent" + } + }, + "resolved": { + "type": "array", + "items": { + "type": "object", + "properties": {}, + "additionalProperties": true + } + }, + "sticker_items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Sticker" + } + } + }, + "additionalProperties": false, + "required": [ + "content", + "embeds", + "flags", + "mention_roles", + "mentions", + "timestamp", + "type" + ] + } + }, + "required": [ + "message" + ] + }, "GuildMessagesSearchResponse": { "type": "object", "properties": { @@ -12300,97 +12391,6 @@ "me_voted" ] }, - "MessageSnapshot": { - "type": "object", - "properties": { - "message": { - "type": "object", - "properties": { - "content": { - "type": "string" - }, - "timestamp": { - "type": "string", - "format": "date-time" - }, - "edited_timestamp": { - "anyOf": [ - { - "type": "string", - "format": "date-time" - }, - { - "type": "null" - } - ] - }, - "mentions": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PartialUser" - } - }, - "mention_roles": { - "type": "array", - "items": { - "type": "string" - } - }, - "attachments": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Attachment" - } - }, - "embeds": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Embed" - } - }, - "type": { - "$ref": "#/components/schemas/MessageType" - }, - "flags": { - "type": "integer" - }, - "components": { - "type": "array", - "items": { - "$ref": "#/components/schemas/MessageComponent" - } - }, - "resolved": { - "type": "array", - "items": { - "type": "object", - "properties": {}, - "additionalProperties": true - } - }, - "sticker_items": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Sticker" - } - } - }, - "additionalProperties": false, - "required": [ - "content", - "embeds", - "flags", - "mention_roles", - "mentions", - "timestamp", - "type" - ] - } - }, - "required": [ - "message" - ] - }, "PartialUser": { "type": "object", "properties": { @@ -12477,6 +12477,38 @@ "username" ] }, + "PublicAttachment": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "content_type": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + } + }, + "required": [ + "filename", + "proxy_url", + "size", + "url" + ] + }, "MessageComponent": { "type": "object", "properties": { @@ -13073,7 +13105,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/components/schemas/Attachment" + "$ref": "#/components/schemas/PublicAttachment" } }, "embeds": { @@ -13223,6 +13255,38 @@ "username" ] }, + "PublicAttachment_1": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "content_type": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + } + }, + "required": [ + "filename", + "proxy_url", + "size", + "url" + ] + }, "GuildVanityUrl": { "type": "object", "properties": { diff --git a/assets/schemas.json b/assets/schemas.json index a7acf2b..2cf6a93 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -2148,6 +2148,100 @@ "messages", "total_results" ], + "definitions": { + "MessageSnapshot": { + "type": "object", + "properties": { + "message": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "edited_timestamp": { + "anyOf": [ + { + "type": "string", + "format": "date-time" + }, + { + "type": "null" + } + ] + }, + "mentions": { + "type": "array", + "items": { + "$ref": "#/definitions/PartialUser" + } + }, + "mention_roles": { + "type": "array", + "items": { + "type": "string" + } + }, + "attachments": { + "type": "array", + "items": { + "$ref": "#/definitions/PublicAttachment_1" + } + }, + "embeds": { + "type": "array", + "items": { + "$ref": "#/definitions/Embed" + } + }, + "type": { + "$ref": "#/definitions/MessageType" + }, + "flags": { + "type": "integer" + }, + "components": { + "type": "array", + "items": { + "$ref": "#/definitions/MessageComponent" + } + }, + "resolved": { + "type": "array", + "items": { + "type": "object", + "properties": {}, + "additionalProperties": true + } + }, + "sticker_items": { + "type": "array", + "items": { + "$ref": "#/definitions/Sticker" + } + } + }, + "additionalProperties": false, + "required": [ + "content", + "embeds", + "flags", + "mention_roles", + "mentions", + "timestamp", + "type" + ] + } + }, + "additionalProperties": false, + "required": [ + "message" + ] + } + }, "$schema": "http://json-schema.org/draft-07/schema#" }, "GuildPruneResponse": { @@ -13093,7 +13187,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/definitions/Attachment" + "$ref": "#/definitions/PublicAttachment" } }, "embeds": { @@ -13243,6 +13337,40 @@ ], "$schema": "http://json-schema.org/draft-07/schema#" }, + "PublicAttachment": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "content_type": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "filename", + "proxy_url", + "size", + "url" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, "MessageComponent": { "type": "object", "properties": { @@ -13872,7 +14000,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/definitions/Attachment" + "$ref": "#/definitions/PublicAttachment" } }, "embeds": { @@ -14028,6 +14156,40 @@ ], "$schema": "http://json-schema.org/draft-07/schema#" }, + "PublicAttachment_1": { + "type": "object", + "properties": { + "filename": { + "type": "string" + }, + "size": { + "type": "integer" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + }, + "content_type": { + "type": "string" + }, + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "filename", + "proxy_url", + "size", + "url" + ], + "$schema": "http://json-schema.org/draft-07/schema#" + }, "GuildVanityUrl": { "type": "object", "properties": { diff --git a/src/schemas/api/messages/Message.ts b/src/schemas/api/messages/Message.ts index ee2b9a8..f99f2b1 100644 --- a/src/schemas/api/messages/Message.ts +++ b/src/schemas/api/messages/Message.ts @@ -16,7 +16,7 @@ along with this program. If not, see . */ -import { Attachment, Sticker } from "@spacebar/util"; +import { Sticker } from "@spacebar/util"; import { Embed, MessageActivity, MessageComponent, PartialUser, Poll, PublicChannel, Snowflake } from "@spacebar/schemas"; import { PublicAttachment } from "./Attachments"; @@ -151,7 +151,7 @@ edited_timestamp?: Date | null; mentions: PartialUser[]; mention_roles: Snowflake[]; - attachments?: Attachment[]; + attachments?: PublicAttachment[]; embeds: Embed[]; type: MessageType; flags: number; diff --git a/src/schemas/responses/AccountStandingResponse.ts b/src/schemas/responses/AccountStandingResponse.ts index 6f29ebe..c1f603b 100644 --- a/src/schemas/responses/AccountStandingResponse.ts +++ b/src/schemas/responses/AccountStandingResponse.ts @@ -16,8 +16,7 @@ along with this program. If not, see . */ -// TODO: remove dependency on entities... -import { Attachment } from "@spacebar/util"; +import { PublicAttachment } from "../api/messages/Attachments"; export enum AccountStandingState { ALL_GOOD = 100, @@ -114,7 +113,7 @@ type: "message"; id: string; content: string; - attachments: Attachment[]; + attachments: PublicAttachment[]; } export interface Classification { diff --git a/src/schemas/responses/GuildMessagesSearchResponse.ts b/src/schemas/responses/GuildMessagesSearchResponse.ts index 8627b3f..e498f8b 100644 --- a/src/schemas/responses/GuildMessagesSearchResponse.ts +++ b/src/schemas/responses/GuildMessagesSearchResponse.ts @@ -17,8 +17,9 @@ */ // TODO: remove dependency on entities -import { Attachment, Role } from "@spacebar/util"; +import { Role } from "@spacebar/util"; import { BaseMessageComponents, Embed, MessageType, Poll, PublicUser } from "@spacebar/schemas"; +import { PublicAttachment } from "../api/messages/Attachments"; export interface GuildMessagesSearchMessage { id: string; @@ -26,7 +27,7 @@ content?: string; channel_id: string; author: PublicUser; - attachments: Attachment[]; + attachments: PublicAttachment[]; embeds: Embed[]; mentions: PublicUser[]; mention_roles: Role[]; diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts index 217f1da..c2628e2 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts @@ -331,7 +331,7 @@ toSnapshot(): MessageSnapshot { return { message: { - attachments: this.attachments, + attachments: this.attachments?.map((x) => x.toJSON()), components: this.components, content: this.content!, edited_timestamp: this.edited_timestamp,