From e7a98b6c46e3d4fdaa68bd8a04ffcf53a9dac184 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Thu, 18 Jul 2024 12:42:07 +0200 Subject: [PATCH] webhook fixes & username/avatar property for msg --- assets/openapi.json | 416 +++++++- assets/schemas.json | 903 ++++++++++++++++++ .../webhooks/#webhook_id/#token/index.ts | 25 +- src/api/util/handlers/Message.ts | 119 ++- src/util/entities/Message.ts | 19 +- src/util/entities/Webhook.ts | 8 +- .../1721298824927-webhookMessageProperties.ts | 15 + .../1721298824927-webhookMessageProperties.ts | 15 + .../1721298824927-webhookMessageProperties.ts | 15 + 9 files changed, 1459 insertions(+), 76 deletions(-) create mode 100644 src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts create mode 100644 src/util/migration/mysql/1721298824927-webhookMessageProperties.ts create mode 100644 src/util/migration/postgres/1721298824927-webhookMessageProperties.ts diff --git a/assets/openapi.json b/assets/openapi.json index 19686c59..6860c21b 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -1127,12 +1127,19 @@ "type": "boolean", "default": false }, + "channel_ordering": { + "type": "array", + "items": { + "type": "string" + } + }, "id": { "type": "string" } }, "required": [ "bans", + "channel_ordering", "channels", "emojis", "features", @@ -1203,9 +1210,6 @@ "default_auto_archive_duration": { "type": "integer" }, - "position": { - "type": "integer" - }, "permission_overwrites": { "type": "array", "items": { @@ -1272,6 +1276,10 @@ "type": "integer", "default": 0 }, + "position": { + "description": "Must be calculated Channel.calculatePosition", + "type": "integer" + }, "id": { "type": "string" } @@ -1280,11 +1288,11 @@ "created_at", "default_thread_rate_limit_per_user", "flags", - "guild", "id", "nsfw", "owner", "parent_id", + "position", "type" ] }, @@ -2138,7 +2146,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/components/schemas/Attachment_1" + "$ref": "#/components/schemas/Attachment" } }, "embeds": { @@ -2324,7 +2332,6 @@ } }, "required": [ - "avatar", "banner", "bio", "communication_disabled_until", @@ -2889,7 +2896,7 @@ ], "type": "number" }, - "Attachment_1": { + "Attachment": { "type": "object", "properties": { "filename": { @@ -3394,7 +3401,7 @@ "attachments": { "type": "array", "items": { - "$ref": "#/components/schemas/Attachment_1" + "$ref": "#/components/schemas/Attachment" } }, "embeds": { @@ -3473,6 +3480,9 @@ "type": "string", "format": "date-time" }, + "avatar": { + "type": "string" + }, "username": { "type": "string" }, @@ -3482,9 +3492,6 @@ "public_flags": { "type": "integer" }, - "avatar": { - "type": "string" - }, "accent_color": { "type": "integer" }, @@ -3721,6 +3728,9 @@ "banner": { "type": "string" }, + "description": { + "type": "string" + }, "unavailable": { "type": "boolean" }, @@ -3757,9 +3767,6 @@ "default_message_notifications": { "type": "integer" }, - "description": { - "type": "string" - }, "discovery_splash": { "type": "string" }, @@ -3852,12 +3859,19 @@ }, "premium_progress_bar_enabled": { "type": "boolean" + }, + "channel_ordering": { + "type": "array", + "items": { + "type": "string" + } } }, "required": [ "_do_validate", "assign", "bans", + "channel_ordering", "channels", "emojis", "features", @@ -5081,6 +5095,9 @@ "content": { "type": "string" }, + "mobile_network_type": { + "type": "string" + }, "nonce": { "type": "string" }, @@ -5191,6 +5208,10 @@ "items": { "type": "string" } + }, + "components": { + "type": "array", + "items": {} } } }, @@ -5218,6 +5239,9 @@ "content": { "type": "string" }, + "mobile_network_type": { + "type": "string" + }, "nonce": { "type": "string" }, @@ -5310,6 +5334,10 @@ "items": { "type": "string" } + }, + "components": { + "type": "array", + "items": {} } } }, @@ -5834,6 +5862,16 @@ "UserSettingsSchema": { "type": "object", "properties": { + "status": { + "enum": [ + "dnd", + "idle", + "invisible", + "offline", + "online" + ], + "type": "string" + }, "afk_timeout": { "type": "integer" }, @@ -5931,16 +5969,6 @@ "show_current_game": { "type": "boolean" }, - "status": { - "enum": [ - "dnd", - "idle", - "invisible", - "offline", - "online" - ], - "type": "string" - }, "stream_notifications_enabled": { "type": "boolean" }, @@ -6181,6 +6209,107 @@ "name" ] }, + "WebhookExecuteSchema": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "username": { + "type": "string" + }, + "avatar_url": { + "type": "string" + }, + "tts": { + "type": "boolean" + }, + "embeds": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Embed" + } + }, + "allowed_mentions": { + "type": "object", + "properties": { + "parse": { + "type": "array", + "items": { + "type": "string" + } + }, + "roles": { + "type": "array", + "items": { + "type": "string" + } + }, + "users": { + "type": "array", + "items": { + "type": "string" + } + }, + "replied_user": { + "type": "boolean" + } + }, + "additionalProperties": false + }, + "components": { + "type": "array", + "items": {} + }, + "file": { + "type": "object", + "properties": { + "filename": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "filename" + ] + }, + "payload_json": { + "type": "string" + }, + "attachments": { + "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "filename": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "filename", + "id" + ] + } + }, + "flags": { + "type": "integer" + }, + "thread_name": { + "type": "string" + }, + "applied_tags": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "WidgetModifySchema": { "type": "object", "properties": { @@ -6960,6 +7089,9 @@ "type": "string", "format": "date-time" }, + "avatar": { + "type": "string" + }, "verified": { "type": "boolean" }, @@ -6972,9 +7104,6 @@ "public_flags": { "type": "integer" }, - "avatar": { - "type": "string" - }, "accent_color": { "type": "integer" }, @@ -7077,6 +7206,9 @@ "type": "string", "format": "date-time" }, + "avatar": { + "type": "string" + }, "verified": { "type": "boolean" }, @@ -7089,9 +7221,6 @@ "public_flags": { "type": "integer" }, - "avatar": { - "type": "string" - }, "accent_color": { "type": "integer" }, @@ -7305,6 +7434,9 @@ "premium_since": { "type": "integer" }, + "avatar": { + "type": "string" + }, "user": { "$ref": "#/components/schemas/PublicUser" }, @@ -7533,12 +7665,19 @@ "type": "boolean", "default": false }, + "channel_ordering": { + "type": "array", + "items": { + "type": "string" + } + }, "id": { "type": "string" } }, "required": [ "bans", + "channel_ordering", "channels", "emojis", "features", @@ -7737,6 +7876,9 @@ "premium_since": { "type": "integer" }, + "avatar": { + "type": "string" + }, "user": { "$ref": "#/components/schemas/PublicUser" }, @@ -8037,9 +8179,175 @@ }, { "name": "voice" + }, + { + "name": "webhooks" } ], "paths": { + "/webhooks/{webhook_id}/": { + "get": { + "security": [ + { + "bearer": [] + } + ], + "description": "Returns a webhook object for the given id.", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIWebhook" + } + } + } + }, + "404": { + "description": "No description available" + } + }, + "parameters": [ + { + "name": "webhook_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + }, + "description": "webhook_id" + } + ], + "tags": [ + "webhooks" + ] + } + }, + "/webhooks/{webhook_id}/{token}/": { + "get": { + "security": [ + { + "bearer": [] + } + ], + "description": "Returns a webhook object for the given id.", + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIWebhook" + } + } + } + }, + "404": { + "description": "No description available" + } + }, + "parameters": [ + { + "name": "webhook_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + }, + "description": "webhook_id" + }, + { + "name": "token", + "in": "path", + "required": true, + "schema": { + "type": "string" + }, + "description": "token" + } + ], + "tags": [ + "webhooks" + ] + }, + "post": { + "security": [ + { + "bearer": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WebhookExecuteSchema" + } + } + } + }, + "responses": { + "204": { + "description": "No description available" + }, + "400": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIErrorResponse" + } + } + } + }, + "404": { + "description": "No description available" + } + }, + "parameters": [ + { + "name": "webhook_id", + "in": "path", + "required": true, + "schema": { + "type": "string" + }, + "description": "webhook_id" + }, + { + "name": "token", + "in": "path", + "required": true, + "schema": { + "type": "string" + }, + "description": "token" + }, + { + "name": "wait", + "in": "query", + "required": false, + "schema": { + "type": "boolean" + }, + "description": "waits for server confirmation of message send before response, and returns the created message body" + }, + { + "name": "thread_id", + "in": "query", + "required": false, + "schema": { + "type": "string" + }, + "description": "Send a message to the specified thread within a webhook's channel." + } + ], + "tags": [ + "webhooks" + ] + } + }, "/voice/regions/": { "get": { "security": [ @@ -10189,6 +10497,15 @@ } } }, + "parameters": [ + { + "name": "client_id", + "in": "query", + "schema": { + "type": "string" + } + } + ], "tags": [ "oauth2" ] @@ -10265,6 +10582,30 @@ ] } }, + "/oauth2/applications/@me/": { + "get": { + "security": [ + { + "bearer": [] + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Application" + } + } + } + } + }, + "tags": [ + "oauth2" + ] + } + }, "/invites/{code}": { "get": { "security": [ @@ -10879,14 +11220,23 @@ }, "/guilds/{guild_id}/webhooks/": { "get": { + "x-permission-required": "MANAGE_WEBHOOKS", "security": [ { "bearer": [] } ], + "description": "Returns a list of guild webhook objects. Requires the MANAGE_WEBHOOKS permission.", "responses": { - "default": { - "description": "No description available" + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/APIWebhookArray" + } + } + } } }, "parameters": [ @@ -14363,11 +14713,13 @@ }, "/channels/{channel_id}/webhooks/": { "get": { + "x-permission-required": "MANAGE_WEBHOOKS", "security": [ { "bearer": [] } ], + "description": "Returns a list of channel webhook objects. Requires the MANAGE_WEBHOOKS permission.", "responses": { "200": { "description": "", diff --git a/assets/schemas.json b/assets/schemas.json index 018ddaca..39961d30 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -2379,6 +2379,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -2704,6 +2710,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -6598,6 +6605,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -6923,6 +6936,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -10817,6 +10831,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -11142,6 +11162,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -15031,6 +15052,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -15356,6 +15383,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -19281,6 +19309,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -19606,6 +19640,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -23500,6 +23535,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -23825,6 +23866,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -27710,6 +27752,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -28035,6 +28083,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -31923,6 +31972,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -32248,6 +32303,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -36145,6 +36201,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -36470,6 +36532,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -40355,6 +40418,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -40680,6 +40749,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -44565,6 +44635,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -44890,6 +44966,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -48794,6 +48871,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -49119,6 +49202,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -53007,6 +53091,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -53332,6 +53422,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -57280,6 +57371,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -57605,6 +57702,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -61512,6 +61610,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -61837,6 +61941,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -65885,6 +65990,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -66210,6 +66321,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -70116,6 +70228,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -70441,6 +70559,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -74357,6 +74476,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -74682,6 +74807,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -78580,6 +78706,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -78905,6 +79037,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -82809,6 +82942,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -83134,6 +83273,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -87028,6 +87168,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -87353,6 +87499,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -91235,6 +91382,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -91560,6 +91713,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -95560,6 +95714,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -95885,6 +96045,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -99882,6 +100043,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -100207,6 +100374,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -104092,6 +104260,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -104417,6 +104591,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -108310,6 +108485,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -108635,6 +108816,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -112521,6 +112703,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -112846,6 +113034,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -116732,6 +116921,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -117057,6 +117252,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -120978,6 +121174,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -121303,6 +121505,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -125189,6 +125392,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -125514,6 +125723,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -129399,6 +129609,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -129724,6 +129940,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -133624,6 +133841,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -133949,6 +134172,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -137838,6 +138062,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -138163,6 +138393,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -142126,6 +142357,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -142451,6 +142688,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -146336,6 +146574,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -146661,6 +146905,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -150546,6 +150791,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -150871,6 +151122,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -154753,6 +155005,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -155078,6 +155336,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -158966,6 +159225,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -159291,6 +159556,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -163189,6 +163455,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -163514,6 +163786,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -167396,6 +167669,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -167721,6 +168000,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -171652,6 +171932,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -171977,6 +172263,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -175894,6 +176181,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -176219,6 +176512,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -180101,6 +180395,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -180426,6 +180726,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -184333,6 +184634,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -184658,6 +184965,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -188654,6 +188962,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -188979,6 +189293,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -192860,6 +193175,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -193185,6 +193506,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -197105,6 +197427,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -197430,6 +197758,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -201338,6 +201667,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -201663,6 +201998,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -205623,6 +205959,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -205948,6 +206290,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -209830,6 +210173,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -210155,6 +210504,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -214045,6 +214395,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -214370,6 +214726,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -218250,6 +218607,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -218575,6 +218938,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -222461,6 +222825,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -222786,6 +223156,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -226672,6 +227043,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -226997,6 +227374,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -230969,6 +231347,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -231294,6 +231678,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -235180,6 +235565,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -235505,6 +235896,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -239423,6 +239815,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -239748,6 +240146,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -243638,6 +244037,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -243963,6 +244368,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -247843,6 +248249,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -248168,6 +248580,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -252054,6 +252467,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -252379,6 +252798,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -256276,6 +256696,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -256601,6 +257027,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -260512,6 +260939,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -260837,6 +261270,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -264719,6 +265153,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -265044,6 +265484,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -268929,6 +269370,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -269254,6 +269701,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -273168,6 +273616,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -273493,6 +273947,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -277375,6 +277830,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -277700,6 +278161,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -281661,6 +282123,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -281986,6 +282454,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -285875,6 +286344,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -286200,6 +286675,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -290082,6 +290558,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -290407,6 +290889,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -294289,6 +294772,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -294614,6 +295103,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -298503,6 +298993,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -298828,6 +299324,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -302714,6 +303211,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -303039,6 +303542,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -306921,6 +307425,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -307246,6 +307756,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -311203,6 +311714,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -311528,6 +312045,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -315421,6 +315939,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -315746,6 +316270,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -319640,6 +320165,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -319965,6 +320496,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -323909,6 +324441,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -324234,6 +324772,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -328137,6 +328676,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -328462,6 +329007,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -332371,6 +332917,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -332696,6 +333248,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -336599,6 +337152,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -336924,6 +337483,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -340806,6 +341366,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -341131,6 +341697,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -345041,6 +345608,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -345366,6 +345939,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -349288,6 +349862,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -349613,6 +350193,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -353489,6 +354070,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -353814,6 +354401,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -357700,6 +358288,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -358025,6 +358619,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -361907,6 +362502,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -362232,6 +362833,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -366121,6 +366723,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -366446,6 +367054,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -370539,6 +371148,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -370864,6 +371479,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -374737,6 +375353,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -375062,6 +375684,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -379029,6 +379652,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -379354,6 +379983,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -383230,6 +383860,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -383555,6 +384191,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -387431,6 +388068,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -387756,6 +388399,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -391632,6 +392276,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -391957,6 +392607,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -395927,6 +396578,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -396252,6 +396909,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -400126,6 +400784,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -400451,6 +401115,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -404325,6 +404990,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -404650,6 +405321,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -408524,6 +409196,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -408849,6 +409527,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -412725,6 +413404,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -413050,6 +413735,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -416926,6 +417612,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -417251,6 +417943,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -421127,6 +421820,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -421452,6 +422151,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -425328,6 +426028,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -425653,6 +426359,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -429529,6 +430236,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -429854,6 +430567,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -433794,6 +434508,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -434119,6 +434839,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -437995,6 +438716,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -438320,6 +439047,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -442196,6 +442924,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -442521,6 +443255,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -446397,6 +447132,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -446722,6 +447463,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -450645,6 +451387,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -450970,6 +451718,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -455082,6 +455831,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -455407,6 +456162,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -459283,6 +460039,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -459608,6 +460370,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -463484,6 +464247,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -463809,6 +464578,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -467685,6 +468455,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -468010,6 +468786,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -471886,6 +472663,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -472211,6 +472994,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -476113,6 +476897,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -476438,6 +477228,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -480314,6 +481105,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -480639,6 +481436,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -484536,6 +485334,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -484861,6 +485665,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -488751,6 +489556,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -489076,6 +489887,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -493078,6 +493890,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -493403,6 +494221,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -497297,6 +498116,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -497622,6 +498447,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -501522,6 +502348,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -501847,6 +502679,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -505733,6 +506566,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -506058,6 +506897,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -509944,6 +510784,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -510269,6 +511115,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -514142,6 +514989,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -514467,6 +515320,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -518352,6 +519206,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -518677,6 +519537,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -522577,6 +523438,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -522902,6 +523769,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -526806,6 +527674,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -527131,6 +528005,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -531014,6 +531889,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -531339,6 +532220,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -535221,6 +536103,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -535546,6 +536434,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -539428,6 +540317,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -539753,6 +540648,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", @@ -543641,6 +544537,12 @@ "$ref": "#/definitions/MessageComponent" } }, + "username": { + "type": "string" + }, + "avatar": { + "type": "string" + }, "id": { "type": "string" } @@ -543966,6 +544868,7 @@ "guild", "guild_id", "id", + "name", "source_guild", "source_guild_id", "type", diff --git a/src/api/routes/webhooks/#webhook_id/#token/index.ts b/src/api/routes/webhooks/#webhook_id/#token/index.ts index b47502b4..538ee181 100644 --- a/src/api/routes/webhooks/#webhook_id/#token/index.ts +++ b/src/api/routes/webhooks/#webhook_id/#token/index.ts @@ -1,12 +1,14 @@ -import { handleMessage, route } from "@spacebar/api"; +import { handleMessage, postHandleMessage, route } from "@spacebar/api"; import { Attachment, Config, DiscordApiErrors, FieldErrors, Message, + MessageCreateEvent, Webhook, WebhookExecuteSchema, + emitEvent, uploadFile, } from "@spacebar/util"; import { Request, Response, Router } from "express"; @@ -93,7 +95,11 @@ router.post( }, }), async (req: Request, res: Response) => { + const { wait, thread_id } = req.query; + if (!wait) return res.status(204).send(); + const { webhook_id, token } = req.params; + const body = req.body as WebhookExecuteSchema; const attachments: Attachment[] = []; @@ -200,6 +206,7 @@ router.post( webhook_id: webhook.id, application_id: webhook.application?.id, embeds, + // TODO: Support thread_id/thread_name once threads are implemented channel_id: webhook.channel_id, attachments, timestamp: new Date(), @@ -209,6 +216,22 @@ router.post( message.edited_timestamp = null; webhook.channel.last_message_id = message.id; + + await Promise.all([ + message.save(), + emitEvent({ + event: "MESSAGE_CREATE", + channel_id: webhook.channel_id, + data: message, + } as MessageCreateEvent), + ]); + + // no await as it shouldnt block the message send function and silently catch error + postHandleMessage(message).catch((e) => + console.error("[Message] post-message handler failed", e), + ); + + return res.json(message); }, ); diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index 6172a3d0..18616506 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -41,11 +41,13 @@ import { Sticker, MessageCreateSchema, EmbedCache, + handleFile, } from "@spacebar/util"; import { HTTPError } from "lambert-server"; import { In } from "typeorm"; import { EmbedHandlers } from "@spacebar/api"; import * as Sentry from "@sentry/node"; +import fetch from "node-fetch"; const allow_empty = false; // TODO: check webhook, application, system author, stickers // TODO: embed gifs/videos/images @@ -92,44 +94,89 @@ export async function handleMessage(opts: MessageOptions): Promise { where: { id: opts.application_id }, }); } + + let permission: any; if (opts.webhook_id) { message.webhook = await Webhook.findOneOrFail({ where: { id: opts.webhook_id }, }); - } - const permission = await getPermission( - opts.author_id, - channel.guild_id, - opts.channel_id, - ); - permission.hasThrow("SEND_MESSAGES"); - if (permission.cache.member) { - message.member = permission.cache.member; - } + message.author = (await User.findOne({ + where: { id: opts.webhook_id }, + })) || undefined; - if (opts.tts) permission.hasThrow("SEND_TTS_MESSAGES"); - if (opts.message_reference) { - permission.hasThrow("READ_MESSAGE_HISTORY"); - // code below has to be redone when we add custom message routing - if (message.guild_id !== null) { - const guild = await Guild.findOneOrFail({ - where: { id: channel.guild_id }, + if (!message.author) { + message.author = User.create({ + id: opts.webhook_id, + username: message.webhook.name, + discriminator: "0000", + avatar: message.webhook.avatar, + public_flags: 0, + premium: false, + premium_type: 0, + bot: true, + created_at: new Date(), + verified: true, + rights: "0", + data: { + valid_tokens_since: new Date(), + }, }); - if (!guild.features.includes("CROSS_CHANNEL_REPLIES")) { - if (opts.message_reference.guild_id !== channel.guild_id) - throw new HTTPError( - "You can only reference messages from this guild", - ); - if (opts.message_reference.channel_id !== opts.channel_id) - throw new HTTPError( - "You can only reference messages from this channel", - ); - } + + await message.author.save(); + } + + if (opts.username) { + message.username = opts.username; + message.author.username = message.username; + } + if (opts.avatar_url) { + const avatarData = await fetch(opts.avatar_url); + const base64 = await avatarData.buffer().then((x) => x.toString("base64")); + + const dataUri = "data:" + avatarData.headers.get("content-type") + ";base64," + base64; + + message.avatar = await handleFile( + `/avatars/${opts.webhook_id}`, + dataUri as string, + ); + console.log(message.avatar); + message.author.avatar = message.avatar; + } + } else { + permission = await getPermission( + opts.author_id, + channel.guild_id, + opts.channel_id, + ); + permission.hasThrow("SEND_MESSAGES"); + if (permission.cache.member) { + message.member = permission.cache.member; + } + + if (opts.tts) permission.hasThrow("SEND_TTS_MESSAGES"); + if (opts.message_reference) { + permission.hasThrow("READ_MESSAGE_HISTORY"); + // code below has to be redone when we add custom message routing + if (message.guild_id !== null) { + const guild = await Guild.findOneOrFail({ + where: { id: channel.guild_id }, + }); + if (!guild.features.includes("CROSS_CHANNEL_REPLIES")) { + if (opts.message_reference.guild_id !== channel.guild_id) + throw new HTTPError( + "You can only reference messages from this guild", + ); + if (opts.message_reference.channel_id !== opts.channel_id) + throw new HTTPError( + "You can only reference messages from this channel", + ); + } + } + /** Q: should be checked if the referenced message exists? ANSWER: NO + otherwise backfilling won't work **/ + message.type = MessageType.REPLY; } - /** Q: should be checked if the referenced message exists? ANSWER: NO - otherwise backfilling won't work **/ - message.type = MessageType.REPLY; } // TODO: stickers/activity @@ -172,14 +219,14 @@ export async function handleMessage(opts: MessageOptions): Promise { const role = await Role.findOneOrFail({ where: { id: mention, guild_id: channel.guild_id }, }); - if (role.mentionable || permission.has("MANAGE_ROLES")) { + if (role.mentionable || (opts.webhook_id || permission.has("MANAGE_ROLES"))) { mention_role_ids.push(mention); } }, ), ); - if (permission.has("MENTION_EVERYONE")) { + if (opts.webhook_id || permission.has("MENTION_EVERYONE")) { mention_everyone = !!content.match(EVERYONE_MENTION) || !!content.match(HERE_MENTION); @@ -302,4 +349,6 @@ interface MessageOptions extends MessageCreateSchema { attachments?: Attachment[]; edited_timestamp?: Date; timestamp?: Date; + username?: string; + avatar_url?: string; } diff --git a/src/util/entities/Message.ts b/src/util/entities/Message.ts index b519099a..86238e53 100644 --- a/src/util/entities/Message.ts +++ b/src/util/entities/Message.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -218,6 +218,12 @@ export class Message extends BaseClass { @Column({ type: "simple-json", nullable: true }) components?: MessageComponent[]; + @Column({ nullable: true }) + username?: string; + + @Column({ nullable: true }) + avatar?: string; + toJSON(): Message { return { ...this, @@ -234,7 +240,12 @@ export class Message extends BaseClass { reactions: this.reactions ?? undefined, sticker_items: this.sticker_items ?? undefined, message_reference: this.message_reference ?? undefined, - author: this.author?.toPublicUser() ?? undefined, + author: { + ...this.author?.toPublicUser() ?? undefined, + // Webhooks + username: this.username ?? this.author?.username, + avatar: this.avatar ?? this.author?.avatar, + }, activity: this.activity ?? undefined, application: this.application ?? undefined, components: this.components ?? undefined, diff --git a/src/util/entities/Webhook.ts b/src/util/entities/Webhook.ts index 91498a22..b7fba53a 100644 --- a/src/util/entities/Webhook.ts +++ b/src/util/entities/Webhook.ts @@ -1,17 +1,17 @@ /* Spacebar: A FOSS re-implementation and extension of the Discord.com backend. Copyright (C) 2023 Spacebar and Spacebar Contributors - + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ @@ -35,7 +35,7 @@ export class Webhook extends BaseClass { type: WebhookType; @Column({ nullable: true }) - name?: string; + name: string; @Column({ nullable: true }) avatar?: string; diff --git a/src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts b/src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts new file mode 100644 index 00000000..ccbe689a --- /dev/null +++ b/src/util/migration/mariadb/1721298824927-webhookMessageProperties.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class WebhookMessageProperties1721298824927 implements MigrationInterface { + name = "WebhookMessageProperties1721298824927"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query("ALTER TABLE `messages` ADD `username` text NULL"); + await queryRunner.query("ALTER TABLE `messages` ADD `avatar` text NULL"); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `username`"); + await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `avatar`"); + } +} diff --git a/src/util/migration/mysql/1721298824927-webhookMessageProperties.ts b/src/util/migration/mysql/1721298824927-webhookMessageProperties.ts new file mode 100644 index 00000000..ccbe689a --- /dev/null +++ b/src/util/migration/mysql/1721298824927-webhookMessageProperties.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class WebhookMessageProperties1721298824927 implements MigrationInterface { + name = "WebhookMessageProperties1721298824927"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query("ALTER TABLE `messages` ADD `username` text NULL"); + await queryRunner.query("ALTER TABLE `messages` ADD `avatar` text NULL"); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `username`"); + await queryRunner.query("ALTER TABLE `messages` DROP COLUMN `avatar`"); + } +} diff --git a/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts b/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts new file mode 100644 index 00000000..46c507d4 --- /dev/null +++ b/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts @@ -0,0 +1,15 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class WebhookMessageProperties1721298824927 implements MigrationInterface { + name = "WebhookMessageProperties1721298824927"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query("ALTER TABLE messages ADD username text NULL"); + await queryRunner.query("ALTER TABLE messages ADD avatar text NULL"); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query("ALTER TABLE messages DROP COLUMN username"); + await queryRunner.query("ALTER TABLE messages DROP COLUMN avatar"); + } +}