Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Threads): API v9, add rest support for Threads #31

Open
wants to merge 7 commits into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions rest/Endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,67 @@ export default class Endpoints {
return `/guilds/${guildID}/templates/${code}`;
}

// Threads
/**
* `/channels/:channelID/messages/:messageID/threads`
* - POST - Start Thread with Message
*/
public static START_THREAD_WITH_MESSAGE(channelID: string, messageID: string) {
SiroTM marked this conversation as resolved.
Show resolved Hide resolved
return `/channels/${channelID}/messages/${messageID}/threads`;
}
/**
* `/channels/:channelID/threads`
* - POST - Start Thread without Message
*/
public static START_THREAD_WITHOUT_MESSAGE(channelID: string) {
return `/channels/${channelID}/threads`;
}
/**
* `/channels/:channelID/thread-members/@me`
* - PUT - Join Thread
* - DELETE - Leave Thread
*/
public static THREAD(channelID: string) {
return `/channels/${channelID}/thread-members/@me`;
}
/**
* `/channels/:channelID/thread-members/:userID`
* - 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 - List Thread Members
*/
public static LIST_THREAD_MEMBERS(channelID: string) {
return `/channels/${channelID}/thread-members`;
}
/**
* `/channels/:channelID/threads/active`
* - 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 - 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 - List Joined Private Archived Threads
*/
public static LIST_JOINED_PRIVATE_ARCHIVED_THREADS(channelID: string) {
return `/channels/${channelID}/users/@me/threads/archived/private`;
}

// User
/**
* `/users/:userID`
Expand Down
2 changes: 1 addition & 1 deletion rest/RESTClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions structures/Guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions ws/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down