@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,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
const Guild = require("./Guild");
|
|
5
|
+
const GuildScheduledEvent = require("./GuildScheduledEvent");
|
|
6
|
+
const Member = require("./Member");
|
|
7
|
+
const Role = require("./Role");
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents an invite. Some properties are only available when fetching invites from channels, which requires the Manage Channel permission.
|
|
11
|
+
* @prop {(TextChannel | NewsChannel | VoiceChannel | GroupChannel | StageChannel | Object)?} channel Info on the invite channel
|
|
12
|
+
* @prop {String?} channel.icon The icon of a channel (group dm)
|
|
13
|
+
* @prop {String} channel.id The ID of the invite's channel
|
|
14
|
+
* @prop {String?} channel.name The name of the invite's channel
|
|
15
|
+
* @prop {Number} channel.type The type of the invite's channel
|
|
16
|
+
* @prop {String} code The invite code
|
|
17
|
+
* @prop {Number?} createdAt Timestamp of invite creation
|
|
18
|
+
* @prop {Number?} expiresAt Timestamp of invite expiration
|
|
19
|
+
* @prop {Number?} flags The invite flags. For now, if there are any invite flags, they will only be `1` (meaning this invite is a guest invite for a voice channel)
|
|
20
|
+
* @prop {(Guild | Object)?} guild Info on the invite guild. If the guild is not cached, this will be an object with an `id` key. No other property is guaranteed.
|
|
21
|
+
* @prop {GuildScheduledEvent?} guildScheduledEvent The guild scheduled event the invite points to, if the invite was fetched with a `guildScheduledEventID`
|
|
22
|
+
* @prop {User?} inviter The invite creator
|
|
23
|
+
* @prop {Number?} maxAge How long the invite lasts in seconds
|
|
24
|
+
* @prop {Number?} maxUses The max number of invite uses
|
|
25
|
+
* @prop {Number?} memberCount The **approximate** member count for the guild
|
|
26
|
+
* @prop {Number?} presenceCount The **approximate** presence count for the guild
|
|
27
|
+
* @prop {Array<Role>?} roles The roles assigned to the user upon accepting the invite. Roles of uncached guilds are partial (`id`, `name`, `position`, `color`, `colors`, `icon` and `unicodeEmoji` only)
|
|
28
|
+
* @prop {Object?} stageInstance [DEPRECATED] The active public stage instance data for the stage channel this invite is for
|
|
29
|
+
* @prop {String?} targetApplicationID The target application id
|
|
30
|
+
* @prop {Number?} targetType The type of the target application
|
|
31
|
+
* @prop {User?} targetUser The user whose stream is displayed for the invite (voice channel only)
|
|
32
|
+
* @prop {Boolean?} temporary Whether the invite grants temporary membership or not
|
|
33
|
+
* @prop {Number} type The type of invite. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/invite#invite-object-invite-types) for valid types
|
|
34
|
+
* @prop {Number?} uses The number of invite uses
|
|
35
|
+
*/
|
|
36
|
+
class Invite extends Base {
|
|
37
|
+
constructor(data, client) {
|
|
38
|
+
super();
|
|
39
|
+
this._client = client;
|
|
40
|
+
this.code = data.code;
|
|
41
|
+
if (data.guild && client.guilds.has(data.guild.id)) {
|
|
42
|
+
this.channel = client.guilds.get(data.guild.id).channels.update(data.channel, client);
|
|
43
|
+
} else {
|
|
44
|
+
this.channel = data.channel;
|
|
45
|
+
}
|
|
46
|
+
if (data.guild) {
|
|
47
|
+
if (client.guilds.has(data.guild.id)) {
|
|
48
|
+
this.guild = client.guilds.update(data.guild, client);
|
|
49
|
+
} else if (Object.keys(data.guild).length !== 1) {
|
|
50
|
+
this.guild = new Guild(data.guild, client);
|
|
51
|
+
} else {
|
|
52
|
+
this.guild = { id: data.guild.id };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (data.inviter) {
|
|
56
|
+
this.inviter = client.users.add(data.inviter, client);
|
|
57
|
+
}
|
|
58
|
+
this.uses = data.uses !== undefined ? data.uses : null;
|
|
59
|
+
this.maxUses = data.max_uses !== undefined ? data.max_uses : null;
|
|
60
|
+
this.maxAge = data.max_age !== undefined ? data.max_age : null;
|
|
61
|
+
this.temporary = data.temporary !== undefined ? data.temporary : null;
|
|
62
|
+
this._createdAt = data.created_at !== undefined ? data.created_at : null;
|
|
63
|
+
this._expiresAt = data.expires_at !== undefined ? data.expires_at : null;
|
|
64
|
+
this.presenceCount = data.approximate_presence_count !== undefined ? data.approximate_presence_count : null;
|
|
65
|
+
this.memberCount = data.approximate_member_count !== undefined ? data.approximate_member_count : null;
|
|
66
|
+
if (data.stage_instance !== undefined) {
|
|
67
|
+
data.stage_instance.members = data.stage_instance.members.map((m) => {
|
|
68
|
+
m.id = m.user.id;
|
|
69
|
+
return m;
|
|
70
|
+
});
|
|
71
|
+
this.stageInstance = {
|
|
72
|
+
members: data.stage_instance.members.map((m) => this.guild instanceof Guild ? this.guild.members.update(m, this.guild) : new Member(m, undefined, this._client)),
|
|
73
|
+
participantCount: data.stage_instance.participant_count,
|
|
74
|
+
speakerCount: data.stage_instance.speaker_count,
|
|
75
|
+
topic: data.stage_instance.topic,
|
|
76
|
+
};
|
|
77
|
+
} else {
|
|
78
|
+
this.stageInstance = null;
|
|
79
|
+
}
|
|
80
|
+
if (data.flags !== undefined) {
|
|
81
|
+
this.flags = data.flags;
|
|
82
|
+
}
|
|
83
|
+
if (data.guild_scheduled_event !== undefined) {
|
|
84
|
+
this.guildScheduledEvent = new GuildScheduledEvent(data.guild_scheduled_event, client);
|
|
85
|
+
}
|
|
86
|
+
if (data.roles !== undefined) {
|
|
87
|
+
this.roles = data.roles.map((role) => (this.guild instanceof Guild && this.guild.roles.get(role.id)) || new Role(role, this.guild));
|
|
88
|
+
}
|
|
89
|
+
if (data.type !== undefined) {
|
|
90
|
+
this.type = data.type;
|
|
91
|
+
}
|
|
92
|
+
this.targetApplicationID = data.target_application !== undefined ? data.target_application.id : null;
|
|
93
|
+
this.targetType = data.target_type !== undefined ? data.target_type : null;
|
|
94
|
+
this.targetUser = data.target_user !== undefined ? this._client.users.update(data.target_user, this._client) : null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get createdAt() {
|
|
98
|
+
return Date.parse(this._createdAt) || null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get expiresAt() {
|
|
102
|
+
return Date.parse(this._expiresAt) || null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Delete the invite
|
|
107
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
108
|
+
* @returns {Promise}
|
|
109
|
+
*/
|
|
110
|
+
delete(reason) {
|
|
111
|
+
return this._client.deleteInvite.call(this._client, this.code, reason);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
toString() {
|
|
115
|
+
return `[Invite ${this.code}]`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
toJSON(props = []) {
|
|
119
|
+
return super.toJSON([
|
|
120
|
+
"channel",
|
|
121
|
+
"code",
|
|
122
|
+
"createdAt",
|
|
123
|
+
"flags",
|
|
124
|
+
"guild",
|
|
125
|
+
"guildScheduledEvent",
|
|
126
|
+
"maxAge",
|
|
127
|
+
"maxUses",
|
|
128
|
+
"memberCount",
|
|
129
|
+
"presenceCount",
|
|
130
|
+
"revoked",
|
|
131
|
+
"roles",
|
|
132
|
+
"targetApplicationID",
|
|
133
|
+
"targetType",
|
|
134
|
+
"targetUser",
|
|
135
|
+
"temporary",
|
|
136
|
+
"type",
|
|
137
|
+
"uses",
|
|
138
|
+
...props,
|
|
139
|
+
]);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = Invite;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
const Collection = require("../util/Collection");
|
|
5
|
+
const LobbyMember = require("./LobbyMember");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a lobby, a group of users of an application who can chat together, for example in a game through the Discord Social SDK
|
|
9
|
+
* @prop {String} applicationID The ID of the application that created the lobby
|
|
10
|
+
* @prop {String} id The ID of the lobby
|
|
11
|
+
* @prop {(TextChannel | NewsChannel | VoiceChannel | StageChannel | ForumChannel | MediaChannel | ThreadChannel)?} linkedChannel The guild channel linked to the lobby, if any
|
|
12
|
+
* @prop {Collection<LobbyMember>} members The members of the lobby
|
|
13
|
+
* @prop {Object<String, String>?} metadata The metadata of the lobby, as key/value pairs
|
|
14
|
+
*/
|
|
15
|
+
class Lobby extends Base {
|
|
16
|
+
constructor(data, client) {
|
|
17
|
+
super(data.id);
|
|
18
|
+
this._client = client;
|
|
19
|
+
this.applicationID = data.application_id;
|
|
20
|
+
this.linkedChannel = data.linked_channel ? client.getChannel(data.linked_channel.id) || Channel.from(data.linked_channel, client) : null;
|
|
21
|
+
this.members = new Collection(LobbyMember);
|
|
22
|
+
if (data.members) {
|
|
23
|
+
for (const member of data.members) {
|
|
24
|
+
this.members.add(new LobbyMember(member, client, this.id));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
this.metadata = data.metadata !== undefined ? data.metadata : null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Add a user to this lobby, or update them if they are already a member
|
|
32
|
+
* @arg {String} userID The ID of the user
|
|
33
|
+
* @arg {Object} [options] The properties of the member. See `Client#addLobbyMember` for the full list of options
|
|
34
|
+
* @returns {Promise<LobbyMember>}
|
|
35
|
+
*/
|
|
36
|
+
addMember(userID, options) {
|
|
37
|
+
return this._client.addLobbyMember.call(this._client, this.id, userID, options);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Add, update or remove up to 25 members of this lobby
|
|
42
|
+
* @arg {Array<Object>} members The members to add, update or remove. See `Client#bulkEditLobbyMembers` for the full list of options
|
|
43
|
+
* @returns {Promise<Array<LobbyMember>>} The added and updated members
|
|
44
|
+
*/
|
|
45
|
+
bulkEditMembers(members) {
|
|
46
|
+
return this._client.bulkEditLobbyMembers.call(this._client, this.id, members);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Create a single-use invite to the channel linked to this lobby for a member. The invite expires after one hour
|
|
51
|
+
* @arg {String} userID The ID of the member
|
|
52
|
+
* @returns {Promise<Object>} An object containing the invite `code`
|
|
53
|
+
*/
|
|
54
|
+
createChannelInvite(userID) {
|
|
55
|
+
return this._client.createLobbyChannelInvite.call(this._client, this.id, userID);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Delete this lobby
|
|
60
|
+
* @returns {Promise}
|
|
61
|
+
*/
|
|
62
|
+
delete() {
|
|
63
|
+
return this._client.deleteLobby.call(this._client, this.id);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Edit this lobby
|
|
68
|
+
* @arg {Object} options The properties to edit. See `Client#editLobby` for the full list of options
|
|
69
|
+
* @returns {Promise<Lobby>}
|
|
70
|
+
*/
|
|
71
|
+
edit(options) {
|
|
72
|
+
return this._client.editLobby.call(this._client, this.id, options);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Set the moderation metadata of a message of this lobby
|
|
77
|
+
* @arg {String} messageID The ID of the message
|
|
78
|
+
* @arg {Object<String, String>} metadata The moderation metadata, as key/value pairs. See `Client#editLobbyMessageModerationMetadata` for the limits
|
|
79
|
+
* @returns {Promise}
|
|
80
|
+
*/
|
|
81
|
+
editMessageModerationMetadata(messageID, metadata) {
|
|
82
|
+
return this._client.editLobbyMessageModerationMetadata.call(this._client, this.id, messageID, metadata);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Remove a member from this lobby
|
|
87
|
+
* @arg {String} userID The ID of the member
|
|
88
|
+
* @returns {Promise}
|
|
89
|
+
*/
|
|
90
|
+
removeMember(userID) {
|
|
91
|
+
return this._client.removeLobbyMember.call(this._client, this.id, userID);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
toJSON(props = []) {
|
|
95
|
+
return super.toJSON([
|
|
96
|
+
"applicationID",
|
|
97
|
+
"linkedChannel",
|
|
98
|
+
"members",
|
|
99
|
+
"metadata",
|
|
100
|
+
...props,
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
module.exports = Lobby;
|
|
106
|
+
|
|
107
|
+
// Circular import
|
|
108
|
+
const Channel = require("./Channel");
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a lobby member
|
|
7
|
+
* @prop {String?} additionalName An additional display name of the member, such as an in-game character name
|
|
8
|
+
* @prop {Number} flags The lobby member flags of the member. See `Constants.LobbyMemberFlags`
|
|
9
|
+
* @prop {String} id The ID of the user
|
|
10
|
+
* @prop {String} lobbyID The ID of the lobby
|
|
11
|
+
* @prop {Object<String, String>?} metadata The metadata of the member, as key/value pairs
|
|
12
|
+
*/
|
|
13
|
+
class LobbyMember extends Base {
|
|
14
|
+
constructor(data, client, lobbyID) {
|
|
15
|
+
super(data.id);
|
|
16
|
+
this._client = client;
|
|
17
|
+
this.lobbyID = lobbyID;
|
|
18
|
+
this.additionalName = data.additional_name !== undefined ? data.additional_name : null;
|
|
19
|
+
this.flags = data.flags || 0;
|
|
20
|
+
this.metadata = data.metadata !== undefined ? data.metadata : null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a single-use invite to the channel linked to the lobby for this member. The invite expires after one hour
|
|
25
|
+
* @returns {Promise<Object>} An object containing the invite `code`
|
|
26
|
+
*/
|
|
27
|
+
createChannelInvite() {
|
|
28
|
+
return this._client.createLobbyChannelInvite.call(this._client, this.lobbyID, this.id);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Edit this member
|
|
33
|
+
* @arg {Object} options The properties to edit. See `Client#addLobbyMember` for the full list of options
|
|
34
|
+
* @returns {Promise<LobbyMember>}
|
|
35
|
+
*/
|
|
36
|
+
edit(options) {
|
|
37
|
+
return this._client.addLobbyMember.call(this._client, this.lobbyID, this.id, options);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Remove this member from the lobby
|
|
42
|
+
* @returns {Promise}
|
|
43
|
+
*/
|
|
44
|
+
remove() {
|
|
45
|
+
return this._client.removeLobbyMember.call(this._client, this.lobbyID, this.id);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
toJSON(props = []) {
|
|
49
|
+
return super.toJSON([
|
|
50
|
+
"additionalName",
|
|
51
|
+
"flags",
|
|
52
|
+
"lobbyID",
|
|
53
|
+
"metadata",
|
|
54
|
+
...props,
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = LobbyMember;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Collection = require("../util/Collection");
|
|
4
|
+
const GuildChannel = require("./GuildChannel");
|
|
5
|
+
const PermissionOverwrite = require("./PermissionOverwrite");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a guild media channel. See GuildChannel for more properties and methods.
|
|
9
|
+
* @extends GuildChannel
|
|
10
|
+
* @prop {Array<Object>} availableTags The available tags that can be applied to threads in the channel. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#forum-tag-object) for object structure (max 20)
|
|
11
|
+
* @prop {Number} defaultAutoArchiveDuration The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080)
|
|
12
|
+
* @prop {Object} defaultReactionEmoji The emoji to show in the add reaction button on a thread in the channel
|
|
13
|
+
* @prop {Number} defaultSortOrder The default sort order type used to order posts in the channel
|
|
14
|
+
* @prop {Number} defaultThreadRateLimitPerUser The initial rateLimitPerUser to set on newly created threads in the channel
|
|
15
|
+
* @prop {String?} lastMessageID The ID of the most recently created thread in the channel. This can be null if there has never been a thread in this channel
|
|
16
|
+
* @prop {Boolean} nsfw Whether the channel is an NSFW channel or not
|
|
17
|
+
* @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in the channel
|
|
18
|
+
* @prop {Number} position The position of the channel
|
|
19
|
+
* @prop {Number?} 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)
|
|
20
|
+
* @prop {Array<PublicThreadChannel>} threads An array of threads in the channel
|
|
21
|
+
* @prop {String?} topic The topic of the channel
|
|
22
|
+
*/
|
|
23
|
+
class MediaChannel extends GuildChannel {
|
|
24
|
+
constructor(data, client) {
|
|
25
|
+
super(data, client);
|
|
26
|
+
this.lastMessageID = data.last_message_id || null;
|
|
27
|
+
this.update(data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
update(data) {
|
|
31
|
+
super.update(data);
|
|
32
|
+
if (data.topic !== undefined) {
|
|
33
|
+
this.topic = data.topic;
|
|
34
|
+
}
|
|
35
|
+
if (data.available_tags !== undefined) {
|
|
36
|
+
this.availableTags = data.available_tags;
|
|
37
|
+
}
|
|
38
|
+
if (data.default_auto_archive_duration !== undefined) {
|
|
39
|
+
this.defaultAutoArchiveDuration = data.default_auto_archive_duration;
|
|
40
|
+
}
|
|
41
|
+
if (data.default_reaction_emoji !== undefined) {
|
|
42
|
+
this.defaultReactionEmoji = data.default_reaction_emoji;
|
|
43
|
+
}
|
|
44
|
+
if (data.default_sort_order !== undefined) {
|
|
45
|
+
this.defaultSortOrder = data.default_sort_order;
|
|
46
|
+
}
|
|
47
|
+
if (data.default_thread_rate_limit_per_user !== undefined) {
|
|
48
|
+
this.defaultThreadRateLimitPerUser = data.default_thread_rate_limit_per_user;
|
|
49
|
+
}
|
|
50
|
+
if (data.nsfw !== undefined) {
|
|
51
|
+
this.nsfw = data.nsfw;
|
|
52
|
+
}
|
|
53
|
+
if (data.permission_overwrites !== undefined) {
|
|
54
|
+
this.permissionOverwrites = new Collection(PermissionOverwrite);
|
|
55
|
+
data.permission_overwrites.forEach((overwrite) => {
|
|
56
|
+
this.permissionOverwrites.add(overwrite);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (data.position !== undefined) {
|
|
60
|
+
this.position = data.position;
|
|
61
|
+
}
|
|
62
|
+
if (data.rate_limit_per_user !== undefined) {
|
|
63
|
+
this.rateLimitPerUser = data.rate_limit_per_user;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get threads() {
|
|
68
|
+
return this.guild.threads.filter((thread) => thread.parentID === this.id);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Create an invite for the channel
|
|
73
|
+
* @arg {Object} [options] Invite generation options
|
|
74
|
+
* @arg {Number} [options.maxAge] How long the invite should last in seconds
|
|
75
|
+
* @arg {Number} [options.maxUses] How many uses the invite should last for
|
|
76
|
+
* @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not
|
|
77
|
+
* @arg {Boolean} [options.unique] Whether the invite is unique or not
|
|
78
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
79
|
+
* @returns {Promise<Invite>}
|
|
80
|
+
*/
|
|
81
|
+
createInvite(options, reason) {
|
|
82
|
+
return this._client.createChannelInvite.call(this.client, this.id, options, reason);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Create a thread inside the channel
|
|
87
|
+
* @arg {Object} options The thread options
|
|
88
|
+
* @arg {Array<String>} [options.appliedTags] The IDs of the set of tags that have been applied to a thread in a forum/media channel (threads created in forum/media channels only, max 5)
|
|
89
|
+
* @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)
|
|
90
|
+
* @arg {Object} [options.message] The message to create with the thread. Note: When creating a forum/media channel thread, you must provide at least one of `content`, `embeds`, `stickerIDs`, `components`, or `files`
|
|
91
|
+
* @arg {Object} [options.message.allowedMentions] A list of mentions to allow (overrides default)
|
|
92
|
+
* @arg {Boolean} [options.message.allowedMentions.everyone] Whether or not to allow @everyone/@here
|
|
93
|
+
* @arg {Boolean} [options.message.allowedMentions.repliedUser] Whether or not to mention the author of the message being replied to
|
|
94
|
+
* @arg {Boolean | Array<String>} [options.message.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow
|
|
95
|
+
* @arg {Boolean | Array<String>} [options.message.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow
|
|
96
|
+
* @arg {Array<Object>} [options.message.attachments] An array of attachment objects with the filename and description
|
|
97
|
+
* @arg {String} [options.message.attachments[].description] The description of the file
|
|
98
|
+
* @arg {String} [options.message.attachments[].filename] The name of the file
|
|
99
|
+
* @arg {Number} options.message.attachments[].id The index of the file
|
|
100
|
+
* @arg {Array<Object>} [options.message.components] An array of component objects
|
|
101
|
+
* @arg {String} [options.message.components[].custom_id] The ID of the component (type 2 style 1-4 and type 3,5,6,7,8 only)
|
|
102
|
+
* @arg {Boolean} [options.message.components[].disabled] Whether the component is disabled (type 2 and 3,5,6,7,8 only)
|
|
103
|
+
* @arg {Object} [options.message.components[].emoji] The emoji to be displayed in the component (type 2)
|
|
104
|
+
* @arg {String} [options.message.components[].label] The label to be displayed in the component (type 2)
|
|
105
|
+
* @arg {Array<Object>} [options.message.components[].default_values] default values for the component (type 5,6,7,8 only)
|
|
106
|
+
* @arg {String} [options.message.components[].default_values[].id] id of a user, role, or channel
|
|
107
|
+
* @arg {String} [options.message.components[].default_values[].type] type of value that id represents (user, role, or channel)
|
|
108
|
+
* @arg {Number} [options.message.components[].max_values] The maximum number of items that can be chosen (1-25, default 1)
|
|
109
|
+
* @arg {Number} [options.message.components[].min_values] The minimum number of items that must be chosen (0-25, default 1)
|
|
110
|
+
* @arg {Array<Object>} [options.message.components[].options] The options for this component (type 3 only)
|
|
111
|
+
* @arg {Boolean} [options.message.components[].options[].default] Whether this option should be the default value selected
|
|
112
|
+
* @arg {String} [options.message.components[].options[].description] The description for this option
|
|
113
|
+
* @arg {Object} [options.message.components[].options[].emoji] The emoji to be displayed in this option
|
|
114
|
+
* @arg {String} options.message.components[].options[].label The label for this option
|
|
115
|
+
* @arg {Number | String} options.message.components[].options[].value The value for this option
|
|
116
|
+
* @arg {String} [options.message.components[].placeholder] The placeholder text for the component when no option is selected (type 3,5,6,7,8 only)
|
|
117
|
+
* @arg {String} [options.message.components[].sku_id] The ID of the SKU to purchase (type 2 style 6 only)
|
|
118
|
+
* @arg {Number} [options.message.components[].style] The style of the component (type 2 only) - If 1-4, `custom_id` is required; if 5, `url` is required; if 6, `sku_id` is required
|
|
119
|
+
* @arg {Number} options.message.components[].type The type of component - If 1, it is a collection and a `components` array (nested) is required; if 2, it is a button; if 3, it is a string select; if 4, it is a text input; if 5, it is a user select; if 6, it is a role select; if 7, it is a mentionable select; if 8, it is a channel select; if 9, it is a section; if 10, it is a text display; if 11, it is a thumbnail; if 12, it is a media gallery; if 13, it is a file; if 14, it is a separator; if 17, it is a container; if 18, it is a label (modals only); if 19, it is a file upload (modals only); if 21, it is a radio group (modals only); if 22, it is a checkbox group (modals only); if 23, it is a checkbox (modals only)
|
|
120
|
+
* @arg {String} [options.message.components[].url] The URL that the component should open for users (type 2 style 5 only)
|
|
121
|
+
* @arg {String} [options.message.content] A string containing the message content
|
|
122
|
+
* @arg {Array<Object>} [options.message.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
|
|
123
|
+
* @arg {Array<String>} [options.message.stickerIDs] An array of IDs corresponding to stickers to send
|
|
124
|
+
* @arg {String} options.name The thread channel name
|
|
125
|
+
* @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)
|
|
126
|
+
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
|
127
|
+
* @arg {Object | Array<Object>} [file] A file object (or an Array of them)
|
|
128
|
+
* @arg {Buffer} file.file A buffer containing file data
|
|
129
|
+
* @arg {String} file.name What to name the file
|
|
130
|
+
* @returns {Promise<ThreadChannel>}
|
|
131
|
+
*/
|
|
132
|
+
createThread(options, file) {
|
|
133
|
+
return this._client.createThread.call(this.client, this.id, options, file);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Create a channel webhook
|
|
138
|
+
* @arg {Object} options Webhook options
|
|
139
|
+
* @arg {String} [options.avatar] The default avatar as a base64 data URI. Note: base64 strings alone are not base64 data URI strings
|
|
140
|
+
* @arg {String} options.name The default name
|
|
141
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
142
|
+
* @returns {Promise<Object>} Resolves with a webhook object
|
|
143
|
+
*/
|
|
144
|
+
createWebhook(options, reason) {
|
|
145
|
+
return this._client.createChannelWebhook.call(this.client, this.id, options, reason);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Delete a channel permission overwrite
|
|
150
|
+
* @arg {String} overwriteID The ID of the overwritten user or role
|
|
151
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
152
|
+
* @returns {Promise}
|
|
153
|
+
*/
|
|
154
|
+
deletePermission(overwriteID, reason) {
|
|
155
|
+
return this._client.deleteChannelPermission.call(this._client, this.id, overwriteID, reason);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Create a channel permission overwrite
|
|
160
|
+
* @arg {String} overwriteID The ID of the overwritten user or role
|
|
161
|
+
* @arg {BigInt | Number | String} allow The permissions number for allowed permissions
|
|
162
|
+
* @arg {BigInt | Number | String} deny The permissions number for denied permissions
|
|
163
|
+
* @arg {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role"
|
|
164
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
165
|
+
* @returns {Promise<PermissionOverwrite>}
|
|
166
|
+
*/
|
|
167
|
+
editPermission(overwriteID, allow, deny, type, reason) {
|
|
168
|
+
return this._client.editChannelPermission.call(this._client, this.id, overwriteID, allow, deny, type, reason);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get all archived threads in the channel
|
|
173
|
+
* @arg {Object} [options] Additional options when requesting archived threads
|
|
174
|
+
* @arg {Date} [options.before] List of threads to return before the timestamp
|
|
175
|
+
* @arg {Number} [options.limit] Maximum number of threads to return
|
|
176
|
+
* @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
|
|
177
|
+
*/
|
|
178
|
+
getArchivedThreads(options) {
|
|
179
|
+
return this._client.getArchivedThreads.call(this.client, this.id, "public", options);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Get all invites in the channel
|
|
184
|
+
* @returns {Promise<Array<Invite>>}
|
|
185
|
+
*/
|
|
186
|
+
getInvites() {
|
|
187
|
+
return this._client.getChannelInvites.call(this.client, this.id);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Get all the webhooks in the channel
|
|
192
|
+
* @returns {Promise<Array<Object>>} Resolves with an array of webhook objects
|
|
193
|
+
*/
|
|
194
|
+
getWebhooks() {
|
|
195
|
+
return this._client.getChannelWebhooks.call(this.client, this.id);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
toJSON(props = []) {
|
|
199
|
+
return super.toJSON([
|
|
200
|
+
"availableTags",
|
|
201
|
+
"defaultAutoArchiveDuration",
|
|
202
|
+
"defaultReactionEmoji",
|
|
203
|
+
"defaultSortOrder",
|
|
204
|
+
"defaultThreadRateLimitPerUser",
|
|
205
|
+
"lastMessageID",
|
|
206
|
+
"nsfw",
|
|
207
|
+
"permissionOverwrites",
|
|
208
|
+
"position",
|
|
209
|
+
"rateLimitPerUser",
|
|
210
|
+
"topic",
|
|
211
|
+
...props,
|
|
212
|
+
]);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
module.exports = MediaChannel;
|