@zygout/eris 0.19.0 → 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 -20
- package/README.md +109 -80
- package/esm.mjs +72 -72
- package/index.d.ts +4407 -4397
- package/index.js +75 -75
- package/lib/Client.js +4708 -4683
- package/lib/Constants.d.ts +990 -988
- package/lib/Constants.js +1163 -1161
- package/lib/command/Command.js +552 -552
- package/lib/command/CommandClient.js +460 -460
- package/lib/errors/DiscordHTTPError.js +63 -63
- package/lib/errors/DiscordRESTError.js +77 -77
- package/lib/gateway/Shard.js +3029 -3029
- package/lib/gateway/ShardManager.js +164 -164
- package/lib/rest/Endpoints.js +172 -172
- package/lib/rest/RequestHandler.js +459 -459
- package/lib/structures/ApplicationCommand.js +125 -125
- package/lib/structures/AutoModerationRule.js +143 -143
- package/lib/structures/AutocompleteInteraction.js +80 -80
- package/lib/structures/Base.js +81 -81
- package/lib/structures/CategoryChannel.js +77 -77
- package/lib/structures/Channel.js +98 -98
- package/lib/structures/CommandInteraction.js +473 -473
- package/lib/structures/ComponentInteraction.js +538 -538
- package/lib/structures/DMChannel.js +278 -278
- package/lib/structures/Entitlement.js +77 -77
- package/lib/structures/ExtendedUser.js +46 -46
- package/lib/structures/ForumChannel.js +24 -24
- package/lib/structures/GroupChannel.js +106 -106
- package/lib/structures/Guild.js +1677 -1677
- package/lib/structures/GuildAuditLogEntry.js +190 -190
- package/lib/structures/GuildChannel.js +128 -128
- package/lib/structures/GuildIntegration.js +99 -99
- package/lib/structures/GuildPreview.js +97 -97
- package/lib/structures/GuildScheduledEvent.js +176 -176
- package/lib/structures/GuildTemplate.js +76 -76
- package/lib/structures/GuildTextableChannel.js +260 -260
- package/lib/structures/Interaction.js +133 -133
- package/lib/structures/Invite.js +143 -143
- package/lib/structures/Lobby.js +108 -108
- package/lib/structures/LobbyMember.js +59 -59
- package/lib/structures/MediaChannel.js +216 -216
- package/lib/structures/Member.js +371 -371
- package/lib/structures/Message.js +708 -708
- package/lib/structures/ModalSubmitInteraction.js +478 -478
- package/lib/structures/NewsChannel.js +34 -34
- package/lib/structures/NewsThreadChannel.js +12 -12
- package/lib/structures/Permission.js +80 -80
- package/lib/structures/PermissionOverwrite.js +32 -32
- package/lib/structures/PingInteraction.js +39 -39
- package/lib/structures/PrivateThreadChannel.js +25 -25
- package/lib/structures/PublicThreadChannel.js +26 -26
- package/lib/structures/Role.js +163 -163
- package/lib/structures/SKU.js +80 -80
- package/lib/structures/SoundboardSound.js +79 -79
- package/lib/structures/StageChannel.js +59 -59
- package/lib/structures/StageInstance.js +55 -55
- package/lib/structures/Subscription.js +69 -69
- package/lib/structures/TextChannel.js +202 -202
- package/lib/structures/ThreadChannel.js +143 -143
- package/lib/structures/ThreadMember.js +59 -59
- package/lib/structures/UnavailableGuild.js +26 -26
- package/lib/structures/UnknownInteraction.js +502 -502
- package/lib/structures/User.js +296 -296
- package/lib/structures/VoiceChannel.js +166 -166
- package/lib/structures/VoiceState.js +84 -84
- package/lib/util/BrowserWebSocket.js +76 -76
- package/lib/util/Bucket.js +89 -89
- package/lib/util/Collection.js +202 -202
- package/lib/util/MultipartData.js +70 -70
- package/lib/util/Opus.js +33 -33
- package/lib/util/SequentialBucket.js +83 -83
- package/lib/util/emitDeprecation.js +26 -26
- package/lib/voice/Piper.js +300 -300
- package/lib/voice/SharedStream.js +238 -238
- package/lib/voice/VoiceConnection.js +1440 -1440
- package/lib/voice/VoiceConnectionManager.js +151 -151
- package/lib/voice/VoiceDataStream.js +22 -22
- package/lib/voice/streams/BaseTransformer.js +40 -40
- package/lib/voice/streams/DCAOpusTransformer.js +78 -78
- package/lib/voice/streams/FFmpegDuplex.js +192 -192
- package/lib/voice/streams/FFmpegOggTransformer.js +35 -35
- package/lib/voice/streams/FFmpegPCMTransformer.js +26 -26
- package/lib/voice/streams/OggOpusTransformer.js +108 -108
- package/lib/voice/streams/PCMOpusTransformer.js +61 -61
- package/lib/voice/streams/VolumeTransformer.js +50 -50
- package/lib/voice/streams/WebmOpusTransformer.js +258 -258
- package/package.json +83 -82
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const Base = require("./Base");
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Represents an entitlement
|
|
7
|
-
* @prop {String} applicationID The ID of the parent application
|
|
8
|
-
* @prop {Boolean} consumed For consumable items, whether or not the entitlement has been consumed
|
|
9
|
-
* @prop {Boolean} deleted Whether the entitlement was deleted
|
|
10
|
-
* @prop {Number?} endsAt Timestamp of when the entitlement is no longer valid
|
|
11
|
-
* @prop {String?} guildID The ID of the guild that is granted access to the SKU, if any
|
|
12
|
-
* @prop {String} id The ID of the entitlement
|
|
13
|
-
* @prop {String} skuID The ID of the SKU
|
|
14
|
-
* @prop {Number?} startsAt Timestamp of when the entitlement starts being valid
|
|
15
|
-
* @prop {Number} type The type of entitlement. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/entitlement#entitlement-object-entitlement-types) for a list of types
|
|
16
|
-
* @prop {String?} userID The ID of the user that is granted access to the SKU, if any
|
|
17
|
-
*/
|
|
18
|
-
class Entitlement extends Base {
|
|
19
|
-
constructor(data, client) {
|
|
20
|
-
super(data.id);
|
|
21
|
-
this._client = client;
|
|
22
|
-
this.applicationID = data.application_id;
|
|
23
|
-
this.guildID = data.guild_id !== undefined ? data.guild_id : null;
|
|
24
|
-
this.skuID = data.sku_id;
|
|
25
|
-
this.type = data.type;
|
|
26
|
-
this.userID = data.user_id !== undefined ? data.user_id : null;
|
|
27
|
-
this.update(data);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
update(data) {
|
|
31
|
-
if (data.consumed !== undefined) {
|
|
32
|
-
this.consumed = data.consumed;
|
|
33
|
-
}
|
|
34
|
-
if (data.deleted !== undefined) {
|
|
35
|
-
this.deleted = data.deleted;
|
|
36
|
-
}
|
|
37
|
-
if (data.ends_at !== undefined) {
|
|
38
|
-
this.endsAt = data.ends_at ? Date.parse(data.ends_at) : null;
|
|
39
|
-
}
|
|
40
|
-
if (data.starts_at !== undefined) {
|
|
41
|
-
this.startsAt = data.starts_at ? Date.parse(data.starts_at) : null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Mark this entitlement as consumed. Only available for one-time purchase consumable SKUs
|
|
47
|
-
* @returns {Promise}
|
|
48
|
-
*/
|
|
49
|
-
consume() {
|
|
50
|
-
return this._client.consumeEntitlement.call(this._client, this.id);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Delete this entitlement. Only available for test entitlements
|
|
55
|
-
* @returns {Promise}
|
|
56
|
-
*/
|
|
57
|
-
delete() {
|
|
58
|
-
return this._client.deleteTestEntitlement.call(this._client, this.id);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
toJSON(props = []) {
|
|
62
|
-
return super.toJSON([
|
|
63
|
-
"applicationID",
|
|
64
|
-
"consumed",
|
|
65
|
-
"deleted",
|
|
66
|
-
"endsAt",
|
|
67
|
-
"guildID",
|
|
68
|
-
"skuID",
|
|
69
|
-
"startsAt",
|
|
70
|
-
"type",
|
|
71
|
-
"userID",
|
|
72
|
-
...props,
|
|
73
|
-
]);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
module.exports = Entitlement;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents an entitlement
|
|
7
|
+
* @prop {String} applicationID The ID of the parent application
|
|
8
|
+
* @prop {Boolean} consumed For consumable items, whether or not the entitlement has been consumed
|
|
9
|
+
* @prop {Boolean} deleted Whether the entitlement was deleted
|
|
10
|
+
* @prop {Number?} endsAt Timestamp of when the entitlement is no longer valid
|
|
11
|
+
* @prop {String?} guildID The ID of the guild that is granted access to the SKU, if any
|
|
12
|
+
* @prop {String} id The ID of the entitlement
|
|
13
|
+
* @prop {String} skuID The ID of the SKU
|
|
14
|
+
* @prop {Number?} startsAt Timestamp of when the entitlement starts being valid
|
|
15
|
+
* @prop {Number} type The type of entitlement. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/entitlement#entitlement-object-entitlement-types) for a list of types
|
|
16
|
+
* @prop {String?} userID The ID of the user that is granted access to the SKU, if any
|
|
17
|
+
*/
|
|
18
|
+
class Entitlement extends Base {
|
|
19
|
+
constructor(data, client) {
|
|
20
|
+
super(data.id);
|
|
21
|
+
this._client = client;
|
|
22
|
+
this.applicationID = data.application_id;
|
|
23
|
+
this.guildID = data.guild_id !== undefined ? data.guild_id : null;
|
|
24
|
+
this.skuID = data.sku_id;
|
|
25
|
+
this.type = data.type;
|
|
26
|
+
this.userID = data.user_id !== undefined ? data.user_id : null;
|
|
27
|
+
this.update(data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
update(data) {
|
|
31
|
+
if (data.consumed !== undefined) {
|
|
32
|
+
this.consumed = data.consumed;
|
|
33
|
+
}
|
|
34
|
+
if (data.deleted !== undefined) {
|
|
35
|
+
this.deleted = data.deleted;
|
|
36
|
+
}
|
|
37
|
+
if (data.ends_at !== undefined) {
|
|
38
|
+
this.endsAt = data.ends_at ? Date.parse(data.ends_at) : null;
|
|
39
|
+
}
|
|
40
|
+
if (data.starts_at !== undefined) {
|
|
41
|
+
this.startsAt = data.starts_at ? Date.parse(data.starts_at) : null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Mark this entitlement as consumed. Only available for one-time purchase consumable SKUs
|
|
47
|
+
* @returns {Promise}
|
|
48
|
+
*/
|
|
49
|
+
consume() {
|
|
50
|
+
return this._client.consumeEntitlement.call(this._client, this.id);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Delete this entitlement. Only available for test entitlements
|
|
55
|
+
* @returns {Promise}
|
|
56
|
+
*/
|
|
57
|
+
delete() {
|
|
58
|
+
return this._client.deleteTestEntitlement.call(this._client, this.id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
toJSON(props = []) {
|
|
62
|
+
return super.toJSON([
|
|
63
|
+
"applicationID",
|
|
64
|
+
"consumed",
|
|
65
|
+
"deleted",
|
|
66
|
+
"endsAt",
|
|
67
|
+
"guildID",
|
|
68
|
+
"skuID",
|
|
69
|
+
"startsAt",
|
|
70
|
+
"type",
|
|
71
|
+
"userID",
|
|
72
|
+
...props,
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = Entitlement;
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const User = require("./User");
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Represents an extended user
|
|
7
|
-
* @extends User
|
|
8
|
-
* @prop {String?} email The email of the user
|
|
9
|
-
* @prop {Boolean?} mfaEnabled Whether the user has enabled two-factor authentication
|
|
10
|
-
* @prop {Number?} premiumType The type of Nitro subscription on the user's account
|
|
11
|
-
* @prop {Boolean?} verified Whether the account email has been verified
|
|
12
|
-
*/
|
|
13
|
-
class ExtendedUser extends User {
|
|
14
|
-
constructor(data, client) {
|
|
15
|
-
super(data, client);
|
|
16
|
-
this.update(data);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
update(data) {
|
|
20
|
-
super.update(data);
|
|
21
|
-
if (data.email !== undefined) {
|
|
22
|
-
this.email = data.email;
|
|
23
|
-
}
|
|
24
|
-
if (data.verified !== undefined) {
|
|
25
|
-
this.verified = data.verified;
|
|
26
|
-
}
|
|
27
|
-
if (data.mfa_enabled !== undefined) {
|
|
28
|
-
this.mfaEnabled = data.mfa_enabled;
|
|
29
|
-
}
|
|
30
|
-
if (data.premium_type !== undefined) {
|
|
31
|
-
this.premiumType = data.premium_type;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
toJSON(props = []) {
|
|
36
|
-
return super.toJSON([
|
|
37
|
-
"email",
|
|
38
|
-
"mfaEnabled",
|
|
39
|
-
"premium",
|
|
40
|
-
"verified",
|
|
41
|
-
...props,
|
|
42
|
-
]);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = ExtendedUser;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const User = require("./User");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents an extended user
|
|
7
|
+
* @extends User
|
|
8
|
+
* @prop {String?} email The email of the user
|
|
9
|
+
* @prop {Boolean?} mfaEnabled Whether the user has enabled two-factor authentication
|
|
10
|
+
* @prop {Number?} premiumType The type of Nitro subscription on the user's account
|
|
11
|
+
* @prop {Boolean?} verified Whether the account email has been verified
|
|
12
|
+
*/
|
|
13
|
+
class ExtendedUser extends User {
|
|
14
|
+
constructor(data, client) {
|
|
15
|
+
super(data, client);
|
|
16
|
+
this.update(data);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
update(data) {
|
|
20
|
+
super.update(data);
|
|
21
|
+
if (data.email !== undefined) {
|
|
22
|
+
this.email = data.email;
|
|
23
|
+
}
|
|
24
|
+
if (data.verified !== undefined) {
|
|
25
|
+
this.verified = data.verified;
|
|
26
|
+
}
|
|
27
|
+
if (data.mfa_enabled !== undefined) {
|
|
28
|
+
this.mfaEnabled = data.mfa_enabled;
|
|
29
|
+
}
|
|
30
|
+
if (data.premium_type !== undefined) {
|
|
31
|
+
this.premiumType = data.premium_type;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
toJSON(props = []) {
|
|
36
|
+
return super.toJSON([
|
|
37
|
+
"email",
|
|
38
|
+
"mfaEnabled",
|
|
39
|
+
"premium",
|
|
40
|
+
"verified",
|
|
41
|
+
...props,
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = ExtendedUser;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const MediaChannel = require("./MediaChannel");
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Represents a guild forum channel. See MediaChannel for more properties and methods
|
|
7
|
-
* @extends MediaChannel
|
|
8
|
-
* @prop {Number} defaultForumLayout The default forum layout type used to display posts in the channel
|
|
9
|
-
*/
|
|
10
|
-
class ForumChannel extends MediaChannel {
|
|
11
|
-
constructor(data, client) {
|
|
12
|
-
super(data, client);
|
|
13
|
-
this.defaultForumLayout = data.default_forum_layout;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
toJSON(props = []) {
|
|
17
|
-
return super.toJSON([
|
|
18
|
-
"defaultForumLayout",
|
|
19
|
-
...props,
|
|
20
|
-
]);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = ForumChannel;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const MediaChannel = require("./MediaChannel");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a guild forum channel. See MediaChannel for more properties and methods
|
|
7
|
+
* @extends MediaChannel
|
|
8
|
+
* @prop {Number} defaultForumLayout The default forum layout type used to display posts in the channel
|
|
9
|
+
*/
|
|
10
|
+
class ForumChannel extends MediaChannel {
|
|
11
|
+
constructor(data, client) {
|
|
12
|
+
super(data, client);
|
|
13
|
+
this.defaultForumLayout = data.default_forum_layout;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
toJSON(props = []) {
|
|
17
|
+
return super.toJSON([
|
|
18
|
+
"defaultForumLayout",
|
|
19
|
+
...props,
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = ForumChannel;
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const Channel = require("./Channel");
|
|
4
|
-
const Collection = require("../util/Collection");
|
|
5
|
-
const Endpoints = require("../rest/Endpoints");
|
|
6
|
-
const User = require("./User");
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Represents a group channel. Bots cannot get data for user-created Group channels. See Channel for additional properties
|
|
10
|
-
* @extends Channel
|
|
11
|
-
* @prop {String} applicationID The application ID of the bot that created the group DM
|
|
12
|
-
* @prop {String?} icon The hash of the group channel icon
|
|
13
|
-
* @prop {String?} iconURL The URL of the group channel icon
|
|
14
|
-
* @prop {String?} lastMessageID The ID of the last message in this channel
|
|
15
|
-
* @prop {Number?} lastPinTimestamp The timestamp of the last pinned message
|
|
16
|
-
* @prop {Boolean} managed Whether the group channel is managed by an application (should always be `true`)
|
|
17
|
-
* @prop {String} name The name of the group channel
|
|
18
|
-
* @prop {String} ownerID The ID of the user that is the group owner
|
|
19
|
-
* @prop {Collection<User>} recipients The recipients in the group channel
|
|
20
|
-
*/
|
|
21
|
-
class GroupChannel extends Channel {
|
|
22
|
-
constructor(data, client) {
|
|
23
|
-
super(data, client);
|
|
24
|
-
this.applicationID = data.applicationID;
|
|
25
|
-
this.lastMessageID = data.last_message_id;
|
|
26
|
-
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
|
27
|
-
this.managed = data.managed;
|
|
28
|
-
this.name = data.name;
|
|
29
|
-
this.ownerID = data.owner_id;
|
|
30
|
-
this.icon = data.icon;
|
|
31
|
-
this.recipients = new Collection(User);
|
|
32
|
-
data.recipients.forEach((recipient) => {
|
|
33
|
-
this.recipients.add(client.users.add(recipient, client));
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get iconURL() {
|
|
38
|
-
return this.icon ? this._client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon)) : null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Add a user to the group
|
|
43
|
-
* @arg {String} userID The ID of the user to add
|
|
44
|
-
* @arg {Object} options The options for adding the user
|
|
45
|
-
* @arg {String} options.accessToken The access token of the user to add. Requires having been authorized with the `gdm.join` scope
|
|
46
|
-
* @arg {String} [options.nick] The nickname to give the user
|
|
47
|
-
* @returns {Promise}
|
|
48
|
-
*/
|
|
49
|
-
addRecipient(userID, options) {
|
|
50
|
-
return this._client.addGroupRecipient.call(this._client, this.id, userID, options);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Delete the Group Channel
|
|
55
|
-
* @returns {Promise<GroupChannel>}
|
|
56
|
-
*/
|
|
57
|
-
delete() {
|
|
58
|
-
return this._client.deleteChannel.call(this._client, this.id);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get the group's icon with the given format and size
|
|
63
|
-
* @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp")
|
|
64
|
-
* @arg {Number} [size] The size of the icon (any power of two between 16 and 4096)
|
|
65
|
-
* @returns {String?}
|
|
66
|
-
*/
|
|
67
|
-
dynamicIconURL(format, size) {
|
|
68
|
-
return this.icon ? this._client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon), format, size) : null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Edit the channel's properties
|
|
73
|
-
* @arg {Object} options The properties to edit
|
|
74
|
-
* @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
|
|
75
|
-
* @arg {String} [options.name] The name of the channel
|
|
76
|
-
* @returns {Promise<GroupChannel>}
|
|
77
|
-
*/
|
|
78
|
-
edit(options) {
|
|
79
|
-
return this._client.editChannel.call(this._client, this.id, options);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Remove a user from the group
|
|
84
|
-
* @arg {String} userID The ID of the target user
|
|
85
|
-
* @returns {Promise}
|
|
86
|
-
*/
|
|
87
|
-
removeRecipient(userID) {
|
|
88
|
-
return this._client.removeGroupRecipient.call(this._client, this.id, userID);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
toJSON(props = []) {
|
|
92
|
-
return super.toJSON([
|
|
93
|
-
"applicationID",
|
|
94
|
-
"icon",
|
|
95
|
-
"lastMessageID",
|
|
96
|
-
"lastPinTimestamp",
|
|
97
|
-
"managed",
|
|
98
|
-
"name",
|
|
99
|
-
"ownerID",
|
|
100
|
-
"recipients",
|
|
101
|
-
...props,
|
|
102
|
-
]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
module.exports = GroupChannel;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Channel = require("./Channel");
|
|
4
|
+
const Collection = require("../util/Collection");
|
|
5
|
+
const Endpoints = require("../rest/Endpoints");
|
|
6
|
+
const User = require("./User");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents a group channel. Bots cannot get data for user-created Group channels. See Channel for additional properties
|
|
10
|
+
* @extends Channel
|
|
11
|
+
* @prop {String} applicationID The application ID of the bot that created the group DM
|
|
12
|
+
* @prop {String?} icon The hash of the group channel icon
|
|
13
|
+
* @prop {String?} iconURL The URL of the group channel icon
|
|
14
|
+
* @prop {String?} lastMessageID The ID of the last message in this channel
|
|
15
|
+
* @prop {Number?} lastPinTimestamp The timestamp of the last pinned message
|
|
16
|
+
* @prop {Boolean} managed Whether the group channel is managed by an application (should always be `true`)
|
|
17
|
+
* @prop {String} name The name of the group channel
|
|
18
|
+
* @prop {String} ownerID The ID of the user that is the group owner
|
|
19
|
+
* @prop {Collection<User>} recipients The recipients in the group channel
|
|
20
|
+
*/
|
|
21
|
+
class GroupChannel extends Channel {
|
|
22
|
+
constructor(data, client) {
|
|
23
|
+
super(data, client);
|
|
24
|
+
this.applicationID = data.applicationID;
|
|
25
|
+
this.lastMessageID = data.last_message_id;
|
|
26
|
+
this.lastPinTimestamp = data.last_pin_timestamp ? Date.parse(data.last_pin_timestamp) : null;
|
|
27
|
+
this.managed = data.managed;
|
|
28
|
+
this.name = data.name;
|
|
29
|
+
this.ownerID = data.owner_id;
|
|
30
|
+
this.icon = data.icon;
|
|
31
|
+
this.recipients = new Collection(User);
|
|
32
|
+
data.recipients.forEach((recipient) => {
|
|
33
|
+
this.recipients.add(client.users.add(recipient, client));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get iconURL() {
|
|
38
|
+
return this.icon ? this._client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon)) : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Add a user to the group
|
|
43
|
+
* @arg {String} userID The ID of the user to add
|
|
44
|
+
* @arg {Object} options The options for adding the user
|
|
45
|
+
* @arg {String} options.accessToken The access token of the user to add. Requires having been authorized with the `gdm.join` scope
|
|
46
|
+
* @arg {String} [options.nick] The nickname to give the user
|
|
47
|
+
* @returns {Promise}
|
|
48
|
+
*/
|
|
49
|
+
addRecipient(userID, options) {
|
|
50
|
+
return this._client.addGroupRecipient.call(this._client, this.id, userID, options);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Delete the Group Channel
|
|
55
|
+
* @returns {Promise<GroupChannel>}
|
|
56
|
+
*/
|
|
57
|
+
delete() {
|
|
58
|
+
return this._client.deleteChannel.call(this._client, this.id);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get the group's icon with the given format and size
|
|
63
|
+
* @arg {String} [format] The filetype of the icon ("jpg", "jpeg", "png", "gif", or "webp")
|
|
64
|
+
* @arg {Number} [size] The size of the icon (any power of two between 16 and 4096)
|
|
65
|
+
* @returns {String?}
|
|
66
|
+
*/
|
|
67
|
+
dynamicIconURL(format, size) {
|
|
68
|
+
return this.icon ? this._client._formatImage(Endpoints.CHANNEL_ICON(this.id, this.icon), format, size) : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Edit the channel's properties
|
|
73
|
+
* @arg {Object} options The properties to edit
|
|
74
|
+
* @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
|
|
75
|
+
* @arg {String} [options.name] The name of the channel
|
|
76
|
+
* @returns {Promise<GroupChannel>}
|
|
77
|
+
*/
|
|
78
|
+
edit(options) {
|
|
79
|
+
return this._client.editChannel.call(this._client, this.id, options);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Remove a user from the group
|
|
84
|
+
* @arg {String} userID The ID of the target user
|
|
85
|
+
* @returns {Promise}
|
|
86
|
+
*/
|
|
87
|
+
removeRecipient(userID) {
|
|
88
|
+
return this._client.removeGroupRecipient.call(this._client, this.id, userID);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
toJSON(props = []) {
|
|
92
|
+
return super.toJSON([
|
|
93
|
+
"applicationID",
|
|
94
|
+
"icon",
|
|
95
|
+
"lastMessageID",
|
|
96
|
+
"lastPinTimestamp",
|
|
97
|
+
"managed",
|
|
98
|
+
"name",
|
|
99
|
+
"ownerID",
|
|
100
|
+
"recipients",
|
|
101
|
+
...props,
|
|
102
|
+
]);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = GroupChannel;
|