From ecfd5d3b5efb5c9dbce27067d11cd60036ea507a Mon Sep 17 00:00:00 2001 From: SiroTM Date: Sun, 6 Jun 2021 08:02:34 -0400 Subject: [PATCH 1/7] feat(Threads) --- rest/Endpoints.ts | 67 +++++++++++++++++++++++++++++++++++++++++++ rest/RESTClient.ts | 2 +- src/Client.ts | 59 +++++++++++++++++++++++++++++++++++++ src/util/Constants.ts | 8 ++++++ structures/Guild.ts | 1 + ws/constants.ts | 6 ++++ 6 files changed, 142 insertions(+), 1 deletion(-) diff --git a/rest/Endpoints.ts b/rest/Endpoints.ts index 8114a62..172a6cd 100644 --- a/rest/Endpoints.ts +++ b/rest/Endpoints.ts @@ -67,6 +67,73 @@ export default class Endpoints { public static CHANNEL_MESSAGE_REACTIONS(channelID: string, messageID: string) { return `/channels/${channelID}/messages/${messageID}/reactions`; } + /** + * `/channels/{channel.id}/messages/{message.id}/threads` + * - POST - Create new thread from existing message + */ + public static START_THREAD_WITH_MESSAGE(channelID: string, messageID: string) { + return `/channels/${channelID}/messages/${messageID}/threads`; + } + /** + * `/channels/{channel.id}/threads` + * - POST - Creates a new thread that is not connected to an existing message + */ + public static START_THREAD_WITHOUT_MESSAGE(channelID: string) { + return `/channels/${channelID}/threads`; + } + /** + * `/channels/{channel.id}/thread-members/@me` + * - PUT - Adds the current user to a thread + * - DELETE - Removes the current user from a thread + */ + public static THREAD(channelID: string) { + return `/channels/${channelID}/thread-members/@me`; + } + /** + * `/channels/{channel.id}/thread-members/{user.id}` + * - PUT - Adds another member to a thread + * - DELETE - Removes another member from a thread + */ + public static THREAD_MEMBER(channelID: string, userID: string) { + return `/channels/${channelID}/thread-members/${userID}`; + } + /** + * `/channels/{channel.id}/thread-members` + * - GET - Return array of thread members objects that are members of the thread + */ + public static LIST_THREAD_MEMBERS(channelID: string) { + return `/channels/${channelID}/thread-members`; + } + /** + * `/channels/{channel.id}/threads/active` + * - GET - Return all active threads in the channel + */ + public static LIST_ACTIVE_THREADS(channelID: string) { + return `/channels/${channelID}/thread/active`; + } + /** + * `/channels/{channel.id}/threads/archived/public` + * - GET - Return archived threads in the channel that are public + */ + public static LIST_PUBLIC_ARCHIVED_THREADS(channelID: string) { + return `/channels/${channelID}/threads/archived/public`; + } + /** + * `/channels/{channel.id}/threads/archived/private` + * - GET - Return archived threads in the channel that are of type GUILD_PRIVATE_THREAD + */ + public static LIST_PRIVATE_ARCHIVED_THREADS(channelID: string) { + return `/channels/${channelID}/threads/archived/private`; + } + /** + * `/channels/{channel.id}/users/@me/threads/archived/private` + * - GET - Return archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined + */ + public static LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID: string) { + return `/channels/${channelID}/users/@me/threads/archived/private`; + } + + /** * `/channels/:channelID/messages/bulk-delete` * - POST - Bulk Delete Messages diff --git a/rest/RESTClient.ts b/rest/RESTClient.ts index 0a8285c..50b1ffa 100644 --- a/rest/RESTClient.ts +++ b/rest/RESTClient.ts @@ -9,7 +9,7 @@ import { REST_CONSTANTS } from '../src/util/Constants'; const { version, repository } = require('../../package.json'); export default class RESTClient { - version = 'v8'; + version = 'v9'; apiURL = `/api/${this.version}`;// eslint-disable-line @typescript-eslint/member-ordering readonly client: Client; globallyRateLimited = false; diff --git a/src/Client.ts b/src/Client.ts index cfeeffe..7027b3c 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -38,6 +38,10 @@ export default class Client { return this.rest.request('PUT', Endpoints.CHANNEL_PINNED_MESSAGE(channelID, messageID), true); } + addThreadMember(channelID: string, userID: string) { + return this.rest.request('PUT', Endpoints.THREAD_MEMBER(channelID, userID), true); + } + beginGuildPrune(guildID: string, params: any = {}) { return this.rest.request('POST', Endpoints.GUILD_PRUNE(guildID), true, { days: params.days, @@ -499,10 +503,47 @@ export default class Client { : this.rest.request('GET', Endpoints.WEBHOOK(webhookID), true); } + joinThread(channelID: string) { + return this.rest.request('PUT', Endpoints.THREAD(channelID), true); + } + leaveGuild(guildID: string) { return this.rest.request('DELETE', Endpoints.USER_GUILD(guildID), true); } + leaveThread(channelID: string) { + return this.rest.request('DELETE', Endpoints.THREAD(channelID), true); + } + + listActiveThreads(channelID: string) { + return this.rest.request('GET', Endpoints.LIST_ACTIVE_THREADS(channelID), true); + } + + listJoinedPrivateArchivedThreads(channelID: string, params: any = {}) { + return this.rest.request('GET', Endpoints.LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID), true, { + before: params.before, + limit: params.limit, + }); + } + + listPrivateArchivedThreads(channelID: string, params: any = {}) { + return this.rest.request('GET', Endpoints.LIST_PRIVATE_ARCHIVED_THREADS(channelID), true, { + before: params.before, + limit: params.limit, + }); + } + + listPublicArchivedThreads(channelID: string, params: any = {}) { + return this.rest.request('GET', Endpoints.LIST_PUBLIC_ARCHIVED_THREADS(channelID), true, { + before: params.before, + limit: params.limit, + }); + } + + listThreadMembers(channelID: string) { + return this.rest.request('GET', Endpoints.LIST_THREAD_MEMBERS(channelID), true); + } + listVoiceRegions() { return this.rest.request('GET', Endpoints.VOICE_REGIONS(), true); } @@ -526,6 +567,24 @@ export default class Client { return this.rest.request('DELETE', Endpoints.GUILD_MEMBER_ROLE(guildID, userID, roleID), true); } + removeThreadMember(channelID: string, userID: string) { + return this.rest.request('DELETE', Endpoints.THREAD_MEMBER(channelID, userID), true); + } + + startThreadWithMessage(channelID: string, messageID: string, params: any = {}) { + return this.rest.request('POST', Endpoints.START_THREAD_WITH_MESSAGE(channelID, messageID), true, { + name: params.name, + auto_archive_duration: params.autoArchiveDuration, + }); + } + + startThreadWithoutMessage(channelID: string, params: any = {}) { + return this.rest.request('POST', Endpoints.START_THREAD_WITHOUT_MESSAGE(channelID), true, { + name: params.name, + auto_archive_duration: params.autoArchiveDuration, + }); + } + syncGuildIntegration(guildID: string, integrationID: string) { return this.rest.request('POST', Endpoints.GUILD_INTEGRATION_SYNC(guildID, integrationID), true); } diff --git a/src/util/Constants.ts b/src/util/Constants.ts index ffb3323..9877a11 100644 --- a/src/util/Constants.ts +++ b/src/util/Constants.ts @@ -401,6 +401,9 @@ export enum JSON_ERROR_CODES { INVALID_CHANNEL_DELETE_COMMUNITY = 50074, // UNKNOWN 50075-50080, INVALID_STICKER_SENT = 50081, + INVALID_THREAD_OPERATION = 50083, + INVALID_THREAD_NOTIFICATION_SETTINGS, + INVALID_THREAD_TIMESTAMP, MFA_ENABLED = 60001, MFA_DISABLED, @@ -498,6 +501,11 @@ export enum PERMISSION_FLAGS { MANAGE_ROLES = 1 << 28, MANAGE_WEBHOOKS = 1 << 29, MANAGE_EMOJIS = 1 << 30, + USE_SLASH_COMMANDS = 1 << 31, + REQUEST_TO_SPEAK = 1 << 32, + MANAGE_THREADS = 1 << 34, + USE_PUBLIC_THREADS = 1 << 35, + USE_PRIVATE_THREADS = 1 << 36, } // List of all limits diff --git a/structures/Guild.ts b/structures/Guild.ts index 1ef28bf..2f70b18 100644 --- a/structures/Guild.ts +++ b/structures/Guild.ts @@ -42,6 +42,7 @@ export default interface Guild extends Base { splash: string | null; system_channel_flags: SystemChannelFlags; system_channel_id: string | null; + threads?: Channel[]; unavailable?: boolean; vanity_url_code: string | null; verification_level: VerificationLevel; diff --git a/ws/constants.ts b/ws/constants.ts index 1f1f355..2cb900a 100644 --- a/ws/constants.ts +++ b/ws/constants.ts @@ -31,6 +31,12 @@ export const EVENTS = { MESSAGE_REACTION_REMOVE_EMOJI: 'messageReactionRemoveEmoji', PRESENCE_UPDATE: 'presenceUpdate', TYPING_START: 'typingStart', + THREAD_CREATE: 'threadCreate', + THREAD_UPDATE: 'threadUpdate', + THREAD_DELETE: 'threadDelete', + THREAD_LIST_SYNC: 'threadListSync', + THREAD_MEMBER_UPDATE: 'threadMemberUpdate', + THREAD_MEMBERS_UPDATE: 'threadMembersUpdate', USER_UPDATE: 'userUpdate', VOICE_STATE_UPDATE: 'voiceStateUpdate', VOICE_SERVER_UPDATE: 'guildServerUpdate', From a84f8c1a55c0a03ab2364f695354020ae0b7b72d Mon Sep 17 00:00:00 2001 From: SiroTM Date: Sun, 6 Jun 2021 12:08:48 -0400 Subject: [PATCH 2/7] refactor(Threads): Endpoints --- rest/Endpoints.ts | 128 ++++++++++++++++++++++------------------------ src/Client.ts | 15 ++---- 2 files changed, 65 insertions(+), 78 deletions(-) diff --git a/rest/Endpoints.ts b/rest/Endpoints.ts index 172a6cd..9937587 100644 --- a/rest/Endpoints.ts +++ b/rest/Endpoints.ts @@ -67,73 +67,6 @@ export default class Endpoints { public static CHANNEL_MESSAGE_REACTIONS(channelID: string, messageID: string) { return `/channels/${channelID}/messages/${messageID}/reactions`; } - /** - * `/channels/{channel.id}/messages/{message.id}/threads` - * - POST - Create new thread from existing message - */ - public static START_THREAD_WITH_MESSAGE(channelID: string, messageID: string) { - return `/channels/${channelID}/messages/${messageID}/threads`; - } - /** - * `/channels/{channel.id}/threads` - * - POST - Creates a new thread that is not connected to an existing message - */ - public static START_THREAD_WITHOUT_MESSAGE(channelID: string) { - return `/channels/${channelID}/threads`; - } - /** - * `/channels/{channel.id}/thread-members/@me` - * - PUT - Adds the current user to a thread - * - DELETE - Removes the current user from a thread - */ - public static THREAD(channelID: string) { - return `/channels/${channelID}/thread-members/@me`; - } - /** - * `/channels/{channel.id}/thread-members/{user.id}` - * - PUT - Adds another member to a thread - * - DELETE - Removes another member from a thread - */ - public static THREAD_MEMBER(channelID: string, userID: string) { - return `/channels/${channelID}/thread-members/${userID}`; - } - /** - * `/channels/{channel.id}/thread-members` - * - GET - Return array of thread members objects that are members of the thread - */ - public static LIST_THREAD_MEMBERS(channelID: string) { - return `/channels/${channelID}/thread-members`; - } - /** - * `/channels/{channel.id}/threads/active` - * - GET - Return all active threads in the channel - */ - public static LIST_ACTIVE_THREADS(channelID: string) { - return `/channels/${channelID}/thread/active`; - } - /** - * `/channels/{channel.id}/threads/archived/public` - * - GET - Return archived threads in the channel that are public - */ - public static LIST_PUBLIC_ARCHIVED_THREADS(channelID: string) { - return `/channels/${channelID}/threads/archived/public`; - } - /** - * `/channels/{channel.id}/threads/archived/private` - * - GET - Return archived threads in the channel that are of type GUILD_PRIVATE_THREAD - */ - public static LIST_PRIVATE_ARCHIVED_THREADS(channelID: string) { - return `/channels/${channelID}/threads/archived/private`; - } - /** - * `/channels/{channel.id}/users/@me/threads/archived/private` - * - GET - Return archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined - */ - public static LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID: string) { - return `/channels/${channelID}/users/@me/threads/archived/private`; - } - - /** * `/channels/:channelID/messages/bulk-delete` * - POST - Bulk Delete Messages @@ -430,6 +363,67 @@ export default class Endpoints { return `/guilds/${guildID}/templates/${code}`; } + // Threads + /** + * `/channels/{channel.id}/messages/{message.id}/threads` + * - POST - Create new thread from existing message + */ + public static START_THREAD_WITH_MESSAGE(channelID: string, messageID: string) { + return `/channels/${channelID}/messages/${messageID}/threads`; + } + /** + * `/channels/{channel.id}/threads` + * - POST - Creates a new thread that is not connected to an existing message + */ + public static START_THREAD_WITHOUT_MESSAGE(channelID: string) { + return `/channels/${channelID}/threads`; + } + /** + * `/channels/{channel.id}/thread-members/@me` + * - PUT - Adds the current user to a thread + * - DELETE - Removes the current user from a thread + */ + public static THREAD(channelID: string) { + return `/channels/${channelID}/thread-members/@me`; + } + /** + * `/channels/{channel.id}/thread-members/{user.id}` + * - PUT - Adds another member to a thread + * - DELETE - Removes another member from a thread + */ + public static THREAD_MEMBER(channelID: string, userID: string) { + return `/channels/${channelID}/thread-members/${userID}`; + } + /** + * `/channels/{channel.id}/thread-members` + * - GET - Return array of thread members objects that are members of the thread + */ + public static LIST_THREAD_MEMBERS(channelID: string) { + return `/channels/${channelID}/thread-members`; + } + /** + * `/channels/{channel.id}/threads/active` + * - GET - Return all active threads in the channel + */ + public static LIST_ACTIVE_THREADS(channelID: string) { + return `/channels/${channelID}/threads/active`; + } + /** + * `/channels/{channel.id}/threads/archived/public OR private` + * - GET & type = public - Return archived threads in the channel that are public + * - GET & type = private - Return archived threads in the channel that are of type GUILD_PRIVATE_THREAD + */ + public static LIST_ARCHIVED_THREADS(channelID: string, type: 'public'|'private') { + return `/channels/${channelID}/threads/archived/${type}`; + } + /** + * `/channels/{channel.id}/users/@me/threads/archived/private` + * - GET - Return archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined + */ + public static LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID: string) { + return `/channels/${channelID}/users/@me/threads/archived/private`; + } + // User /** * `/users/:userID` diff --git a/src/Client.ts b/src/Client.ts index 7027b3c..d784ef0 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -519,22 +519,15 @@ export default class Client { return this.rest.request('GET', Endpoints.LIST_ACTIVE_THREADS(channelID), true); } - listJoinedPrivateArchivedThreads(channelID: string, params: any = {}) { - return this.rest.request('GET', Endpoints.LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID), true, { + listArchivedThreads(channelID: string, type: 'public'|'private', params: any = {}) { + return this.rest.request('GET', Endpoints.LIST_ARCHIVED_THREADS(channelID, type), true, { before: params.before, limit: params.limit, }); } - listPrivateArchivedThreads(channelID: string, params: any = {}) { - return this.rest.request('GET', Endpoints.LIST_PRIVATE_ARCHIVED_THREADS(channelID), true, { - before: params.before, - limit: params.limit, - }); - } - - listPublicArchivedThreads(channelID: string, params: any = {}) { - return this.rest.request('GET', Endpoints.LIST_PUBLIC_ARCHIVED_THREADS(channelID), true, { + listJoinedPrivateArchivedThreads(channelID: string, params: any = {}) { + return this.rest.request('GET', Endpoints.LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID), true, { before: params.before, limit: params.limit, }); From f46f23aa527b477aaac20c087b9434a64252eed5 Mon Sep 17 00:00:00 2001 From: SiroTM <80137236+SiroTM@users.noreply.github.com> Date: Sun, 6 Jun 2021 18:27:00 -0400 Subject: [PATCH 3/7] Update rest/Endpoints.ts Co-authored-by: bsian03 --- rest/Endpoints.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/Endpoints.ts b/rest/Endpoints.ts index 9937587..fb1eebe 100644 --- a/rest/Endpoints.ts +++ b/rest/Endpoints.ts @@ -413,7 +413,7 @@ export default class Endpoints { * - GET & type = public - Return archived threads in the channel that are public * - GET & type = private - Return archived threads in the channel that are of type GUILD_PRIVATE_THREAD */ - public static LIST_ARCHIVED_THREADS(channelID: string, type: 'public'|'private') { + public static LIST_ARCHIVED_THREADS(channelID: string, type: 'public' | 'private') { return `/channels/${channelID}/threads/archived/${type}`; } /** From 8838faa5bb72b4e6bec5e09ab58d300a4cbdbf98 Mon Sep 17 00:00:00 2001 From: SiroTM Date: Mon, 7 Jun 2021 08:11:25 -0400 Subject: [PATCH 4/7] refactor(Threads): Endpoints description --- rest/Endpoints.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rest/Endpoints.ts b/rest/Endpoints.ts index fb1eebe..ce85107 100644 --- a/rest/Endpoints.ts +++ b/rest/Endpoints.ts @@ -366,7 +366,7 @@ export default class Endpoints { // Threads /** * `/channels/{channel.id}/messages/{message.id}/threads` - * - POST - Create new thread from existing message + * - POST - Creates a new thread from an existing message */ public static START_THREAD_WITH_MESSAGE(channelID: string, messageID: string) { return `/channels/${channelID}/messages/${messageID}/threads`; @@ -396,29 +396,29 @@ export default class Endpoints { } /** * `/channels/{channel.id}/thread-members` - * - GET - Return array of thread members objects that are members of the thread + * - GET - Returns array of thread members objects that are members of the thread */ public static LIST_THREAD_MEMBERS(channelID: string) { return `/channels/${channelID}/thread-members`; } /** * `/channels/{channel.id}/threads/active` - * - GET - Return all active threads in the channel + * - GET - Returns all active threads in the channel, including public and private threads */ public static LIST_ACTIVE_THREADS(channelID: string) { return `/channels/${channelID}/threads/active`; } /** * `/channels/{channel.id}/threads/archived/public OR private` - * - GET & type = public - Return archived threads in the channel that are public - * - GET & type = private - Return archived threads in the channel that are of type GUILD_PRIVATE_THREAD + * - GET & type = public - Returns archived threads in the channel that are public + * - GET & type = private - Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD */ public static LIST_ARCHIVED_THREADS(channelID: string, type: 'public' | 'private') { return `/channels/${channelID}/threads/archived/${type}`; } /** * `/channels/{channel.id}/users/@me/threads/archived/private` - * - GET - Return archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined + * - GET - Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined */ public static LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID: string) { return `/channels/${channelID}/users/@me/threads/archived/private`; From ea1a0611ece747ca1a06739a69bc19244dd72c0d Mon Sep 17 00:00:00 2001 From: SiroTM Date: Mon, 7 Jun 2021 08:21:40 -0400 Subject: [PATCH 5/7] refactor(Threads): Endpoints description2 --- rest/Endpoints.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rest/Endpoints.ts b/rest/Endpoints.ts index ce85107..35f2444 100644 --- a/rest/Endpoints.ts +++ b/rest/Endpoints.ts @@ -365,21 +365,21 @@ export default class Endpoints { // Threads /** - * `/channels/{channel.id}/messages/{message.id}/threads` + * `/channels/:channelID/messages/:messageID/threads` * - POST - Creates a new thread from an existing message */ public static START_THREAD_WITH_MESSAGE(channelID: string, messageID: string) { return `/channels/${channelID}/messages/${messageID}/threads`; } /** - * `/channels/{channel.id}/threads` + * `/channels/:channelID/threads` * - POST - Creates a new thread that is not connected to an existing message */ public static START_THREAD_WITHOUT_MESSAGE(channelID: string) { return `/channels/${channelID}/threads`; } /** - * `/channels/{channel.id}/thread-members/@me` + * `/channels/:channelID/thread-members/@me` * - PUT - Adds the current user to a thread * - DELETE - Removes the current user from a thread */ @@ -387,7 +387,7 @@ export default class Endpoints { return `/channels/${channelID}/thread-members/@me`; } /** - * `/channels/{channel.id}/thread-members/{user.id}` + * `/channels/:channelID/thread-members/:userID` * - PUT - Adds another member to a thread * - DELETE - Removes another member from a thread */ @@ -395,21 +395,21 @@ export default class Endpoints { return `/channels/${channelID}/thread-members/${userID}`; } /** - * `/channels/{channel.id}/thread-members` + * `/channels/:channelID/thread-members` * - GET - Returns array of thread members objects that are members of the thread */ public static LIST_THREAD_MEMBERS(channelID: string) { return `/channels/${channelID}/thread-members`; } /** - * `/channels/{channel.id}/threads/active` + * `/channels/:channelID/threads/active` * - GET - Returns all active threads in the channel, including public and private threads */ public static LIST_ACTIVE_THREADS(channelID: string) { return `/channels/${channelID}/threads/active`; } /** - * `/channels/{channel.id}/threads/archived/public OR private` + * `/channels/:channelID}/threads/archived/public OR private` * - GET & type = public - Returns archived threads in the channel that are public * - GET & type = private - Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD */ @@ -417,7 +417,7 @@ export default class Endpoints { return `/channels/${channelID}/threads/archived/${type}`; } /** - * `/channels/{channel.id}/users/@me/threads/archived/private` + * `/channels/:channelID/users/@me/threads/archived/private` * - GET - Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined */ public static LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID: string) { From 3df8a54c91f8eb3031fb0258a652d702398a35f2 Mon Sep 17 00:00:00 2001 From: SiroTM Date: Sun, 13 Jun 2021 19:06:38 -0400 Subject: [PATCH 6/7] refactor(Threads): Endpoints description3 --- rest/Endpoints.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rest/Endpoints.ts b/rest/Endpoints.ts index 35f2444..c560b91 100644 --- a/rest/Endpoints.ts +++ b/rest/Endpoints.ts @@ -366,59 +366,59 @@ export default class Endpoints { // Threads /** * `/channels/:channelID/messages/:messageID/threads` - * - POST - Creates a new thread from an existing message + * - POST - Start Thread with Message */ public static START_THREAD_WITH_MESSAGE(channelID: string, messageID: string) { return `/channels/${channelID}/messages/${messageID}/threads`; } /** * `/channels/:channelID/threads` - * - POST - Creates a new thread that is not connected to an existing message + * - POST - Start Thread without Message */ public static START_THREAD_WITHOUT_MESSAGE(channelID: string) { return `/channels/${channelID}/threads`; } /** * `/channels/:channelID/thread-members/@me` - * - PUT - Adds the current user to a thread - * - DELETE - Removes the current user from a thread + * - PUT - Join Thread + * - DELETE - Leave Thread */ public static THREAD(channelID: string) { return `/channels/${channelID}/thread-members/@me`; } /** * `/channels/:channelID/thread-members/:userID` - * - PUT - Adds another member to a thread - * - DELETE - Removes another member from a thread + * - PUT - Add Thread Member + * - DELETE - Remove Thread Member */ public static THREAD_MEMBER(channelID: string, userID: string) { return `/channels/${channelID}/thread-members/${userID}`; } /** * `/channels/:channelID/thread-members` - * - GET - Returns array of thread members objects that are members of the thread + * - GET - List Thread Members */ public static LIST_THREAD_MEMBERS(channelID: string) { return `/channels/${channelID}/thread-members`; } /** * `/channels/:channelID/threads/active` - * - GET - Returns all active threads in the channel, including public and private threads + * - GET - List Active Threads */ public static LIST_ACTIVE_THREADS(channelID: string) { return `/channels/${channelID}/threads/active`; } /** * `/channels/:channelID}/threads/archived/public OR private` - * - GET & type = public - Returns archived threads in the channel that are public - * - GET & type = private - Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD + * - GET & type = public - List Public Archived Threads + * - GET & type = private - List Private Archived Threads */ public static LIST_ARCHIVED_THREADS(channelID: string, type: 'public' | 'private') { return `/channels/${channelID}/threads/archived/${type}`; } /** * `/channels/:channelID/users/@me/threads/archived/private` - * - GET - Returns archived threads in the channel that are of type GUILD_PRIVATE_THREAD, and the user has joined + * - GET - List Joined Private Archived Threads */ public static LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID: string) { return `/channels/${channelID}/users/@me/threads/archived/private`; From a3bf2572980c688f055aa4bd4626c5b437e86550 Mon Sep 17 00:00:00 2001 From: SiroTM Date: Tue, 15 Jun 2021 16:41:00 -0400 Subject: [PATCH 7/7] revert src folder --- src/Client.ts | 52 ------------------------------------------- src/util/Constants.ts | 8 ------- 2 files changed, 60 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index d784ef0..cfeeffe 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -38,10 +38,6 @@ export default class Client { return this.rest.request('PUT', Endpoints.CHANNEL_PINNED_MESSAGE(channelID, messageID), true); } - addThreadMember(channelID: string, userID: string) { - return this.rest.request('PUT', Endpoints.THREAD_MEMBER(channelID, userID), true); - } - beginGuildPrune(guildID: string, params: any = {}) { return this.rest.request('POST', Endpoints.GUILD_PRUNE(guildID), true, { days: params.days, @@ -503,40 +499,10 @@ export default class Client { : this.rest.request('GET', Endpoints.WEBHOOK(webhookID), true); } - joinThread(channelID: string) { - return this.rest.request('PUT', Endpoints.THREAD(channelID), true); - } - leaveGuild(guildID: string) { return this.rest.request('DELETE', Endpoints.USER_GUILD(guildID), true); } - leaveThread(channelID: string) { - return this.rest.request('DELETE', Endpoints.THREAD(channelID), true); - } - - listActiveThreads(channelID: string) { - return this.rest.request('GET', Endpoints.LIST_ACTIVE_THREADS(channelID), true); - } - - listArchivedThreads(channelID: string, type: 'public'|'private', params: any = {}) { - return this.rest.request('GET', Endpoints.LIST_ARCHIVED_THREADS(channelID, type), true, { - before: params.before, - limit: params.limit, - }); - } - - listJoinedPrivateArchivedThreads(channelID: string, params: any = {}) { - return this.rest.request('GET', Endpoints.LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID), true, { - before: params.before, - limit: params.limit, - }); - } - - listThreadMembers(channelID: string) { - return this.rest.request('GET', Endpoints.LIST_THREAD_MEMBERS(channelID), true); - } - listVoiceRegions() { return this.rest.request('GET', Endpoints.VOICE_REGIONS(), true); } @@ -560,24 +526,6 @@ export default class Client { return this.rest.request('DELETE', Endpoints.GUILD_MEMBER_ROLE(guildID, userID, roleID), true); } - removeThreadMember(channelID: string, userID: string) { - return this.rest.request('DELETE', Endpoints.THREAD_MEMBER(channelID, userID), true); - } - - startThreadWithMessage(channelID: string, messageID: string, params: any = {}) { - return this.rest.request('POST', Endpoints.START_THREAD_WITH_MESSAGE(channelID, messageID), true, { - name: params.name, - auto_archive_duration: params.autoArchiveDuration, - }); - } - - startThreadWithoutMessage(channelID: string, params: any = {}) { - return this.rest.request('POST', Endpoints.START_THREAD_WITHOUT_MESSAGE(channelID), true, { - name: params.name, - auto_archive_duration: params.autoArchiveDuration, - }); - } - syncGuildIntegration(guildID: string, integrationID: string) { return this.rest.request('POST', Endpoints.GUILD_INTEGRATION_SYNC(guildID, integrationID), true); } diff --git a/src/util/Constants.ts b/src/util/Constants.ts index 9877a11..ffb3323 100644 --- a/src/util/Constants.ts +++ b/src/util/Constants.ts @@ -401,9 +401,6 @@ export enum JSON_ERROR_CODES { INVALID_CHANNEL_DELETE_COMMUNITY = 50074, // UNKNOWN 50075-50080, INVALID_STICKER_SENT = 50081, - INVALID_THREAD_OPERATION = 50083, - INVALID_THREAD_NOTIFICATION_SETTINGS, - INVALID_THREAD_TIMESTAMP, MFA_ENABLED = 60001, MFA_DISABLED, @@ -501,11 +498,6 @@ export enum PERMISSION_FLAGS { MANAGE_ROLES = 1 << 28, MANAGE_WEBHOOKS = 1 << 29, MANAGE_EMOJIS = 1 << 30, - USE_SLASH_COMMANDS = 1 << 31, - REQUEST_TO_SPEAK = 1 << 32, - MANAGE_THREADS = 1 << 34, - USE_PUBLIC_THREADS = 1 << 35, - USE_PRIVATE_THREADS = 1 << 36, } // List of all limits