diff options
-rw-r--r-- | api/assets/schemas.json | 2338 | ||||
-rw-r--r-- | api/src/routes/guilds/#guild_id/members/#member_id/index.ts | 3 | ||||
-rw-r--r-- | slowcord/build/index.js | 128 | ||||
-rw-r--r-- | slowcord/build/index.js.map | 1 |
4 files changed, 2051 insertions, 419 deletions
diff --git a/api/assets/schemas.json b/api/assets/schemas.json index 7a96be3c..cb3485fe 100644 --- a/api/assets/schemas.json +++ b/api/assets/schemas.json @@ -1,4 +1,733 @@ { + "MessageCreateSchema": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "nonce": { + "type": "string" + }, + "tts": { + "type": "boolean" + }, + "flags": { + "type": "string" + }, + "embeds": { + "type": "array", + "items": { + "$ref": "#/definitions/Embed" + } + }, + "embed": { + "$ref": "#/definitions/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 + }, + "message_reference": { + "type": "object", + "properties": { + "message_id": { + "type": "string" + }, + "channel_id": { + "type": "string" + }, + "guild_id": { + "type": "string" + }, + "fail_if_not_exists": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "channel_id", + "message_id" + ] + }, + "payload_json": { + "type": "string" + }, + "file": {}, + "attachments": { + "description": "TODO: we should create an interface for attachments\nTODO: OpenWAAO<-->attachment-style metadata conversion", + "type": "array", + "items": {} + }, + "sticker_ids": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "additionalProperties": false, + "definitions": { + "Embed": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "type": { + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" + }, + "description": { + "type": "string" + }, + "url": { + "type": "string" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "color": { + "type": "integer" + }, + "footer": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "text" + ] + }, + "image": { + "$ref": "#/definitions/EmbedImage" + }, + "thumbnail": { + "$ref": "#/definitions/EmbedImage" + }, + "video": { + "$ref": "#/definitions/EmbedImage" + }, + "provider": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "author": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "inline": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "name", + "value" + ] + } + } + }, + "additionalProperties": false + }, + "EmbedImage": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + } + }, + "additionalProperties": false + }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, + "ChannelModifySchema": { + "type": "object", + "properties": { + "name": { + "maxLength": 100, + "type": "string" + }, + "type": { + "enum": [ + 0, + 1, + 10, + 11, + 12, + 13, + 14, + 15, + 2, + 255, + 3, + 33, + 34, + 35, + 4, + 5, + 6, + 64, + 7, + 8, + 9 + ], + "type": "number" + }, + "topic": { + "type": "string" + }, + "icon": { + "type": [ + "null", + "string" + ] + }, + "bitrate": { + "type": "integer" + }, + "user_limit": { + "type": "integer" + }, + "rate_limit_per_user": { + "type": "integer" + }, + "position": { + "type": "integer" + }, + "permission_overwrites": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/ChannelPermissionOverwriteType" + }, + "allow": { + "type": "string" + }, + "deny": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "allow", + "deny", + "id", + "type" + ] + } + }, + "parent_id": { + "type": "string" + }, + "id": { + "type": "string" + }, + "nsfw": { + "type": "boolean" + }, + "rtc_region": { + "type": "string" + }, + "default_auto_archive_duration": { + "type": "integer" + } + }, + "additionalProperties": false + }, + "UserPublic": { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "discriminator": { + "type": "string" + }, + "id": { + "type": "string" + }, + "public_flags": { + "type": "integer" + }, + "avatar": { + "type": "string" + }, + "accent_color": { + "type": "integer" + }, + "banner": { + "type": "string" + }, + "bio": { + "type": "string" + }, + "bot": { + "type": "boolean" + }, + "premium_since": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false, + "required": [ + "bio", + "bot", + "discriminator", + "id", + "premium_since", + "public_flags", + "username" + ] + }, + "PublicConnectedAccount": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "verified": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "name", + "type", + "verified" + ] + } + }, + "$schema": "http://json-schema.org/draft-07/schema#" + }, + "RouteResponse": { + "type": "object", + "properties": { + "status": { + "type": "integer" + }, + "body": { + "type": "array", + "items": { + "type": "string" + } + }, + "headers": { + "$ref": "#/definitions/Record<string,string>" + } + }, + "additionalProperties": false, + "definitions": { + "Embed": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "type": { + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" + }, + "description": { + "type": "string" + }, + "url": { + "type": "string" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "color": { + "type": "integer" + }, + "footer": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "text" + ] + }, + "image": { + "$ref": "#/definitions/EmbedImage" + }, + "thumbnail": { + "$ref": "#/definitions/EmbedImage" + }, + "video": { + "$ref": "#/definitions/EmbedImage" + }, + "provider": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "author": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "inline": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "name", + "value" + ] + } + } + }, + "additionalProperties": false + }, + "EmbedImage": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + } + }, + "additionalProperties": false + }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, + "ChannelModifySchema": { + "type": "object", + "properties": { + "name": { + "maxLength": 100, + "type": "string" + }, + "type": { + "enum": [ + 0, + 1, + 10, + 11, + 12, + 13, + 14, + 15, + 2, + 255, + 3, + 33, + 34, + 35, + 4, + 5, + 6, + 64, + 7, + 8, + 9 + ], + "type": "number" + }, + "topic": { + "type": "string" + }, + "icon": { + "type": [ + "null", + "string" + ] + }, + "bitrate": { + "type": "integer" + }, + "user_limit": { + "type": "integer" + }, + "rate_limit_per_user": { + "type": "integer" + }, + "position": { + "type": "integer" + }, + "permission_overwrites": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/ChannelPermissionOverwriteType" + }, + "allow": { + "type": "string" + }, + "deny": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "allow", + "deny", + "id", + "type" + ] + } + }, + "parent_id": { + "type": "string" + }, + "id": { + "type": "string" + }, + "nsfw": { + "type": "boolean" + }, + "rtc_region": { + "type": "string" + }, + "default_auto_archive_duration": { + "type": "integer" + } + }, + "additionalProperties": false + }, + "UserPublic": { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "discriminator": { + "type": "string" + }, + "id": { + "type": "string" + }, + "public_flags": { + "type": "integer" + }, + "avatar": { + "type": "string" + }, + "accent_color": { + "type": "integer" + }, + "banner": { + "type": "string" + }, + "bio": { + "type": "string" + }, + "bot": { + "type": "boolean" + }, + "premium_since": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false, + "required": [ + "bio", + "bot", + "discriminator", + "id", + "premium_since", + "public_flags", + "username" + ] + }, + "PublicConnectedAccount": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "verified": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "name", + "type", + "verified" + ] + } + }, + "$schema": "http://json-schema.org/draft-07/schema#" + }, "LoginSchema": { "type": "object", "properties": { @@ -26,6 +755,315 @@ "login", "password" ], + "definitions": { + "Embed": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "type": { + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" + }, + "description": { + "type": "string" + }, + "url": { + "type": "string" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "color": { + "type": "integer" + }, + "footer": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "text" + ] + }, + "image": { + "$ref": "#/definitions/EmbedImage" + }, + "thumbnail": { + "$ref": "#/definitions/EmbedImage" + }, + "video": { + "$ref": "#/definitions/EmbedImage" + }, + "provider": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "author": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "inline": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "name", + "value" + ] + } + } + }, + "additionalProperties": false + }, + "EmbedImage": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + } + }, + "additionalProperties": false + }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, + "ChannelModifySchema": { + "type": "object", + "properties": { + "name": { + "maxLength": 100, + "type": "string" + }, + "type": { + "enum": [ + 0, + 1, + 10, + 11, + 12, + 13, + 14, + 15, + 2, + 255, + 3, + 33, + 34, + 35, + 4, + 5, + 6, + 64, + 7, + 8, + 9 + ], + "type": "number" + }, + "topic": { + "type": "string" + }, + "icon": { + "type": [ + "null", + "string" + ] + }, + "bitrate": { + "type": "integer" + }, + "user_limit": { + "type": "integer" + }, + "rate_limit_per_user": { + "type": "integer" + }, + "position": { + "type": "integer" + }, + "permission_overwrites": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/ChannelPermissionOverwriteType" + }, + "allow": { + "type": "string" + }, + "deny": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "allow", + "deny", + "id", + "type" + ] + } + }, + "parent_id": { + "type": "string" + }, + "id": { + "type": "string" + }, + "nsfw": { + "type": "boolean" + }, + "rtc_region": { + "type": "string" + }, + "default_auto_archive_duration": { + "type": "integer" + } + }, + "additionalProperties": false + }, + "UserPublic": { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "discriminator": { + "type": "string" + }, + "id": { + "type": "string" + }, + "public_flags": { + "type": "integer" + }, + "avatar": { + "type": "string" + }, + "accent_color": { + "type": "integer" + }, + "banner": { + "type": "string" + }, + "bio": { + "type": "string" + }, + "bot": { + "type": "boolean" + }, + "premium_since": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false, + "required": [ + "bio", + "bot", + "discriminator", + "id", + "premium_since", + "public_flags", + "username" + ] + }, + "PublicConnectedAccount": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "verified": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "name", + "type", + "verified" + ] + } + }, "$schema": "http://json-schema.org/draft-07/schema#" }, "RegisterSchema": { @@ -69,6 +1107,315 @@ "consent", "username" ], + "definitions": { + "Embed": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "type": { + "enum": [ + "article", + "gifv", + "image", + "link", + "rich", + "video" + ], + "type": "string" + }, + "description": { + "type": "string" + }, + "url": { + "type": "string" + }, + "timestamp": { + "type": "string", + "format": "date-time" + }, + "color": { + "type": "integer" + }, + "footer": { + "type": "object", + "properties": { + "text": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "text" + ] + }, + "image": { + "$ref": "#/definitions/EmbedImage" + }, + "thumbnail": { + "$ref": "#/definitions/EmbedImage" + }, + "video": { + "$ref": "#/definitions/EmbedImage" + }, + "provider": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "author": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "url": { + "type": "string" + }, + "icon_url": { + "type": "string" + }, + "proxy_icon_url": { + "type": "string" + } + }, + "additionalProperties": false + }, + "fields": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + }, + "inline": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "name", + "value" + ] + } + } + }, + "additionalProperties": false + }, + "EmbedImage": { + "type": "object", + "properties": { + "url": { + "type": "string" + }, + "proxy_url": { + "type": "string" + }, + "height": { + "type": "integer" + }, + "width": { + "type": "integer" + } + }, + "additionalProperties": false + }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, + "ChannelModifySchema": { + "type": "object", + "properties": { + "name": { + "maxLength": 100, + "type": "string" + }, + "type": { + "enum": [ + 0, + 1, + 10, + 11, + 12, + 13, + 14, + 15, + 2, + 255, + 3, + 33, + 34, + 35, + 4, + 5, + 6, + 64, + 7, + 8, + 9 + ], + "type": "number" + }, + "topic": { + "type": "string" + }, + "icon": { + "type": [ + "null", + "string" + ] + }, + "bitrate": { + "type": "integer" + }, + "user_limit": { + "type": "integer" + }, + "rate_limit_per_user": { + "type": "integer" + }, + "position": { + "type": "integer" + }, + "permission_overwrites": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/ChannelPermissionOverwriteType" + }, + "allow": { + "type": "string" + }, + "deny": { + "type": "string" + } + }, + "additionalProperties": false, + "required": [ + "allow", + "deny", + "id", + "type" + ] + } + }, + "parent_id": { + "type": "string" + }, + "id": { + "type": "string" + }, + "nsfw": { + "type": "boolean" + }, + "rtc_region": { + "type": "string" + }, + "default_auto_archive_duration": { + "type": "integer" + } + }, + "additionalProperties": false + }, + "UserPublic": { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "discriminator": { + "type": "string" + }, + "id": { + "type": "string" + }, + "public_flags": { + "type": "integer" + }, + "avatar": { + "type": "string" + }, + "accent_color": { + "type": "integer" + }, + "banner": { + "type": "string" + }, + "bio": { + "type": "string" + }, + "bot": { + "type": "boolean" + }, + "premium_since": { + "type": "string", + "format": "date-time" + } + }, + "additionalProperties": false, + "required": [ + "bio", + "bot", + "discriminator", + "id", + "premium_since", + "public_flags", + "username" + ] + }, + "PublicConnectedAccount": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "verified": { + "type": "boolean" + } + }, + "additionalProperties": false, + "required": [ + "name", + "type", + "verified" + ] + } + }, "$schema": "http://json-schema.org/draft-07/schema#" }, "ChannelModifySchema": { @@ -86,6 +1433,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -168,14 +1517,6 @@ }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -306,6 +1647,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -321,6 +1674,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -472,104 +1827,39 @@ }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "MessageCreateSchema": { + "InviteCreateSchema": { "type": "object", "properties": { - "content": { + "target_user_id": { "type": "string" }, - "nonce": { + "target_type": { "type": "string" }, - "tts": { - "type": "boolean" - }, - "flags": { + "validate": { "type": "string" }, - "embeds": { - "type": "array", - "items": { - "$ref": "#/definitions/Embed" - } + "max_age": { + "type": "integer" }, - "embed": { - "$ref": "#/definitions/Embed" + "max_uses": { + "type": "integer" }, - "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 + "temporary": { + "type": "boolean" }, - "message_reference": { - "type": "object", - "properties": { - "message_id": { - "type": "string" - }, - "channel_id": { - "type": "string" - }, - "guild_id": { - "type": "string" - }, - "fail_if_not_exists": { - "type": "boolean" - } - }, - "additionalProperties": false, - "required": [ - "channel_id", - "message_id" - ] + "unique": { + "type": "boolean" }, - "payload_json": { + "target_user": { "type": "string" }, - "file": {}, - "attachments": { - "type": "array", - "items": {} - }, - "sticker_ids": { - "type": "array", - "items": { - "type": "string" - } + "target_user_type": { + "type": "integer" } }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -700,6 +1990,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -715,6 +2017,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -866,47 +2170,18 @@ }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "InviteCreateSchema": { + "MessageAcknowledgeSchema": { "type": "object", "properties": { - "target_user_id": { - "type": "string" - }, - "target_type": { - "type": "string" - }, - "validate": { - "type": "string" - }, - "max_age": { - "type": "integer" - }, - "max_uses": { - "type": "integer" - }, - "temporary": { - "type": "boolean" - }, - "unique": { + "manual": { "type": "boolean" }, - "target_user": { - "type": "string" - }, - "target_user_type": { + "mention_count": { "type": "integer" } }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -1037,6 +2312,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -1052,6 +2339,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -1203,26 +2492,21 @@ }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "MessageAcknowledgeSchema": { + "BulkDeleteSchema": { "type": "object", "properties": { - "manual": { - "type": "boolean" - }, - "mention_count": { - "type": "integer" + "messages": { + "type": "array", + "items": { + "type": "string" + } } }, "additionalProperties": false, + "required": [ + "messages" + ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -1353,6 +2637,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -1368,6 +2664,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -1519,29 +2817,30 @@ }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "BulkDeleteSchema": { + "ChannelPermissionOverwriteSchema": { "type": "object", "properties": { - "messages": { - "type": "array", - "items": { - "type": "string" - } + "allow": { + "type": "string" + }, + "deny": { + "type": "string" + }, + "id": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/ChannelPermissionOverwriteType" } }, "additionalProperties": false, "required": [ - "messages" + "allow", + "deny", + "id", + "type" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -1672,6 +2971,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -1687,6 +2998,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -1838,38 +3151,22 @@ }, "$schema": "http://json-schema.org/draft-07/schema#" }, - "ChannelPermissionOverwriteSchema": { + "PurgeSchema": { "type": "object", "properties": { - "allow": { - "type": "string" - }, - "deny": { + "before": { "type": "string" }, - "id": { + "after": { "type": "string" - }, - "type": { - "$ref": "#/definitions/ChannelPermissionOverwriteType" } }, "additionalProperties": false, "required": [ - "allow", - "deny", - "id", - "type" + "after", + "before" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -2000,6 +3297,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -2015,6 +3324,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -2183,14 +3494,6 @@ "name" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -2321,6 +3624,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -2336,6 +3651,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -2528,14 +3845,6 @@ "url" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -2666,6 +3975,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -2681,6 +4002,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -2844,14 +4167,6 @@ "url" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -2982,6 +4297,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -2997,6 +4324,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -3160,14 +4489,6 @@ }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -3298,6 +4619,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -3313,6 +4646,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -3494,14 +4829,6 @@ "user_id" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -3632,6 +4959,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -3647,6 +4986,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -3825,14 +5166,6 @@ "user_id" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -3963,6 +5296,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -3978,6 +5323,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -4153,14 +5500,6 @@ ] }, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -4291,6 +5630,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -4306,6 +5657,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -4484,14 +5837,6 @@ "image" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -4622,6 +5967,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -4637,6 +5994,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -4803,14 +6162,6 @@ }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -4941,6 +6292,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -4956,6 +6319,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -5144,14 +6509,6 @@ "name" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -5282,6 +6639,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -5297,6 +6666,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -5524,14 +6895,6 @@ "name" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -5662,6 +7025,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -5677,6 +7052,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -5836,18 +7213,13 @@ "items": { "type": "string" } + }, + "nick": { + "type": "string" } }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -5978,6 +7350,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -5993,6 +7377,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -6156,14 +7542,6 @@ "nick" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -6294,6 +7672,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -6309,6 +7699,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -6472,14 +7864,6 @@ "days" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -6610,6 +7994,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -6625,6 +8021,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -6806,14 +8204,6 @@ }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -6944,6 +8334,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -6959,6 +8361,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -7129,14 +8533,6 @@ ] }, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -7267,6 +8663,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -7282,6 +8690,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -7456,14 +8866,6 @@ "tags" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -7594,6 +8996,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -7609,6 +9023,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -7775,14 +9191,6 @@ "name" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -7913,6 +9321,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -7928,6 +9348,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -8094,14 +9516,6 @@ "name" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -8232,6 +9646,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -8247,6 +9673,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -8409,14 +9837,6 @@ }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -8547,6 +9967,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -8562,6 +9994,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -8744,14 +10178,6 @@ "channel_id" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -8882,6 +10308,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -8897,6 +10335,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -9086,14 +10526,6 @@ }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -9224,6 +10656,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -9239,6 +10683,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -9406,14 +10852,6 @@ "enabled" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -9544,6 +10982,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -9559,6 +11009,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -9728,14 +11180,6 @@ "name" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -9866,6 +11310,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -9881,6 +11337,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -10056,14 +11514,6 @@ "user" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -10194,6 +11644,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -10209,6 +11671,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -10390,14 +11854,6 @@ "object" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -10528,6 +11984,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -10543,6 +12011,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -10712,14 +12182,6 @@ "recipients" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -10850,6 +12312,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -10865,6 +12339,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -11017,7 +12493,6 @@ "$schema": "http://json-schema.org/draft-07/schema#" }, "UserModifySchema": { - "additionalProperties": false, "type": "object", "properties": { "username": { @@ -11054,15 +12529,8 @@ "type": "string" } }, + "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -11193,6 +12661,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -11208,6 +12688,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -11374,14 +12856,6 @@ }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -11512,6 +12986,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -11527,6 +13013,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -11694,14 +13182,6 @@ "username" ], "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -11832,6 +13312,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -11847,6 +13339,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, @@ -12172,14 +13666,6 @@ }, "additionalProperties": false, "definitions": { - "ChannelPermissionOverwriteType": { - "enum": [ - 0, - 1, - 2 - ], - "type": "number" - }, "Embed": { "type": "object", "properties": { @@ -12310,6 +13796,18 @@ }, "additionalProperties": false }, + "Record<string,string>": { + "type": "object", + "additionalProperties": false + }, + "ChannelPermissionOverwriteType": { + "enum": [ + 0, + 1, + 2 + ], + "type": "number" + }, "ChannelModifySchema": { "type": "object", "properties": { @@ -12325,6 +13823,8 @@ 11, 12, 13, + 14, + 15, 2, 255, 3, diff --git a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts index c285abb3..2ff89eae 100644 --- a/api/src/routes/guilds/#guild_id/members/#member_id/index.ts +++ b/api/src/routes/guilds/#guild_id/members/#member_id/index.ts @@ -7,6 +7,7 @@ const router = Router(); export interface MemberChangeSchema { roles?: string[]; + nick?: string; } router.get("/", route({}), async (req: Request, res: Response) => { @@ -34,6 +35,8 @@ router.patch("/", route({ body: "MemberChangeSchema" }), async (req: Request, re member.roles = body.roles.map((x) => new Role({ id: x })); // foreign key constraint will fail if role doesn't exist } + if (body.nick) member.nick = body.nick; + await member.save(); member.roles = member.roles.filter((x) => x.id !== everyone.id); diff --git a/slowcord/build/index.js b/slowcord/build/index.js new file mode 100644 index 00000000..9a85c188 --- /dev/null +++ b/slowcord/build/index.js @@ -0,0 +1,128 @@ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var _a; +import "dotenv/config"; +import express from "express"; +import cookieParser from "cookie-parser"; +import { initDatabase, generateToken, User, Config } from "@fosscord/util"; +import path from "path"; +import fetch from "node-fetch"; +// apparently dirname doesn't exist in modules, nice +/* https://stackoverflow.com/a/62892482 */ +import { fileURLToPath } from "url"; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const app = express(); +app.use(cookieParser()); +const port = process.env.PORT; +// ip -> unix epoch that requests will be accepted again +const rateLimits = {}; +const allowRequestsEveryMs = 0.5 * 1000; // every half second +const allowedRequestsPerSecond = 50; +let requestsThisSecond = 0; +setInterval(() => { + requestsThisSecond = 0; +}, 1000); +class Discord { +} +_a = Discord; +Discord.getAccessToken = (req, res) => __awaiter(void 0, void 0, void 0, function* () { + const { code } = req.query; + const body = new URLSearchParams(Object.entries({ + client_id: process.env.DISCORD_CLIENT_ID, + client_secret: process.env.DISCORD_SECRET, + redirect_uri: process.env.DISCORD_REDIRECT, + code: code, + grant_type: "authorization_code", + })).toString(); + const resp = yield fetch("https://discord.com/api/oauth2/token", { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded", + }, + body: body + }); + const json = yield resp.json(); + if (json.error) + return null; + return { + access_token: json.access_token, + token_type: json.token_type, + expires_in: json.expires_in, + refresh_token: json.refresh_token, + scope: json.scope, + }; +}); +Discord.getUserDetails = (token) => __awaiter(void 0, void 0, void 0, function* () { + const resp = yield fetch("https://discord.com/api/users/@me", { + headers: { + "Authorization": `Bearer ${token}`, + } + }); + const json = yield resp.json(); + if (!json.username || !json.email) + return null; // eh, deal with bad code later + return { + id: json.id, + email: json.email, + username: json.username, + }; +}); +const handlers = { + "discord": Discord, +}; +app.get("/oauth/:type", (req, res) => __awaiter(void 0, void 0, void 0, function* () { + requestsThisSecond++; + if (requestsThisSecond > allowedRequestsPerSecond) + return res.sendStatus(429); + const ip = req.headers["x-forwarded-for"] || req.socket.remoteAddress; + console.log(`${ip}`); + if (!rateLimits[ip]) { + rateLimits[ip] = Date.now() + allowRequestsEveryMs; + } + else if (rateLimits[ip] > Date.now()) { + rateLimits[ip] += allowRequestsEveryMs; + console.log(`${new Date()} : user ${ip} was timed out for ${(rateLimits[ip] - Date.now()) / 1000}s`); + return res.sendStatus(429); + } + else { + delete rateLimits[ip]; + } + const { type } = req.params; + const handler = handlers[type]; + if (!type || !handler) + return res.sendStatus(400); + const data = yield handler.getAccessToken(req, res); + if (!data) + return res.sendStatus(500); + const details = yield handler.getUserDetails(data.access_token); + if (!details) + return res.sendStatus(500); + let user = yield User.findOne({ where: { email: details.email } }); + if (!user) { + user = yield User.register({ + email: details.email, + username: details.username, + req + }); + } + const token = yield generateToken(user.id); + res.cookie("token", token); + res.sendFile(path.join(__dirname, "../public/login.html")); +})); +app.use(express.static("public", { extensions: ["html"] })); +(() => __awaiter(void 0, void 0, void 0, function* () { + yield initDatabase(); + yield Config.init(); + app.listen(port, () => { + console.log(`Listening on port ${port}`); + }); +}))(); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/slowcord/build/index.js.map b/slowcord/build/index.js.map new file mode 100644 index 00000000..c28af385 --- /dev/null +++ b/slowcord/build/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";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