feat: api v9 and threads (#5570)

Co-authored-by: Noel <icrawltogo@gmail.com>
Co-authored-by: Amish Shah <dev@shah.gg>
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
Co-authored-by: SynthGhost <60333233+synthghost@users.noreply.github.com>
Co-authored-by: SpaceEEC <24881032+SpaceEEC@users.noreply.github.com>
Co-authored-by: Elliot <elliot@maisl.fr>
Co-authored-by: Antonio Román <kyradiscord@gmail.com>
Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com>
This commit is contained in:
ckohen
2021-06-24 12:48:29 -07:00
committed by GitHub
parent ea49f7ca74
commit 7346621d15
34 changed files with 1461 additions and 24 deletions

View File

@@ -10,7 +10,7 @@ const SnowflakeUtil = require('../util/SnowflakeUtil');
* @abstract
*/
class Channel extends Base {
constructor(client, data) {
constructor(client, data, immediatePatch = true) {
super(client);
const type = ChannelTypes[data.type];
@@ -22,6 +22,9 @@ class Channel extends Base {
* * `category` - a guild category channel
* * `news` - a guild news channel
* * `store` - a guild store channel
* * 'news_thread` - a guild news channels' public thread channel
* * `public_thread` - a guild text channels' public thread channel
* * `private_thread` - a guild text channels' private thread channel
* * `stage` - a guild stage channel
* * `unknown` - a generic channel of unknown type, could be Channel or GuildChannel
* @type {string}
@@ -34,7 +37,7 @@ class Channel extends Base {
*/
this.deleted = false;
if (data) this._patch(data);
if (data && immediatePatch) this._patch(data);
}
_patch(data) {
@@ -152,6 +155,14 @@ class Channel extends Base {
channel = new StageChannel(guild, data);
break;
}
case ChannelTypes.NEWS_THREAD:
case ChannelTypes.PUBLIC_THREAD:
case ChannelTypes.PRIVATE_THREAD: {
const ThreadChannel = Structures.get('ThreadChannel');
channel = new ThreadChannel(guild, data);
channel.parent?.threads.cache.set(channel.id, channel);
break;
}
}
if (channel) guild.channels?.cache.set(channel.id, channel);
}