@zygout/eris 0.0.0-stage → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +108 -2
- package/esm.mjs +72 -0
- package/index.d.ts +4407 -0
- package/index.js +75 -0
- package/lib/Client.js +4708 -0
- package/lib/Constants.d.ts +990 -0
- package/lib/Constants.js +1163 -0
- package/lib/command/Command.js +552 -0
- package/lib/command/CommandClient.js +460 -0
- package/lib/errors/DiscordHTTPError.js +63 -0
- package/lib/errors/DiscordRESTError.js +77 -0
- package/lib/gateway/Shard.js +3029 -0
- package/lib/gateway/ShardManager.js +164 -0
- package/lib/rest/Endpoints.js +172 -0
- package/lib/rest/RequestHandler.js +459 -0
- package/lib/structures/ApplicationCommand.js +125 -0
- package/lib/structures/AutoModerationRule.js +143 -0
- package/lib/structures/AutocompleteInteraction.js +80 -0
- package/lib/structures/Base.js +81 -0
- package/lib/structures/CategoryChannel.js +77 -0
- package/lib/structures/Channel.js +98 -0
- package/lib/structures/CommandInteraction.js +473 -0
- package/lib/structures/ComponentInteraction.js +538 -0
- package/lib/structures/DMChannel.js +278 -0
- package/lib/structures/Entitlement.js +77 -0
- package/lib/structures/ExtendedUser.js +46 -0
- package/lib/structures/ForumChannel.js +24 -0
- package/lib/structures/GroupChannel.js +106 -0
- package/lib/structures/Guild.js +1677 -0
- package/lib/structures/GuildAuditLogEntry.js +190 -0
- package/lib/structures/GuildChannel.js +128 -0
- package/lib/structures/GuildIntegration.js +99 -0
- package/lib/structures/GuildPreview.js +97 -0
- package/lib/structures/GuildScheduledEvent.js +176 -0
- package/lib/structures/GuildTemplate.js +76 -0
- package/lib/structures/GuildTextableChannel.js +260 -0
- package/lib/structures/Interaction.js +133 -0
- package/lib/structures/Invite.js +143 -0
- package/lib/structures/Lobby.js +108 -0
- package/lib/structures/LobbyMember.js +59 -0
- package/lib/structures/MediaChannel.js +216 -0
- package/lib/structures/Member.js +371 -0
- package/lib/structures/Message.js +708 -0
- package/lib/structures/ModalSubmitInteraction.js +478 -0
- package/lib/structures/NewsChannel.js +34 -0
- package/lib/structures/NewsThreadChannel.js +12 -0
- package/lib/structures/Permission.js +80 -0
- package/lib/structures/PermissionOverwrite.js +32 -0
- package/lib/structures/PingInteraction.js +39 -0
- package/lib/structures/PrivateThreadChannel.js +25 -0
- package/lib/structures/PublicThreadChannel.js +26 -0
- package/lib/structures/Role.js +163 -0
- package/lib/structures/SKU.js +80 -0
- package/lib/structures/SoundboardSound.js +79 -0
- package/lib/structures/StageChannel.js +59 -0
- package/lib/structures/StageInstance.js +55 -0
- package/lib/structures/Subscription.js +69 -0
- package/lib/structures/TextChannel.js +202 -0
- package/lib/structures/ThreadChannel.js +143 -0
- package/lib/structures/ThreadMember.js +59 -0
- package/lib/structures/UnavailableGuild.js +26 -0
- package/lib/structures/UnknownInteraction.js +502 -0
- package/lib/structures/User.js +296 -0
- package/lib/structures/VoiceChannel.js +166 -0
- package/lib/structures/VoiceState.js +84 -0
- package/lib/util/BrowserWebSocket.js +76 -0
- package/lib/util/Bucket.js +89 -0
- package/lib/util/Collection.js +202 -0
- package/lib/util/MultipartData.js +70 -0
- package/lib/util/Opus.js +33 -0
- package/lib/util/SequentialBucket.js +83 -0
- package/lib/util/emitDeprecation.js +26 -0
- package/lib/voice/Piper.js +300 -0
- package/lib/voice/SharedStream.js +238 -0
- package/lib/voice/VoiceConnection.js +1440 -0
- package/lib/voice/VoiceConnectionManager.js +151 -0
- package/lib/voice/VoiceDataStream.js +22 -0
- package/lib/voice/streams/BaseTransformer.js +40 -0
- package/lib/voice/streams/DCAOpusTransformer.js +78 -0
- package/lib/voice/streams/FFmpegDuplex.js +192 -0
- package/lib/voice/streams/FFmpegOggTransformer.js +35 -0
- package/lib/voice/streams/FFmpegPCMTransformer.js +26 -0
- package/lib/voice/streams/OggOpusTransformer.js +108 -0
- package/lib/voice/streams/PCMOpusTransformer.js +61 -0
- package/lib/voice/streams/VolumeTransformer.js +50 -0
- package/lib/voice/streams/WebmOpusTransformer.js +258 -0
- package/package.json +81 -4
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Collection = require("../util/Collection");
|
|
4
|
+
const GuildTextableChannel = require("./GuildTextableChannel");
|
|
5
|
+
const PermissionOverwrite = require("./PermissionOverwrite");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a guild text channel. See GuildTextableChannel for more properties and methods
|
|
9
|
+
* @extends GuildTextableChannel
|
|
10
|
+
* @prop {Number} defaultAutoArchiveDuration The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080)
|
|
11
|
+
* @prop {Number?} lastPinTimestamp The timestamp of the last pinned message
|
|
12
|
+
* @prop {Boolean} nsfw Whether the channel is an NSFW channel or not
|
|
13
|
+
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in the channel
|
|
14
|
+
* @prop {Number} position The position of the channel
|
|
15
|
+
* @prop {String?} topic The topic of the channel
|
|
16
|
+
*/
|
|
17
|
+
class TextChannel extends GuildTextableChannel {
|
|
18
|
+
constructor(data, client) {
|
|
19
|
+
super(data, client);
|
|
20
|
+
this.update(data);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
update(data) {
|
|
24
|
+
super.update(data);
|
|
25
|
+
if (data.position !== undefined) {
|
|
26
|
+
this.position = data.position;
|
|
27
|
+
}
|
|
28
|
+
if (data.permission_overwrites !== undefined) {
|
|
29
|
+
this.permissionOverwrites = new Collection(PermissionOverwrite);
|
|
30
|
+
data.permission_overwrites.forEach((overwrite) => {
|
|
31
|
+
this.permissionOverwrites.add(overwrite);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (data.nsfw !== undefined) {
|
|
35
|
+
this.nsfw = data.nsfw;
|
|
36
|
+
}
|
|
37
|
+
if (data.topic !== undefined) {
|
|
38
|
+
this.topic = data.topic;
|
|
39
|
+
}
|
|
40
|
+
if (data.default_auto_archive_duration !== undefined) {
|
|
41
|
+
this.defaultAutoArchiveDuration = data.default_auto_archive_duration;
|
|
42
|
+
}
|
|
43
|
+
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Create an invite for the channel
|
|
48
|
+
* @arg {Object} [options] Invite generation options
|
|
49
|
+
* @arg {Number} [options.maxAge] How long the invite should last in seconds
|
|
50
|
+
* @arg {Number} [options.maxUses] How many uses the invite should last for
|
|
51
|
+
* @arg {String} [options.targetApplicationID] The target application id
|
|
52
|
+
* @arg {Number} [options.targetType] The type of the target application
|
|
53
|
+
* @arg {String} [options.targetUserID] The ID of the user whose stream should be displayed for the invite (`options.targetType` must be `1`)
|
|
54
|
+
* @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not
|
|
55
|
+
* @arg {Boolean} [options.unique] Whether the invite is unique or not
|
|
56
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
57
|
+
* @returns {Promise<Invite>}
|
|
58
|
+
*/
|
|
59
|
+
createInvite(options, reason) {
|
|
60
|
+
return this._client.createChannelInvite.call(this._client, this.id, options, reason);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Create a thread without an existing message
|
|
65
|
+
* @arg {Object} options The thread options
|
|
66
|
+
* @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)
|
|
67
|
+
* @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the thread (private threads only)
|
|
68
|
+
* @arg {String} options.name The thread channel name
|
|
69
|
+
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (0-21600) (does not affect bots or users with manageMessages/manageChannel permissions)
|
|
70
|
+
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
|
71
|
+
* @arg {Number} [options.type] The channel type of the thread to create. Either `10` (announcement thread, announcement channels only), `11` (public thread) or `12` (private thread)
|
|
72
|
+
* @returns {Promise<NewsThreadChannel | PublicThreadChannel | PrivateThreadChannel>}
|
|
73
|
+
*/
|
|
74
|
+
createThread(options) {
|
|
75
|
+
return this._client.createThread.call(this.client, this.id, options);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Create a thread with an existing message
|
|
80
|
+
* @arg {String} messageID The ID of the message to create the thread from
|
|
81
|
+
* @arg {Object} options The thread options
|
|
82
|
+
* @arg {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
|
|
83
|
+
* @arg {String} options.name The thread channel name
|
|
84
|
+
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (0-21600) (does not affect bots or users with manageMessages/manageChannel permissions)
|
|
85
|
+
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
|
86
|
+
* @returns {Promise<NewsThreadChannel | PublicThreadChannel>}
|
|
87
|
+
*/
|
|
88
|
+
createThreadWithMessage(messageID, options) {
|
|
89
|
+
return this._client.createThreadWithMessage.call(this._client, this.id, messageID, options);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* [DEPRECATED] Create a thread without an existing message. Use `createThread` instead
|
|
94
|
+
* @arg {Object} options The thread options
|
|
95
|
+
* @arg {Number} [options.autoArchiveDuration] Duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080
|
|
96
|
+
* @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the thread (private threads only)
|
|
97
|
+
* @arg {String} options.name The thread channel name
|
|
98
|
+
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (0-21600) (does not affect bots or users with manageMessages/manageChannel permissions)
|
|
99
|
+
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
|
100
|
+
* @arg {Number} [options.type] The channel type of the thread to create. Either `10` (announcement thread, announcement channels only), `11` (public thread) or `12` (private thread)
|
|
101
|
+
* @returns {Promise<NewsThreadChannel | PublicThreadChannel | PrivateThreadChannel>}
|
|
102
|
+
*/
|
|
103
|
+
createThreadWithoutMessage(options) {
|
|
104
|
+
return this._client.createThreadWithoutMessage.call(this._client, this.id, options);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Delete a channel permission overwrite
|
|
109
|
+
* @arg {String} overwriteID The ID of the overwritten user or role
|
|
110
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
111
|
+
* @returns {Promise}
|
|
112
|
+
*/
|
|
113
|
+
deletePermission(overwriteID, reason) {
|
|
114
|
+
return this._client.deleteChannelPermission.call(this._client, this.id, overwriteID, reason);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Create a channel permission overwrite
|
|
119
|
+
* @arg {String} overwriteID The ID of the overwritten user or role
|
|
120
|
+
* @arg {BigInt | Number | String} allow The permissions number for allowed permissions
|
|
121
|
+
* @arg {BigInt | Number | String} deny The permissions number for denied permissions
|
|
122
|
+
* @arg {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role"
|
|
123
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
124
|
+
* @returns {Promise<PermissionOverwrite>}
|
|
125
|
+
*/
|
|
126
|
+
editPermission(overwriteID, allow, deny, type, reason) {
|
|
127
|
+
return this._client.editChannelPermission.call(this._client, this.id, overwriteID, allow, deny, type, reason);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Get all archived threads in this channel
|
|
132
|
+
* @arg {String} type The type of thread channel, either "public" or "private"
|
|
133
|
+
* @arg {Object} [options] Additional options when requesting archived threads
|
|
134
|
+
* @arg {Date} [options.before] List of threads to return before the timestamp
|
|
135
|
+
* @arg {Number} [options.limit] Maximum number of threads to return
|
|
136
|
+
* @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
|
|
137
|
+
*/
|
|
138
|
+
getArchivedThreads(type, options) {
|
|
139
|
+
return this._client.getArchivedThreads.call(this._client, this.id, type, options);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Get all invites in the channel
|
|
144
|
+
* @returns {Promise<Array<Invite>>}
|
|
145
|
+
*/
|
|
146
|
+
getInvites() {
|
|
147
|
+
return this._client.getChannelInvites.call(this._client, this.id);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Get joined private archived threads in this channel
|
|
152
|
+
* @arg {Object} [options] Additional options when requesting archived threads
|
|
153
|
+
* @arg {Date} [options.before] List of threads to return before the timestamp
|
|
154
|
+
* @arg {Number} [options.limit] Maximum number of threads to return
|
|
155
|
+
* @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
|
|
156
|
+
*/
|
|
157
|
+
getJoinedPrivateArchivedThreads(options) {
|
|
158
|
+
return this._client.getJoinedPrivateArchivedThreads.call(this._client, this.id, options);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get pinned messages in the channel
|
|
163
|
+
* @arg {Object} [options] The options to use to get pinned messages
|
|
164
|
+
* @arg {Date} [options.before] Get pinned messages before this date
|
|
165
|
+
* @arg {Number} [options.limit=50] The max number of pinned messages to get (1-50, default 50)
|
|
166
|
+
* @returns {Promise<{hasMore: Boolean, items: Array<{pinnedAt: Number, message: Message}>}>}
|
|
167
|
+
*/
|
|
168
|
+
getPins(options) {
|
|
169
|
+
return this._client.getPins.call(this._client, this.id, options);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Pin a message
|
|
174
|
+
* @arg {String} messageID The ID of the message
|
|
175
|
+
* @returns {Promise}
|
|
176
|
+
*/
|
|
177
|
+
pinMessage(messageID) {
|
|
178
|
+
return this._client.pinMessage.call(this._client, this.id, messageID);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Unpin a message
|
|
183
|
+
* @arg {String} messageID The ID of the message
|
|
184
|
+
* @returns {Promise}
|
|
185
|
+
*/
|
|
186
|
+
unpinMessage(messageID) {
|
|
187
|
+
return this._client.unpinMessage.call(this._client, this.id, messageID);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
toJSON(props = []) {
|
|
191
|
+
return super.toJSON([
|
|
192
|
+
"defaultAutoArchiveDuration",
|
|
193
|
+
"nsfw",
|
|
194
|
+
"permissionOverwrites",
|
|
195
|
+
"position",
|
|
196
|
+
"topic",
|
|
197
|
+
...props,
|
|
198
|
+
]);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
module.exports = TextChannel;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Collection = require("../util/Collection");
|
|
4
|
+
const GuildTextableChannel = require("./GuildTextableChannel");
|
|
5
|
+
const ThreadMember = require("./ThreadMember");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a thread channel. You also probably want to look at NewsThreadChannel, PublicThreadChannel, and PrivateThreadChannel. See GuildTextableChannel for more properties and methods
|
|
9
|
+
* @extends GuildTextableChannel
|
|
10
|
+
* @prop {Number?} lastPinTimestamp The timestamp of the last pinned message
|
|
11
|
+
* @prop {ThreadMember} member Thread member for the current user, if they have joined the thread
|
|
12
|
+
* @prop {Number} memberCount The approximate number of users in the thread (stops counting at 50)
|
|
13
|
+
* @prop {Collection<ThreadMember>} members Collection of thread members in the channel
|
|
14
|
+
* @prop {Number} messageCount The number of messages (excluding starter and deleted messages) in the thread
|
|
15
|
+
* @prop {String} ownerID The ID of the user that created the thread
|
|
16
|
+
* @prop {Object} threadMetadata Metadata for the thread
|
|
17
|
+
* @prop {Boolean} threadMetadata.archived Whether the thread is archived or not
|
|
18
|
+
* @prop {Number} threadMetadata.archiveTimestamp Timestamp of when the thread's archive status was last changed, used for calculating recent activity
|
|
19
|
+
* @prop {Number} threadMetadata.autoArchiveDuration Duration in minutes to automatically hide the thread after recent activity, either 60, 1440, 4320, or 10080
|
|
20
|
+
* @prop {Number?} threadMetadata.createTimestamp Timestamp when the thread was created (only available for threads created after 09 January 2022)
|
|
21
|
+
* @prop {Boolean} threadMetadata.locked Whether the thread is locked or not
|
|
22
|
+
* @prop {Number} totalMessageSent Total number of messages ever sent in the thread (will not decrement)
|
|
23
|
+
*/
|
|
24
|
+
class ThreadChannel extends GuildTextableChannel {
|
|
25
|
+
constructor(data, client) {
|
|
26
|
+
super(data, client);
|
|
27
|
+
this.members = new Collection(ThreadMember);
|
|
28
|
+
this.ownerID = data.owner_id;
|
|
29
|
+
this.update(data);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
update(data) {
|
|
33
|
+
super.update(data);
|
|
34
|
+
if (data.message_count !== undefined) {
|
|
35
|
+
this.messageCount = data.message_count;
|
|
36
|
+
}
|
|
37
|
+
if (data.member_count !== undefined) {
|
|
38
|
+
this.memberCount = data.member_count;
|
|
39
|
+
}
|
|
40
|
+
if (data.thread_metadata !== undefined) {
|
|
41
|
+
this.threadMetadata = {
|
|
42
|
+
archived: data.thread_metadata.archived,
|
|
43
|
+
archiveTimestamp: Date.parse(data.thread_metadata.archive_timestamp),
|
|
44
|
+
autoArchiveDuration: data.thread_metadata.auto_archive_duration,
|
|
45
|
+
locked: data.thread_metadata.locked,
|
|
46
|
+
};
|
|
47
|
+
if (data.thread_metadata.create_timestamp !== undefined) {
|
|
48
|
+
this.threadMetadata.createTimestamp = Date.parse(data.thread_metadata.create_timestamp) || null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (data.total_message_sent !== undefined) {
|
|
52
|
+
this.totalMessageSent = data.total_message_sent;
|
|
53
|
+
}
|
|
54
|
+
if (data.member !== undefined) {
|
|
55
|
+
this.member = new ThreadMember(data.member, this._client);
|
|
56
|
+
}
|
|
57
|
+
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get a member that is part of the thread channel
|
|
62
|
+
* @arg {String} userID The ID of the user
|
|
63
|
+
* @arg {Boolean} [withMember] Whether to include the guild member object within the response
|
|
64
|
+
* @returns {Promise<ThreadMember>}
|
|
65
|
+
*/
|
|
66
|
+
getMember(userID, withMember) {
|
|
67
|
+
return this._client.getThreadMember.call(this._client, this.id, userID, withMember);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get a list of members that are part of this thread channel
|
|
72
|
+
* @arg {Object} [options] Options for the request
|
|
73
|
+
* @arg {String} [options.after] Get members after this user ID
|
|
74
|
+
* @arg {Number} [options.limit=100] The maximum number of thread members to fetch (1-100)
|
|
75
|
+
* @arg {Boolean} [options.withMember] Whether to include the guild member object for each member of the thread
|
|
76
|
+
* @returns {Promise<Array<ThreadMember>>}
|
|
77
|
+
*/
|
|
78
|
+
getMembers(options) {
|
|
79
|
+
return this._client.getThreadMembers.call(this._client, this.id, options);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get pinned messages in the thread channel
|
|
84
|
+
* @arg {Object} [options] The options to use to get pinned messages
|
|
85
|
+
* @arg {Date} [options.before] Get pinned messages before this date
|
|
86
|
+
* @arg {Number} [options.limit=50] The max number of pinned messages to get (1-50, default 50)
|
|
87
|
+
* @returns {Promise<{hasMore: Boolean, items: Array<{pinnedAt: Number, message: Message}>}>}
|
|
88
|
+
*/
|
|
89
|
+
getPins(options) {
|
|
90
|
+
return this._client.getPins.call(this._client, this.id, options);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Join a thread
|
|
95
|
+
* @arg {String} [userID="@me"] The user ID of the user joining
|
|
96
|
+
* @returns {Promise}
|
|
97
|
+
*/
|
|
98
|
+
join(userID) {
|
|
99
|
+
return this._client.joinThread.call(this._client, this.id, userID);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Leave a thread
|
|
104
|
+
* @arg {String} [userID="@me"] The user ID of the user leaving
|
|
105
|
+
* @returns {Promise}
|
|
106
|
+
*/
|
|
107
|
+
leave(userID) {
|
|
108
|
+
return this._client.leaveThread.call(this._client, this.id, userID);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Pin a message
|
|
113
|
+
* @arg {String} messageID The ID of the message
|
|
114
|
+
* @returns {Promise}
|
|
115
|
+
*/
|
|
116
|
+
pinMessage(messageID) {
|
|
117
|
+
return this._client.pinMessage.call(this._client, this.id, messageID);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Unpin a message
|
|
122
|
+
* @arg {String} messageID The ID of the message
|
|
123
|
+
* @returns {Promise}
|
|
124
|
+
*/
|
|
125
|
+
unpinMessage(messageID) {
|
|
126
|
+
return this._client.unpinMessage.call(this._client, this.id, messageID);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
toJSON(props = []) {
|
|
130
|
+
return super.toJSON([
|
|
131
|
+
"member",
|
|
132
|
+
"memberCount",
|
|
133
|
+
"members",
|
|
134
|
+
"messageCount",
|
|
135
|
+
"ownerID",
|
|
136
|
+
"threadMetadata",
|
|
137
|
+
"totalMessageSent",
|
|
138
|
+
...props,
|
|
139
|
+
]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = ThreadChannel;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a thread member
|
|
7
|
+
* @prop {Number} flags The user-thread settings of this member
|
|
8
|
+
* @prop {Member?} guildMember The guild member that this thread member belongs to
|
|
9
|
+
* @prop {String} id The ID of the thread member
|
|
10
|
+
* @prop {Number} joinTimestamp Timestamp of when the member joined the thread
|
|
11
|
+
* @prop {String} threadID The ID of the thread this member is a part of
|
|
12
|
+
*/
|
|
13
|
+
class ThreadMember extends Base {
|
|
14
|
+
constructor(data, client) {
|
|
15
|
+
super(data.user_id);
|
|
16
|
+
this._client = client;
|
|
17
|
+
this.threadID = data.thread_id || data.id; // Thanks Discord
|
|
18
|
+
this.joinTimestamp = Date.parse(data.join_timestamp);
|
|
19
|
+
|
|
20
|
+
if (data.member !== undefined) {
|
|
21
|
+
const guild = this._client.guilds.get(this._client.threadGuildMap[this.threadID]);
|
|
22
|
+
if (data.user_id) {
|
|
23
|
+
data.member.id = data.user_id;
|
|
24
|
+
}
|
|
25
|
+
this.guildMember = guild.members.update(data.member, guild);
|
|
26
|
+
if (data.presence) {
|
|
27
|
+
this.guildMember.update(data.presence);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.update(data);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
update(data) {
|
|
35
|
+
if (data.flags !== undefined) {
|
|
36
|
+
this.flags = data.flags;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Remove the member from the thread
|
|
42
|
+
* @returns {Promise}
|
|
43
|
+
*/
|
|
44
|
+
leave() {
|
|
45
|
+
return this._client.leaveThread.call(this._client, this.threadID, this.id);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
toJSON(props = []) {
|
|
49
|
+
return super.toJSON([
|
|
50
|
+
"flags",
|
|
51
|
+
"guildMember",
|
|
52
|
+
"joinTimestamp",
|
|
53
|
+
"threadID",
|
|
54
|
+
...props,
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = ThreadMember;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a guild
|
|
7
|
+
* @prop {String} id The ID of the guild
|
|
8
|
+
* @prop {Shard} shard The Shard that owns the guild
|
|
9
|
+
* @prop {Boolean} unavailable Whether the guild is unavailable or not
|
|
10
|
+
*/
|
|
11
|
+
class UnavailableGuild extends Base {
|
|
12
|
+
constructor(data, client) {
|
|
13
|
+
super(data.id);
|
|
14
|
+
this.shard = client.shards.get(client.guildShardMap[this.id]);
|
|
15
|
+
this.unavailable = !!data.unavailable;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
toJSON(props = []) {
|
|
19
|
+
return super.toJSON([
|
|
20
|
+
"unavailable",
|
|
21
|
+
...props,
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = UnavailableGuild;
|