From 23e234a87b0a269f38d0d2f33bfc814bf7346310 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 12 Aug 2023 00:43:00 +1000 Subject: update invites endpoints to support latest api --- assets/openapi.json | 8 +- assets/schemas.json | 643 ++++++++++++++++++++----- src/api/routes/channels/#channel_id/invites.ts | 18 +- src/util/entities/Invite.ts | 9 +- src/util/schemas/InviteCreateSchema.ts | 1 + 5 files changed, 542 insertions(+), 137 deletions(-) diff --git a/assets/openapi.json b/assets/openapi.json index 8ec308ba..19686c59 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -2034,6 +2034,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "required": [ @@ -2041,7 +2044,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -4928,6 +4931,9 @@ }, "target_user_type": { "type": "integer" + }, + "flags": { + "type": "integer" } } }, diff --git a/assets/schemas.json b/assets/schemas.json index 05fa4d22..3891cee7 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -2172,6 +2172,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -2180,7 +2183,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -6374,6 +6377,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -6382,7 +6388,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -10576,6 +10582,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -10584,7 +10593,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -14773,6 +14782,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -14781,7 +14793,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -19006,6 +19018,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -19014,7 +19029,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -23208,6 +23223,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -23216,7 +23234,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -27401,6 +27419,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -27409,7 +27430,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -31597,6 +31618,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -31605,7 +31629,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -35802,6 +35826,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -35810,7 +35837,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -39995,6 +40022,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -40003,7 +40033,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -44188,6 +44218,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -44196,7 +44229,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -48400,6 +48433,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -48408,7 +48444,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -52596,6 +52632,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -52604,7 +52643,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -56852,6 +56891,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -56860,7 +56902,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -61067,6 +61109,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -61075,7 +61120,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -65423,6 +65468,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -65431,7 +65479,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -67827,6 +67875,9 @@ }, "target_user_type": { "type": "integer" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -69634,6 +69685,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -69642,7 +69696,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -73858,6 +73912,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -73866,7 +73923,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -78064,6 +78121,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -78072,7 +78132,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -82276,6 +82336,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -82284,7 +82347,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -86478,6 +86541,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -86486,7 +86552,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -90668,6 +90734,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -90676,7 +90745,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -94969,6 +95038,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -94977,7 +95049,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -99267,6 +99339,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -99275,7 +99350,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -103460,6 +103535,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -103468,7 +103546,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -107661,6 +107739,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -107669,7 +107750,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -111855,6 +111936,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -111863,7 +111947,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -116049,6 +116133,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -116057,7 +116144,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -120278,6 +120365,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -120286,7 +120376,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -124472,6 +124562,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -124480,7 +124573,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -128665,6 +128758,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -128673,7 +128769,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -132873,6 +132969,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -132881,7 +132980,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -137070,6 +137169,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -137078,7 +137180,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -141341,6 +141443,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -141349,7 +141454,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -145534,6 +145639,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -145542,7 +145650,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -149727,6 +149835,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -149735,7 +149846,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -153917,6 +154028,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -153925,7 +154039,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -158113,6 +158227,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -158121,7 +158238,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -162319,6 +162436,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -162327,7 +162447,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -166509,6 +166629,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -166517,7 +166640,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -170748,6 +170871,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -170756,7 +170882,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -174973,6 +175099,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -174981,7 +175110,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -179163,6 +179292,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -179171,7 +179303,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -183378,6 +183510,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -183386,7 +183521,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -187682,6 +187817,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -187690,7 +187828,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -191871,6 +192009,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -191879,7 +192020,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -196099,6 +196240,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -196107,7 +196251,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -200315,6 +200459,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -200323,7 +200470,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -204583,6 +204730,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -204591,7 +204741,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -208773,6 +208923,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -208781,7 +208934,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -212971,6 +213124,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -212979,7 +213135,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -217159,6 +217315,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -217167,7 +217326,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -221353,6 +221512,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -221361,7 +221523,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -225547,6 +225709,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -225555,7 +225720,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -229741,6 +229906,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -229749,7 +229917,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -233967,6 +234135,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -233975,7 +234146,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -238165,6 +238336,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -238173,7 +238347,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -242353,6 +242527,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -242361,7 +242538,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -246547,6 +246724,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -246555,7 +246735,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -250752,6 +250932,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -250760,7 +250943,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -254971,6 +255154,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -254979,7 +255165,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -259161,6 +259347,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -259169,7 +259358,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -263354,6 +263543,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -263362,7 +263554,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -267576,6 +267768,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -267584,7 +267779,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -271766,6 +271961,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -271774,7 +271972,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -276035,6 +276233,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -276043,7 +276244,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -280232,6 +280433,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -280240,7 +280444,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -284422,6 +284626,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -284430,7 +284637,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -288612,6 +288819,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -288620,7 +288830,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -292809,6 +293019,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -292817,7 +293030,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -297003,6 +297216,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -297011,7 +297227,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -301193,6 +301409,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -301201,7 +301420,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -305458,6 +305677,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -305466,7 +305688,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -309659,6 +309881,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -309667,7 +309892,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -313861,6 +314086,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -313869,7 +314097,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -318113,6 +318341,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -318121,7 +318352,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -322324,6 +322555,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -322332,7 +322566,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -326541,6 +326775,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -326549,7 +326786,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -330752,6 +330989,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -330760,7 +331000,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -334942,6 +335182,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -334950,7 +335193,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -339160,6 +339403,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -339168,7 +339414,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -343390,6 +343636,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -343398,7 +343647,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -347574,6 +347823,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -347582,7 +347834,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -351768,6 +352020,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -351776,7 +352031,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -355958,6 +356213,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -355966,7 +356224,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -360155,6 +360413,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -360163,7 +360424,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -364549,6 +364810,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -364557,7 +364821,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -368730,6 +368994,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -368738,7 +369005,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -373005,6 +373272,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -373013,7 +373283,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -377189,6 +377459,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -377197,7 +377470,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -381373,6 +381646,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -381381,7 +381657,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -385557,6 +385833,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -385565,7 +385844,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -389835,6 +390114,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -389843,7 +390125,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -394017,6 +394299,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -394025,7 +394310,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -398199,6 +398484,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -398207,7 +398495,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -402381,6 +402669,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -402389,7 +402680,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -406565,6 +406856,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -406573,7 +406867,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -410749,6 +411043,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -410757,7 +411054,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -414933,6 +415230,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -414941,7 +415241,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -419117,6 +419417,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -419125,7 +419428,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -423301,6 +423604,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -423309,7 +423615,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -427549,6 +427855,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -427557,7 +427866,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -431733,6 +432042,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -431741,7 +432053,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -435917,6 +436229,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -435925,7 +436240,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -440101,6 +440416,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -440109,7 +440427,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -444329,6 +444647,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -444337,7 +444658,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -448742,6 +449063,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -448750,7 +449074,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -452926,6 +453250,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -452934,7 +453261,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -457110,6 +457437,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -457118,7 +457448,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -461294,6 +461624,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -461302,7 +461635,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -465478,6 +465811,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -465486,7 +465822,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -469688,6 +470024,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -469696,7 +470035,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -473872,6 +474211,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -473880,7 +474222,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -478077,6 +478419,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -478085,7 +478430,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -482275,6 +482620,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -482283,7 +482631,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -486582,6 +486930,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -486590,7 +486941,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -490784,6 +491135,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -490792,7 +491146,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -494992,6 +495346,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -495000,7 +495357,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -499186,6 +499543,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -499194,7 +499554,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -503380,6 +503740,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -503388,7 +503751,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -507561,6 +507924,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -507569,7 +507935,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -511754,6 +512120,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -511762,7 +512131,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -515962,6 +516331,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -515970,7 +516342,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -520174,6 +520546,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -520182,7 +520557,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -524365,6 +524740,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -524373,7 +524751,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -528555,6 +528933,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -528563,7 +528944,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -532745,6 +533126,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -532753,7 +533137,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", @@ -536941,6 +537325,9 @@ }, "vanity_url": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -536949,7 +537336,7 @@ "channel_id", "code", "created_at", - "expires_at", + "flags", "guild", "guild_id", "inviter", diff --git a/src/api/routes/channels/#channel_id/invites.ts b/src/api/routes/channels/#channel_id/invites.ts index b02f65d3..ae32e80d 100644 --- a/src/api/routes/channels/#channel_id/invites.ts +++ b/src/api/routes/channels/#channel_id/invites.ts @@ -22,6 +22,7 @@ import { Guild, Invite, InviteCreateEvent, + InviteCreateSchema, PublicInviteRelation, User, emitEvent, @@ -50,6 +51,7 @@ router.post( }), async (req: Request, res: Response) => { const { user_id } = req; + const body = req.body as InviteCreateSchema; const { channel_id } = req.params; const channel = await Channel.findOneOrFail({ where: { id: channel_id }, @@ -62,22 +64,27 @@ router.post( } const { guild_id } = channel; - const expires_at = new Date(req.body.max_age * 1000 + Date.now()); + const expires_at = + body.max_age == 0 || body.max_age == undefined + ? undefined + : new Date(body.max_age * 1000 + Date.now()); const invite = await Invite.create({ code: random(), - temporary: req.body.temporary || true, + temporary: body.temporary || true, uses: 0, - max_uses: req.body.max_uses, - max_age: req.body.max_age, + max_uses: body.max_uses ? Math.max(0, body.max_uses) : 0, + max_age: body.max_age ? Math.max(0, body.max_age) : 0, expires_at, created_at: new Date(), guild_id, channel_id: channel_id, inviter_id: user_id, + flags: body.flags ?? 0, }).save(); + const data = invite.toJSON(); - data.inviter = await User.getPublicUser(req.user_id); + data.inviter = (await User.getPublicUser(req.user_id)).toPublicUser(); data.guild = await Guild.findOne({ where: { id: guild_id } }); data.channel = channel; @@ -86,6 +93,7 @@ router.post( data, guild_id, } as InviteCreateEvent); + res.status(201).send(data); }, ); diff --git a/src/util/entities/Invite.ts b/src/util/entities/Invite.ts index 3019709f..7970c4f0 100644 --- a/src/util/entities/Invite.ts +++ b/src/util/entities/Invite.ts @@ -17,10 +17,10 @@ */ import { Column, Entity, JoinColumn, ManyToOne, RelationId } from "typeorm"; -import { Member } from "./Member"; import { BaseClassWithoutId, PrimaryIdColumn } from "./BaseClass"; import { Channel } from "./Channel"; import { Guild } from "./Guild"; +import { Member } from "./Member"; import { User } from "./User"; export const PublicInviteRelation = ["inviter", "guild", "channel"]; @@ -45,8 +45,8 @@ export class Invite extends BaseClassWithoutId { @Column() created_at: Date; - @Column() - expires_at: Date; + @Column({ nullable: true }) + expires_at?: Date; @Column({ nullable: true }) @RelationId((invite: Invite) => invite.guild) @@ -94,6 +94,9 @@ export class Invite extends BaseClassWithoutId { @Column({ nullable: true }) vanity_url?: boolean; + @Column() + flags: number; + static async joinGuild(user_id: string, code: string) { const invite = await Invite.findOneOrFail({ where: { code } }); if (invite.uses++ >= invite.max_uses && invite.max_uses !== 0) diff --git a/src/util/schemas/InviteCreateSchema.ts b/src/util/schemas/InviteCreateSchema.ts index 6cdc0214..92333e77 100644 --- a/src/util/schemas/InviteCreateSchema.ts +++ b/src/util/schemas/InviteCreateSchema.ts @@ -26,4 +26,5 @@ export interface InviteCreateSchema { unique?: boolean; target_user?: string; target_user_type?: number; + flags?: number; } -- cgit 1.4.1