Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 65cb0ab
Author: bsian03 <chharry321@gmail.com>
Date:   Fri Sep 3 02:31:17 2021 +0100

    Actually return the member

commit fbcbb25
Author: bsian03 <chharry321@gmail.com>
Date:   Fri Sep 3 02:14:48 2021 +0100

    Add thread channel ID to guild map on thread update

commit b861556
Merge: 69d5acc daedb2b
Author: bsian03 <chharry321@gmail.com>
Date:   Fri Sep 3 01:51:07 2021 +0100

    Merge branch 'dev' into v9

commit 69d5acc
Author: bsian03 <chharry321@gmail.com>
Date:   Fri Sep 3 01:44:18 2021 +0100

    No one saw this

commit c09be80
Author: bsian03 <chharry321@gmail.com>
Date:   Fri Sep 3 01:43:56 2021 +0100

    This is a better fix

commit 3e3f623
Author: bsian03 <chharry321@gmail.com>
Date:   Fri Sep 3 01:42:13 2021 +0100

    Fix not sending newly cached thread channel

commit daedb2b
Author: Donovan Daniels <hewwo@yiff.rocks>
Date:   Thu Sep 2 16:40:24 2021 -0500

    Sticker Sending (abalabahaha#1252)

    Co-Authored-By: Catboy <elijahchristopherjohnson@gmail.com>
    Co-authored-by: bsian03 <chharry321@gmail.com>

commit 6e49901
Merge: a8d9a6a e357991
Author: bsian03 <chharry321@gmail.com>
Date:   Tue Aug 31 22:39:20 2021 +0100

    Merge branch 'dev' into v9

commit a8d9a6a
Author: bsian03 <chharry321@gmail.com>
Date:   Tue Aug 31 22:33:46 2021 +0100

    Correct permission name

commit 9bb0a17
Author: bsian03 <chharry321@gmail.com>
Date:   Tue Aug 31 22:32:14 2021 +0100

    Thread metadata locked guaranteed

commit e357991
Author: 5antos <66580910+5antos@users.noreply.github.com>
Date:   Sun Aug 29 23:18:45 2021 +0100

    Enhancements for VoiceChannel join methods (abalabahaha#1195)

    Co-authored-by: Almeida <almeidx@pm.me>
    Co-authored-by: bsian03 <chharry321@gmail.com>

commit f3a4435
Author: bsian03 <chharry321@gmail.com>
Date:   Sat Aug 28 23:59:50 2021 +0100

    Documentation fixes

commit 6af124d
Merge: 890465d 53da0d5
Author: Bsian <chharry321@gmail.com>
Date:   Sun Aug 22 12:29:24 2021 +0100

    Merge branch 'dev' of https://github.com/abalabahaha/eris into v9

commit 890465d
Author: Bsian <chharry321@gmail.com>
Date:   Fri Aug 20 19:27:03 2021 +0100

    added thread member presence is nullable

commit afad66e
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 18 00:25:54 2021 +0100

    Send messages in threads permission

commit 134f5b9
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 18 00:14:53 2021 +0100

    PrivateThread invitable

commit 000732b
Author: Bsian <chharry321@gmail.com>
Date:   Tue Aug 17 21:24:58 2021 +0100

    Seem to have somehow forgotten to remove this

commit b7b7fba
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 11 14:48:58 2021 +0100

    getActiveThreads dep to getActiveGuildThreads

commit bee0cfe
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 11 14:16:30 2021 +0100

    Doc updates r.e. v10

commit a0a75f4
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 11 14:10:47 2021 +0100

    Lint

commit f85da81
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 11 14:10:33 2021 +0100

    Update member cache on threadMembersUpdate

commit 098e04c
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 11 13:51:20 2021 +0100

    Fix caching IDs for threadMembersUpdate

commit 4e86f70
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 11 13:33:57 2021 +0100

    Support threads in audit log

commit 3778a27
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 11 13:18:46 2021 +0100

    Correct defaultAutoArchiveDuration prop names

commit 4e3a2f6
Author: Bsian <chharry321@gmail.com>
Date:   Wed Aug 4 11:58:37 2021 +0100

    Lint

commit 9f04f8d
Author: Bsian <chharry321@gmail.com>
Date:   Tue Aug 3 21:48:10 2021 +0100

    Cache all incoming THREAD_UPDATEs

commit 24b04d7
Author: Bsian <chharry321@gmail.com>
Date:   Tue Aug 3 16:19:07 2021 +0100

    Circular import fix

commit 1fad0e4
Author: Bsian <chharry321@gmail.com>
Date:   Tue Aug 3 15:44:01 2021 +0100

    Fix thread parent ID docs

commit e84743a
Author: Bsian <chharry321@gmail.com>
Date:   Tue Aug 3 15:23:26 2021 +0100

    Update stage instance members properly

commit b5a0a88
Author: Bsian <chharry321@gmail.com>
Date:   Tue Aug 3 15:20:10 2021 +0100

    Correct typings (message ternary checks)

commit 448dcb0
Author: Bsian <chharry321@gmail.com>
Date:   Tue Aug 3 15:13:44 2021 +0100

    Typings fixes (class implementations)

commit 083f94e
Author: Bsian <chharry321@gmail.com>
Date:   Mon Aug 2 17:43:01 2021 +0100

    Fix permissionsOf when run in stage channels

commit 29a5ca8
Author: Bsian <chharry321@gmail.com>
Date:   Sun Aug 1 15:36:55 2021 +0100

    Correct getActiveThreads

commit 6aaae35
Author: bsian03 <chharry321@gmail.com>
Date:   Sun Aug 1 14:46:49 2021 +0100

    Lint

    Co-authored-by: iiFDCT <35053522+iiFDCT@users.noreply.github.com>

commit ffb5548
Author: bsian03 <chharry321@gmail.com>
Date:   Fri Jul 30 23:54:48 2021 +0100

    also for 18

commit b499354
Author: bsian03 <chharry321@gmail.com>
Date:   Fri Jul 30 22:59:02 2021 +0100

    Add case for type 21

commit b75a28e
Author: Bsian <chharry321@gmail.com>
Date:   Tue Jul 13 12:07:26 2021 +0100

    Prefix client prop

commit 9fad4da
Author: Donovan Daniels <hewwo@yiff.rocks>
Date:   Mon Jul 12 05:04:35 2021 -0500

    Fix typings for creating thread messages (#15)

commit 3a1b26a
Author: Bsian <chharry321@gmail.com>
Date:   Fri Jul 2 13:09:18 2021 +0100

    Pass client in param

commit f8f77c6
Author: Bsian <chharry321@gmail.com>
Date:   Wed Jun 30 09:20:15 2021 +0100

    Consistency

commit 2b23918
Author: Bsian <chharry321@gmail.com>
Date:   Wed Jun 30 09:16:23 2021 +0100

    Support editing thread default archive duration

commit 5147bda
Author: Bsian <chharry321@gmail.com>
Date:   Wed Jun 30 09:05:12 2021 +0100

    Support stage instance invites

commit 83bbbdf
Author: Bsian <chharry321@gmail.com>
Date:   Wed Jun 30 00:18:53 2021 +0100

    Update threads to documentation

commit 54376a0
Author: Bsian <chharry321@gmail.com>
Date:   Wed Jun 30 00:06:03 2021 +0100

    Support stage instances in audit log

commit 3d57bef
Author: Bsian <chharry321@gmail.com>
Date:   Tue Jun 29 23:45:02 2021 +0100

    Fix getChannel using channels prop when getting thread channel

commit 7678cde
Author: Bsian <chharry321@gmail.com>
Date:   Tue Jun 29 23:44:35 2021 +0100

    No idea how this trailing whitespace got here

commit 9bfe422
Author: Bsian <chharry321@gmail.com>
Date:   Tue Jun 29 23:42:59 2021 +0100

    Cover channel types in Channel.from

commit 34a6623
Author: Bsian <chharry321@gmail.com>
Date:   Tue Jun 29 23:42:48 2021 +0100

    Fix incorrectly named constructor param

commit b405958
Author: Bsian <chharry321@gmail.com>
Date:   Tue Jun 29 23:35:39 2021 +0100

    Add missing functionality methods

commit 5184e45
Author: Bsian <chharry321@gmail.com>
Date:   Tue Jun 29 22:55:02 2021 +0100

    Correct documentation

commit 289b834
Author: Bsian <chharry321@gmail.com>
Date:   Wed Jun 23 22:40:00 2021 +0100

    Thread without message type

commit 6709477
Author: Bsian <chharry321@gmail.com>
Date:   Wed Jun 23 22:33:49 2021 +0100

    Update method names and docs to match Discord

commit a3b0fea
Author: Bsian <chharry321@gmail.com>
Date:   Wed Jun 23 22:05:36 2021 +0100

    Add channel types to thread channel classes

commit 6fcfcc7
Author: Bsian <chharry321@gmail.com>
Date:   Sat Jun 5 01:02:45 2021 +0100

    Remove Guild#region

commit b6f93de
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 16:55:51 2021 +0100

    Stage discovery

commit 239f48d
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 14:09:54 2021 +0100

    Stage instance caching and gateway events

commit 0de18ca
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 13:49:25 2021 +0100

    Fix typo

commit 47f8d20
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 13:37:30 2021 +0100

    Update Webhook interface (interaction webhooks)

commit 7b0edbb
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 10:40:50 2021 +0100

    GuildMember joinedAt can be null

commit d1186d4
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 10:37:01 2021 +0100

    Expose Message#applicationID

commit 1f20e38
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 10:33:12 2021 +0100

    Expose stage instance

commit c591b45
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 09:54:42 2021 +0100

    Extra newline

commit f8c11ea
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 09:42:20 2021 +0100

    Thread documentation clarification

commit a78baca
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 09:34:10 2021 +0100

    Support webhooks sending to thread channels

commit c6a3fd0
Author: Bsian <chharry321@gmail.com>
Date:   Thu May 27 09:19:33 2021 +0100

    Support uploading new attachments on message edit

commit e7a2401
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 23:20:34 2021 +0100

    Complete gateway events

commit 7eb457c
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 23:14:38 2021 +0100

    Doc fixes

commit 8888a27
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 23:11:20 2021 +0100

    Add ThreadMember cache

commit 8a2bc90
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 23:10:29 2021 +0100

    Discord messed up case

commit 54ef7a4
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 14:00:47 2021 +0100

    Thread events (so far)

commit b7ac7bd
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 13:48:17 2021 +0100

    Add support for stage channels in getChannel

commit e7099fa
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 10:44:10 2021 +0100

    Doc update

commit 1305ed6
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 10:27:10 2021 +0100

    Documentation update

commit 270e1f7
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 10:24:17 2021 +0100

    Add threads prop to guild

commit 5d433aa
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 10:10:53 2021 +0100

    References for ThreadMember

commit 552b7de
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 10:06:22 2021 +0100

    ThreadMember class

commit 713a43b
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 10:05:17 2021 +0100

    Fix some stuff

commit 22bf440
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 09:31:34 2021 +0100

    Typings cleanup

commit 7403f8d
Author: Bsian <chharry321@gmail.com>
Date:   Tue May 25 09:11:23 2021 +0100

    New classes and methods

commit 21e23b6
Author: Bsian <chharry321@gmail.com>
Date:   Mon May 24 23:15:19 2021 +0100

    v9 endpoints

commit 90076d7
Author: Bsian <chharry321@gmail.com>
Date:   Mon May 24 22:10:26 2021 +0100

    v9 Constants
  • Loading branch information
iiFDCT committed Sep 28, 2021
1 parent 3199243 commit 23bf320
Show file tree
Hide file tree
Showing 16 changed files with 273 additions and 105 deletions.
168 changes: 124 additions & 44 deletions index.d.ts

Large diffs are not rendered by default.

67 changes: 42 additions & 25 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ class Client extends EventEmitter {
* @arg {String} [content.messageReference.guildID] The guild ID of the referenced message
* @arg {String} content.messageReference.messageID The message ID of the referenced message. This cannot reference a system message
* @arg {String} [content.messageReferenceID] [DEPRECATED] The ID of the message should be replied to. Use `messageReference` instead
* @arg {Array<String>} [content.stickerIDs] An array of IDs corresponding to stickers to send
* @arg {Boolean} [content.tts] Set the message TTS flag
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
* @arg {Buffer} file.file A buffer containing file data
Expand All @@ -659,13 +660,12 @@ class Client extends EventEmitter {
};
} else if(content.content !== undefined && typeof content.content !== "string") {
content.content = "" + content.content;
} else if(content.content === undefined && !content.embed && !content.embeds && !file) {
return Promise.reject(new Error("No content, file, or embeds"));
} else if(content.embed && !content.embeds) {
this.emit("warn", "[DEPRECATED] content.embed is deprecated. Use content.embeds instead");
content.embeds = [content.embed];
}
content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions);
content.sticker_ids = content.stickerIDs;
if(content.messageReference) {
content.message_reference = content.messageReference;
if(content.messageReference.messageID !== undefined) {
Expand All @@ -688,8 +688,6 @@ class Client extends EventEmitter {
this.emit("warn", "[DEPRECATED] content.messageReferenceID is deprecated. Use content.messageReference instead");
content.message_reference = {message_id: content.messageReferenceID};
}
} else if(!file) {
return Promise.reject(new Error("No content, file, or embeds"));
}
return this.requestHandler.request("POST", Endpoints.CHANNEL_MESSAGES(channelID), true, content, file).then((message) => new Message(message, this));
}
Expand Down Expand Up @@ -764,13 +762,15 @@ class Client extends EventEmitter {
* @arg {String} channelID The ID of the channel
* @arg {Object} options The thread options
* @arg {Number} options.autoArchiveDuration Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
* @arg {boolean} [options.invitable] Whether non-moderators can add other non-moderators to the thread (private threads only)
* @arg {String} options.name The thread channel name
* @arg {Number} [options.type] The channel type of the thread to create. It is recommended by Discord to explicitly set this parameter as the default is highly likely to change in a future API version
* @arg {Number} [options.type] The channel type of the thread to create. It is recommended to explicitly set this property as this will be a required property in API v10
* @returns {Promise<PrivateThreadChannel>}
*/
createThreadWithoutMessage(channelID, options) {
return this.requestHandler.request("POST", Endpoints.THREAD_WITHOUT_MESSAGE(channelID), true, {
auto_archive_duration: options.autoArchiveDuration,
invitable: options.invitable,
name: options.name,
type: options.type
}).then((channel) => Channel.from(channel, this));
Expand Down Expand Up @@ -1041,8 +1041,9 @@ class Client extends EventEmitter {
* @arg {Boolean} [options.archived] The archive status of the channel (thread channels only)
* @arg {Number} [options.autoArchiveDuration] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 (thread channels only)
* @arg {Number} [options.bitrate] The bitrate of the channel (guild voice channels only)
* @arg {Number?} [options.defaultArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) (guild text/news channels only)
* @arg {Number?} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) (guild text/news channels only)
* @arg {String} [options.icon] The icon of the channel as a base64 data URI (group channels only). Note: base64 strings alone are not base64 data URI strings
* @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the channel (private thread channels only)
* @arg {Boolean} [options.locked] The lock status of the channel (thread channels only)
* @arg {String} [options.name] The name of the channel
* @arg {Boolean} [options.nsfw] The nsfw status of the channel (guild channels only)
Expand All @@ -1061,8 +1062,9 @@ class Client extends EventEmitter {
archived: options.archived,
auto_archive_duration: options.autoArchiveDuration,
bitrate: options.bitrate,
default_archive_duration: options.defaultArchiveDuration,
default_auto_archive_duration: options.defaultAutoArchiveDuration,
icon: options.icon,
invitable: options.invitable,
locked: options.locked,
name: options.name,
nsfw: options.nsfw,
Expand Down Expand Up @@ -1386,8 +1388,6 @@ class Client extends EventEmitter {
};
} else if(content.content !== undefined && typeof content.content !== "string") {
content.content = "" + content.content;
} else if(content.content === undefined && !content.embed && !content.embeds && !content.components && content.flags === undefined) {
return Promise.reject(new Error("No content, embeds, components or flags"));
} else if(content.embed && !content.embeds) {
this.emit("warn", "[DEPRECATED] content.embed is deprecated. Use content.embeds instead");
content.embeds = [content.embed];
Expand Down Expand Up @@ -1666,9 +1666,6 @@ class Client extends EventEmitter {
* @returns {Promise<Message>}
*/
editWebhookMessage(webhookID, token, messageID, options) {
if(!options.content && !options.embeds && !options.components && !options.file) {
return Promise.reject(new Error("No content, embed, components, or file"));
}
if(options.allowedMentions) {
options.allowed_mentions = this._formatAllowedMentions(options.allowedMentions);
}
Expand Down Expand Up @@ -1752,16 +1749,13 @@ class Client extends EventEmitter {
* @arg {Object | Array<Object>} [options.file] A file object (or an Array of them)
* @arg {Buffer} options.file.file A buffer containing file data
* @arg {String} options.file.name What to name the file
* @arg {Number} [options.flags] Flags to execute the webhook with, 64 for ephemeral (Interaction webhooks only)
* @arg {String} [options.threadID] The ID of the thread channel in the webhook's channel to send the message to
* @arg {Boolean} [options.tts=false] Whether the message should be a TTS message or not
* @arg {String} [options.username] A custom username, defaults to webhook default username if not specified
* @arg {Boolean} [options.wait=false] Whether to wait for the server to confirm the message create or not
* @returns {Promise<Message?>}
*/
executeWebhook(webhookID, token, options) {
if(!options.content && !options.file && !options.embeds) {
return Promise.reject(new Error("No content, embeds, or file"));
}
let qs = "";
if(options.wait) {
qs += "&wait=true";
Expand Down Expand Up @@ -1792,12 +1786,32 @@ class Client extends EventEmitter {
}

/**
* Get all active threads in a channel
* Get all active threads in a guild
* @arg {String} guildID The ID of the guild
* @returns {Promise<Object>} An object containing an array of `threads` and an array of `members`
*/
getActiveGuildThreads(guildID) {
return this.requestHandler.request("GET", Endpoints.THREADS_GUILD_ACTIVE(guildID), true).then((response) => {
return {
members: response.members.map((member) => new ThreadMember(member, this)),
threads: response.threads.map((thread) => Channel.from(thread, this))
};
});
}

/**
* [DEPRECATED] Get all active threads in a channel. Use getActiveGuildThreads instead
* @arg {String} channelID The ID of the channel
* @returns {Promise<Array<NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>>}
* @returns {Promise<Object>} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
*/
getActiveThreads(channelID) {
return this.requestHandler.request("GET", Endpoints.THREADS_ACTIVE(channelID), true).then((channels) => channels.map((c) => Channel.from(c, this)));
return this.requestHandler.request("GET", Endpoints.THREADS_ACTIVE(channelID), true).then((response) => {
return {
hasMore: response.has_more,
members: response.members.map((member) => new ThreadMember(member, this)),
threads: response.threads.map((thread) => Channel.from(thread, this))
};
});
}

/**
Expand All @@ -1807,7 +1821,7 @@ class Client extends EventEmitter {
* @arg {Object} [options] Additional options when requesting archived threads
* @arg {Date} [options.before] List of threads to return before the timestamp
* @arg {Number} [options.limit] Maximum number of threads to return
* @returns {Object} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
* @returns {Promise<Object>} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
*/
getArchivedThreads(channelID, type, options = {}) {
return this.requestHandler.request("GET", Endpoints.THREADS_ARCHIVED(channelID, type), true, options).then((response) => {
Expand Down Expand Up @@ -1915,7 +1929,7 @@ class Client extends EventEmitter {
* @arg {String} [options.before] Get entries before this entry ID
* @arg {Number} [options.limit=50] The maximum number of entries to return
* @arg {String} [options.userID] Filter entries by the user that performed the action
* @returns {Promise<{users: User[], entries: GuildAuditLogEntry[], integrations: PartialIntegration[], webhooks: Webhook[]}>}
* @returns {Promise<{entries: GuildAuditLogEntry[], integrations: PartialIntegration[], threads: (NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel)[], users: User[], webhooks: Webhook[]}>}
*/
getGuildAuditLog(guildID, options = {}, before, actionType, userID) {
if(!options || typeof options !== "object") {
Expand Down Expand Up @@ -1944,9 +1958,10 @@ class Client extends EventEmitter {
return this.requestHandler.request("GET", Endpoints.GUILD_AUDIT_LOGS(guildID), true, options).then((data) => {
const guild = this.guilds.get(guildID);
return {
users: data.users.map((user) => this.users.add(user, this)),
entries: data.audit_log_entries.map((entry) => new GuildAuditLogEntry(entry, guild)),
integrations: data.integrations.map((integration) => new GuildIntegration(integration, guild)),
threads: data.threads.map((thread) => guild.threads.update(thread, this)),
users: data.users.map((user) => this.users.add(user, this)),
webhooks: data.webhooks
};
});
Expand Down Expand Up @@ -2110,7 +2125,7 @@ class Client extends EventEmitter {
* @arg {Object} [options] Additional options when requesting archived threads
* @arg {Date} [options.before] List of threads to return before the timestamp
* @arg {Number} [options.limit] Maximum number of threads to return
* @returns {Object} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
* @returns {Promise<Object>} An object containing an array of `threads`, an array of `members` and whether the response `hasMore` threads that could be returned in a subsequent call
*/
getJoinedPrivateArchivedThreads(channelID, options = {}) {
return this.requestHandler.request("GET", Endpoints.THREADS_ARCHIVED_JOINED(channelID), true, options).then((response) => {
Expand Down Expand Up @@ -2547,6 +2562,8 @@ class Client extends EventEmitter {
* @arg {Object} [options] VoiceConnection constructor options
* @arg {Object} [options.opusOnly] Skip opus encoder initialization. You should not enable this unless you know what you are doing
* @arg {Object} [options.shared] Whether the VoiceConnection will be part of a SharedStream or not
* @arg {Boolean} [options.selfMute] Whether the bot joins the channel muted or not
* @arg {Boolean} [options.selfDeaf] Whether the bot joins the channel deafened or not
* @returns {Promise<VoiceConnection>} Resolves with a VoiceConnection
*/
joinVoiceChannel(channelID, options = {}) {
Expand All @@ -2560,8 +2577,8 @@ class Client extends EventEmitter {
this.shards.get(this.guildShardMap[this.channelGuildMap[channelID]] || 0).sendWS(Constants.GatewayOPCodes.VOICE_STATE_UPDATE, {
guild_id: this.channelGuildMap[channelID] || null,
channel_id: channelID || null,
self_mute: false,
self_deaf: false
self_mute: options.selfMute || false,
self_deaf: options.selfDeaf || false
});
if(options.opusOnly === undefined) {
options.opusOnly = this.options.opusOnly;
Expand Down
19 changes: 16 additions & 3 deletions lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ const Permissions = {
manageEmojisAndStickers: 1n << 30n, manageEmojis: 1n << 30n, // [DEPRECATED]
useApplicationCommands: 1n << 31n, useSlashCommands: 1n << 31n, // [DEPRECATED]
voiceRequestToSpeak: 1n << 32n,
useExternalStickers: 1n << 37n

manageThreads: 1n << 34n,
createPublicThreads: 1n << 35n,
createPrivateThreads: 1n << 36n,
useExternalStickers: 1n << 37n,
sendMessagesInThreads: 1n << 38n
};
Permissions.allGuild = Permissions.kickMembers
| Permissions.banMembers
Expand Down Expand Up @@ -96,7 +101,11 @@ Permissions.allText = Permissions.createInstantInvite
| Permissions.manageRoles
| Permissions.manageWebhooks
| Permissions.useApplicationCommands
| Permissions.useExternalStickers;
| Permissions.manageThreads
| Permissions.createPublicThreads
| Permissions.createPrivateThreads
| Permissions.useExternalStickers
| Permissions.sendMessagesInThreads;
Permissions.allVoice = Permissions.createInstantInvite
| Permissions.manageChannels
| Permissions.voicePrioritySpeaker
Expand Down Expand Up @@ -189,7 +198,11 @@ module.exports.AuditLogActions = {
INTEGRATION_DELETE: 82,
STAGE_INSTANCE_CREATE: 83,
STAGE_INSTANCE_UPDATE: 84,
STAGE_INSTANCE_DELETE: 85
STAGE_INSTANCE_DELETE: 85,

THREAD_CREATE: 110,
THREAD_UPDATE: 111,
THREAD_DELETE: 112
};

module.exports.MessageActivityTypes = {
Expand Down
22 changes: 20 additions & 2 deletions lib/gateway/Shard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,9 @@ class Shard extends EventEmitter {
case "THREAD_UPDATE": {
const channel = this.client.getChannel(packet.d.id);
if(!channel) {
const thread = Channel.from(packet.d, this.client);
this.emit("threadUpdate", this.client.guilds.get(packet.d.guild_id).threads.add(thread, this.client), null);
this.client.threadGuildMap[packet.d.id] = packet.d.guild_id;
break;
}
if(!(channel instanceof ThreadChannel)) {
Expand All @@ -2126,7 +2129,7 @@ class Shard extends EventEmitter {
* Fired when a thread channel is updated
* @event Client#threadUpdate
* @prop {NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel} channel The updated channel
* @prop {Object} oldChannel
* @prop {Object?} oldChannel The old thread channel. This will be null if the channel was uncached
* @prop {String} oldChannel.name The name of the channel
* @prop {Number} oldChannel.rateLimitPerUser The ratelimit of the channel, in seconds. 0 means no ratelimit is enabled
* @prop {Object} oldChannel.threadMetadata Metadata for the thread
Expand Down Expand Up @@ -2218,7 +2221,22 @@ class Shard extends EventEmitter {
removedMembers = packet.d.removed_member_ids.map((id) => channel.members.remove({id}) || {id});
}
if(packet.d.added_members) {
addedMembers = packet.d.added_members.map((m) => channel.members.update(m, this.client));
addedMembers = packet.d.added_members.map((m) => {
if(m.presence) {
m.presence.id = m.presence.user.id;
this.client.users.update(m.presence.user, this.client);
}

m.thread_id = m.id;
m.id = m.user_id;
m.member.id = m.member.user.id;
const guild = this.client.guilds.get(packet.d.guild_id);
if(guild) {
guild.members.update(m.presence, guild);
guild.members.update(m.member);
}
return channel.members.update(m, this.client);
});
}
/**
* Fired when anyone is added or removed from a thread. If the `guildMembers` intent is not specified, this will only apply for the current user
Expand Down
1 change: 1 addition & 0 deletions lib/rest/Endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ module.exports.THREAD_WITHOUT_MESSAGE = (channelID)
module.exports.THREADS_ACTIVE = (channelID) => `/channels/${channelID}/threads/active`;
module.exports.THREADS_ARCHIVED = (channelID, type) => `/channels/${channelID}/threads/archived/${type}`;
module.exports.THREADS_ARCHIVED_JOINED = (channelID) => `/channels/${channelID}/users/@me/threads/archived/private`;
module.exports.THREADS_GUILD_ACTIVE = (guildID) => `/guilds/${guildID}/threads/active`;
module.exports.USER = (userID) => `/users/${userID}`;
module.exports.USER_BILLING = (userID) => `/users/${userID}/billing`;
module.exports.USER_BILLING_PAYMENTS = (userID) => `/users/${userID}/billing/payments`;
Expand Down
8 changes: 8 additions & 0 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,14 @@ class Guild extends Base {
return this.shard.requestGuildMembers(this.id, options);
}

/**
* Get all active threads in this guild
* @returns {Promise<Object>} An object containing an array of `threads` and an array of `members`
*/
getActiveThreads() {
return this.client.getActiveThreads.call(this.client, this.id);
}

/**
* Get the audit log for the guild
* @arg {Object} [options] Options for the request. If this is a number ([DEPRECATED] behavior), it is treated as `options.limit`
Expand Down

0 comments on commit 23bf320

Please sign in to comment.