@zygout/eris 0.0.0-stage → 0.19.0
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 +80 -3
- package/esm.mjs +72 -0
- package/index.d.ts +4397 -0
- package/index.js +75 -0
- package/lib/Client.js +4683 -0
- package/lib/Constants.d.ts +988 -0
- package/lib/Constants.js +1161 -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 +82 -6
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Interaction = require("./Interaction");
|
|
4
|
+
const { InteractionResponseTypes } = require("../Constants");
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a ping interaction. See Interaction for more properties.
|
|
8
|
+
* @extends Interaction
|
|
9
|
+
*/
|
|
10
|
+
class PingInteraction extends Interaction {
|
|
11
|
+
constructor(info, client) {
|
|
12
|
+
super(info, client);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Acknowledges the ping interaction with a pong response.
|
|
17
|
+
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
|
18
|
+
* @returns {Promise}
|
|
19
|
+
*/
|
|
20
|
+
async acknowledge() {
|
|
21
|
+
return this.pong();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Acknowledges the ping interaction with a pong response.
|
|
26
|
+
* Note: You can **not** use more than 1 initial interaction response per interaction.
|
|
27
|
+
* @returns {Promise}
|
|
28
|
+
*/
|
|
29
|
+
async pong() {
|
|
30
|
+
if (this.acknowledged === true) {
|
|
31
|
+
throw new Error("You have already acknowledged this interaction.");
|
|
32
|
+
}
|
|
33
|
+
return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
|
|
34
|
+
type: InteractionResponseTypes.PONG,
|
|
35
|
+
}).then(() => this.update());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = PingInteraction;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const ThreadChannel = require("./ThreadChannel");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a private thread channel. See ThreadChannel for more properties and methods
|
|
7
|
+
* @extends ThreadChannel
|
|
8
|
+
* @prop {Object} threadMetadata Metadata for the thread
|
|
9
|
+
* @prop {Boolean} threadMetadata.archived Whether the thread is archived or not
|
|
10
|
+
* @prop {Number} threadMetadata.archiveTimestamp Timestamp of when the thread's archive status was last changed, used for calculating recent activity
|
|
11
|
+
* @prop {Number} threadMetadata.autoArchiveDuration Duration in minutes to automatically hide the thread after recent activity, either 60, 1440, 4320, or 10080
|
|
12
|
+
* @prop {Number?} threadMetadata.createTimestamp Timestamp when the thread was created (only available for threads created after 09 January 2022)
|
|
13
|
+
* @prop {Boolean} threadMetadata.invitable Whether non-moderators can add other non-moderators to the thread
|
|
14
|
+
* @prop {Boolean} threadMetadata.locked Whether the thread is locked or not
|
|
15
|
+
*/
|
|
16
|
+
class PrivateThreadChannel extends ThreadChannel {
|
|
17
|
+
update(data) {
|
|
18
|
+
super.update(data);
|
|
19
|
+
if (data.thread_metadata !== undefined) {
|
|
20
|
+
this.threadMetadata.invitable = data.thread_metadata.invitable;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = PrivateThreadChannel;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const ThreadChannel = require("./ThreadChannel");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a public thread channel. See ThreadChannel for more properties
|
|
7
|
+
* @extends ThreadChannel
|
|
8
|
+
* @prop {Array<String>?} 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)
|
|
9
|
+
*/
|
|
10
|
+
class PublicThreadChannel extends ThreadChannel {
|
|
11
|
+
update(data) {
|
|
12
|
+
super.update(data);
|
|
13
|
+
if (data.applied_tags !== undefined) {
|
|
14
|
+
this.appliedTags = data.applied_tags;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
toJSON(props = []) {
|
|
19
|
+
super.toJSON([
|
|
20
|
+
"appliedTags",
|
|
21
|
+
...props,
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = PublicThreadChannel;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
const Endpoints = require("../rest/Endpoints");
|
|
5
|
+
const Permission = require("./Permission");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a role
|
|
9
|
+
* @prop {Number} color The hex color of the role in base 10
|
|
10
|
+
* @prop {Object} colors The role's colors
|
|
11
|
+
* @prop {Number} colors.primaryColor The primary color of the role
|
|
12
|
+
* @prop {Number?} colors.secondaryColor The secondary color of the role (for gradient roles)
|
|
13
|
+
* @prop {Number?} colors.tertiaryColor The tertiary color of the role (for holographic roles)
|
|
14
|
+
* @prop {Number} createdAt Timestamp of the role's creation
|
|
15
|
+
* @prop {Number} flags The flags of the role (see constants)
|
|
16
|
+
* @prop {Guild} guild The guild that owns the role
|
|
17
|
+
* @prop {Boolean} hoist Whether users with the role are hoisted in the user list or not
|
|
18
|
+
* @prop {String?} icon The hash of the role's icon, or null if no icon
|
|
19
|
+
* @prop {String?} iconURL The URL of the role's icon
|
|
20
|
+
* @prop {String} id The ID of the role
|
|
21
|
+
* @prop {Object} json Generates a JSON representation of the role permissions
|
|
22
|
+
* @prop {Boolean} managed Whether a guild integration manages the role or not
|
|
23
|
+
* @prop {String} mention A string that mentions the role
|
|
24
|
+
* @prop {Boolean} mentionable Whether the role is mentionable or not
|
|
25
|
+
* @prop {String} name The name of the role
|
|
26
|
+
* @prop {Permission} permissions The permissions representation of the role
|
|
27
|
+
* @prop {Number} position The position of the role
|
|
28
|
+
* @prop {Object?} tags The tags of the role
|
|
29
|
+
* @prop {String?} tags.bot_id The ID of the bot associated with the role
|
|
30
|
+
* @prop {String?} tags.integration_id The ID of the integration associated with the role
|
|
31
|
+
* @prop {Boolean?} tags.premium_subscriber Whether the role is the guild's premium subscriber role
|
|
32
|
+
* @prop {String?} tags.subscription_listing_id The id of the role's subscription sku and listing
|
|
33
|
+
* @prop {Boolean?} tags.available_for_purchase Whether the role is available for purchase
|
|
34
|
+
* @prop {Boolean?} tags.guild_connections Whether the role is a guild's linked role
|
|
35
|
+
* @prop {String?} unicodeEmoji Unicode emoji for the role
|
|
36
|
+
*/
|
|
37
|
+
class Role extends Base {
|
|
38
|
+
constructor(data, guild) {
|
|
39
|
+
super(data.id);
|
|
40
|
+
this.guild = guild; // REVIEW Should really consider changing this to client
|
|
41
|
+
this.update(data);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
update(data) {
|
|
45
|
+
if (data.name !== undefined) {
|
|
46
|
+
this.name = data.name;
|
|
47
|
+
}
|
|
48
|
+
if (data.mentionable !== undefined) {
|
|
49
|
+
this.mentionable = data.mentionable;
|
|
50
|
+
}
|
|
51
|
+
if (data.managed !== undefined) {
|
|
52
|
+
this.managed = data.managed;
|
|
53
|
+
}
|
|
54
|
+
if (data.hoist !== undefined) {
|
|
55
|
+
this.hoist = data.hoist;
|
|
56
|
+
}
|
|
57
|
+
if (data.color !== undefined) {
|
|
58
|
+
this.color = data.color;
|
|
59
|
+
}
|
|
60
|
+
if (data.colors !== undefined) {
|
|
61
|
+
this.colors = {
|
|
62
|
+
primaryColor: data.colors.primary_color,
|
|
63
|
+
secondaryColor: data.colors.secondary_color,
|
|
64
|
+
tertiaryColor: data.colors.tertiary_color,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (data.position !== undefined) {
|
|
68
|
+
this.position = data.position;
|
|
69
|
+
}
|
|
70
|
+
if (data.permissions !== undefined) {
|
|
71
|
+
this.permissions = new Permission(data.permissions);
|
|
72
|
+
}
|
|
73
|
+
if (data.tags !== undefined) {
|
|
74
|
+
this.tags = data.tags;
|
|
75
|
+
if (this.tags.available_for_purchase === null) {
|
|
76
|
+
this.tags.available_for_purchase = true;
|
|
77
|
+
} else if (this.tags.guild_connections === null) {
|
|
78
|
+
this.tags.guild_connections = true;
|
|
79
|
+
} else if (this.tags.premium_subscriber === null) {
|
|
80
|
+
this.tags.premium_subscriber = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (data.icon !== undefined) {
|
|
84
|
+
this.icon = data.icon;
|
|
85
|
+
}
|
|
86
|
+
if (data.unicode_emoji !== undefined) {
|
|
87
|
+
this.unicodeEmoji = data.unicode_emoji;
|
|
88
|
+
}
|
|
89
|
+
if (data.flags !== undefined) {
|
|
90
|
+
this.flags = data.flags;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get iconURL() {
|
|
95
|
+
return this.icon ? this.guild.shard.client._formatImage(Endpoints.ROLE_ICON(this.id, this.icon)) : null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get json() {
|
|
99
|
+
return this.permissions.json;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
get mention() {
|
|
103
|
+
return `<@&${this.id}>`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Delete the role
|
|
108
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
109
|
+
* @returns {Promise}
|
|
110
|
+
*/
|
|
111
|
+
delete(reason) {
|
|
112
|
+
return this.guild.shard.client.deleteRole.call(this.guild.shard.client, this.guild.id, this.id, reason);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Edit the guild role
|
|
117
|
+
* @arg {Object} options The properties to edit
|
|
118
|
+
* @arg {Number} [options.color] The hex color of the role, in number form (ex: 0x3da5b3 or 4040115)
|
|
119
|
+
* @arg {Object} [options.colors] The role's colors
|
|
120
|
+
* @arg {Number} [options.colors.primaryColor] The primary color of the role
|
|
121
|
+
* @arg {Number?} [options.colors.secondaryColor] The secondary color of the role (for gradient roles)
|
|
122
|
+
* @arg {Number?} [options.colors.tertiaryColor] The tertiary color of the role (for holographic roles)
|
|
123
|
+
* @arg {Boolean} [options.hoist] Whether to hoist the role in the user list or not
|
|
124
|
+
* @arg {String} [options.icon] The role icon as a base64 data URI
|
|
125
|
+
* @arg {Boolean} [options.mentionable] Whether the role is mentionable or not
|
|
126
|
+
* @arg {String} [options.name] The name of the role
|
|
127
|
+
* @arg {BigInt | Number} [options.permissions] The role permissions number
|
|
128
|
+
* @arg {String?} [options.unicodeEmoji] The role's unicode emoji
|
|
129
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
130
|
+
* @returns {Promise<Role>}
|
|
131
|
+
*/
|
|
132
|
+
edit(options, reason) {
|
|
133
|
+
return this.guild.shard.client.editRole.call(this.guild.shard.client, this.guild.id, this.id, options, reason);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Edit the role's position. Note that role position numbers are highest on top and lowest at the bottom.
|
|
138
|
+
* @arg {Number} position The new position of the role
|
|
139
|
+
* @returns {Promise}
|
|
140
|
+
*/
|
|
141
|
+
editPosition(position) {
|
|
142
|
+
return this.guild.shard.client.editRolePosition.call(this.guild.shard.client, this.guild.id, this.id, position);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
toJSON(props = []) {
|
|
146
|
+
return super.toJSON([
|
|
147
|
+
"color",
|
|
148
|
+
"colors",
|
|
149
|
+
"hoist",
|
|
150
|
+
"icon",
|
|
151
|
+
"managed",
|
|
152
|
+
"mentionable",
|
|
153
|
+
"name",
|
|
154
|
+
"permissions",
|
|
155
|
+
"position",
|
|
156
|
+
"tags",
|
|
157
|
+
"unicodeEmoji",
|
|
158
|
+
...props,
|
|
159
|
+
]);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
module.exports = Role;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a SKU (premium offering of an application)
|
|
7
|
+
* @prop {String} applicationID The ID of the parent application
|
|
8
|
+
* @prop {Number} flags The SKU flags combined as a bitfield. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/sku#sku-object-sku-flags) for a list of flags
|
|
9
|
+
* @prop {String} id The ID of the SKU
|
|
10
|
+
* @prop {String} name The customer-facing name of the SKU
|
|
11
|
+
* @prop {String} slug The system-generated URL slug based on the SKU's name
|
|
12
|
+
* @prop {Number} type The type of the SKU. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/sku#sku-object-sku-types) for a list of types
|
|
13
|
+
*/
|
|
14
|
+
class SKU extends Base {
|
|
15
|
+
constructor(data, client) {
|
|
16
|
+
super(data.id);
|
|
17
|
+
this._client = client;
|
|
18
|
+
this.applicationID = data.application_id;
|
|
19
|
+
this.flags = data.flags;
|
|
20
|
+
this.name = data.name;
|
|
21
|
+
this.slug = data.slug;
|
|
22
|
+
this.type = data.type;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create a test entitlement for this SKU
|
|
27
|
+
* @arg {String} ownerID The ID of the guild or user to grant the entitlement to
|
|
28
|
+
* @arg {Number} ownerType The type of the owner. `1` for a guild, `2` for a user
|
|
29
|
+
* @returns {Promise<Entitlement>}
|
|
30
|
+
*/
|
|
31
|
+
createTestEntitlement(ownerID, ownerType) {
|
|
32
|
+
return this._client.createTestEntitlement.call(this._client, {
|
|
33
|
+
ownerID: ownerID,
|
|
34
|
+
ownerType: ownerType,
|
|
35
|
+
skuID: this.id,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get the entitlements for this SKU
|
|
41
|
+
* @arg {Object} [options] Options for the request. See `Client#getEntitlements` for the full list of options (`skuIDs` is ignored)
|
|
42
|
+
* @returns {Promise<Array<Entitlement>>}
|
|
43
|
+
*/
|
|
44
|
+
getEntitlements(options = {}) {
|
|
45
|
+
return this._client.getEntitlements.call(this._client, Object.assign({}, options, {
|
|
46
|
+
skuIDs: [this.id],
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get a subscription to this SKU
|
|
52
|
+
* @arg {String} subscriptionID The ID of the subscription
|
|
53
|
+
* @returns {Promise<Subscription>}
|
|
54
|
+
*/
|
|
55
|
+
getSKUSubscription(subscriptionID) {
|
|
56
|
+
return this._client.getSKUSubscription.call(this._client, this.id, subscriptionID);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Get the subscriptions to this SKU
|
|
61
|
+
* @arg {Object} options Options for the request. See `Client#getSKUSubscriptions` for the full list of options
|
|
62
|
+
* @returns {Promise<Array<Subscription>>}
|
|
63
|
+
*/
|
|
64
|
+
getSKUSubscriptions(options) {
|
|
65
|
+
return this._client.getSKUSubscriptions.call(this._client, this.id, options);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
toJSON(props = []) {
|
|
69
|
+
return super.toJSON([
|
|
70
|
+
"applicationID",
|
|
71
|
+
"flags",
|
|
72
|
+
"name",
|
|
73
|
+
"slug",
|
|
74
|
+
"type",
|
|
75
|
+
...props,
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = SKU;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a Soundboard Sound
|
|
7
|
+
* @prop {Boolean} available Whether the soundboard sound is available or not (will always be true for default soundboard sounds)
|
|
8
|
+
* @prop {String?} emojiID The ID of the relating custom emoji (will always be null for default soundboard sounds)
|
|
9
|
+
* @prop {String?} emojiName The name mof the relating default emoji
|
|
10
|
+
* @prop {Guild?} guild The guild where the soundboard sound was created in (not present for default soundboard sounds). If the guild is uncached, this will be an object with an `id` key. No other keys are guaranteed
|
|
11
|
+
* @prop {String} id The ID of the soundboard sound
|
|
12
|
+
* @prop {String} name The name of the soundboard sound
|
|
13
|
+
* @prop {User?} user The user that created the soundboard sound (not present for default soundboard sounds, or if the bot doesn't have either create/editGuildExpressions permissions)
|
|
14
|
+
* @prop {Number} volume The volume of the soundboard sound, between 0 and 1
|
|
15
|
+
*/
|
|
16
|
+
class SoundboardSound extends Base {
|
|
17
|
+
constructor(data, client) {
|
|
18
|
+
super(data.id);
|
|
19
|
+
this._client = client;
|
|
20
|
+
if (data.guild_id !== undefined) {
|
|
21
|
+
this.guild = client.guilds.get(data.guild_id) || { id: data.guild_id };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
update(data) {
|
|
26
|
+
if (data.name !== undefined) {
|
|
27
|
+
this.name = data.name;
|
|
28
|
+
}
|
|
29
|
+
if (data.volume !== undefined) {
|
|
30
|
+
this.volume = data.volume;
|
|
31
|
+
}
|
|
32
|
+
if (data.emoji_id !== undefined) {
|
|
33
|
+
this.emojiID = data.emoji_id;
|
|
34
|
+
}
|
|
35
|
+
if (data.emoji_name !== undefined) {
|
|
36
|
+
this.emojiName = data.emoji_name;
|
|
37
|
+
}
|
|
38
|
+
if (data.available !== undefined) {
|
|
39
|
+
this.available = data.available;
|
|
40
|
+
}
|
|
41
|
+
if (data.user !== undefined) {
|
|
42
|
+
this.user = this._client.users.update(data.user, this._client);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Delete the soundboard sound (not available for default soundboard sounds)
|
|
48
|
+
* @arg {String} [reason] The reason to be displayed in audit logs
|
|
49
|
+
* @returns {Promise}
|
|
50
|
+
*/
|
|
51
|
+
delete(reason) {
|
|
52
|
+
return this._client.deleteGuildSoundboardSound.call(this._client, this.guild.id, this.id, reason);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Edit the soundboard sound (not available for default soundboard sounds)
|
|
57
|
+
* @arg {Object} options The properties to edit
|
|
58
|
+
* @arg {String?} [options.emojiID] The ID of the relating custom emoji (mutually exclusive with options.emojiName)
|
|
59
|
+
* @arg {String?} [options.emojiName] The name of the relating default emoji (mutually exclusive with options.emojiID)
|
|
60
|
+
* @arg {String} [options.name] The name of the soundboard sound (2-32 characters)
|
|
61
|
+
* @arg {Number?} [options.volume] The volume of the soundboard sound, between 0 and 1
|
|
62
|
+
* @arg {String} [options.reason] The reason to be displayed in audit logs
|
|
63
|
+
* @returns {Promise<SoundboardSound>}
|
|
64
|
+
*/
|
|
65
|
+
edit(options) {
|
|
66
|
+
return this._client.editGuildSoundboardSound.call(this._client, this.guild.id, this.id, options);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Send the soundboard sound to a connected voice channel
|
|
71
|
+
* @arg {String} channelID The ID of the connected voice channel
|
|
72
|
+
* @returns {Promise}
|
|
73
|
+
*/
|
|
74
|
+
send(channelID) {
|
|
75
|
+
return this._client.sendSoundboardSound.call(this._client, channelID, { soundID: this.id, sourceGuildID: this.guild.id });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = SoundboardSound;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const VoiceChannel = require("./VoiceChannel");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a guild stage channel. See VoiceChannel for more properties and methods.
|
|
7
|
+
* @extends VoiceChannel
|
|
8
|
+
*/
|
|
9
|
+
class StageChannel extends VoiceChannel {
|
|
10
|
+
update(data) {
|
|
11
|
+
super.update(data);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Create a stage instance
|
|
16
|
+
* @arg {Object} options The stage instance options
|
|
17
|
+
* @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public, 2 is guild only
|
|
18
|
+
* @arg {String} options.topic The stage instance topic
|
|
19
|
+
* @returns {Promise<StageInstance>}
|
|
20
|
+
*/
|
|
21
|
+
createInstance(options) {
|
|
22
|
+
return this._client.createStageInstance.call(this._client, this.id, options);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Delete the stage instance for this channel
|
|
27
|
+
* @returns {Promise}
|
|
28
|
+
*/
|
|
29
|
+
deleteInstance() {
|
|
30
|
+
return this._client.deleteStageInstance.call(this._client, this.id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Update the stage instance for this channel
|
|
35
|
+
* @arg {Object} options The properties to edit
|
|
36
|
+
* @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public, 2 is guild only
|
|
37
|
+
* @arg {String} [options.topic] The stage instance topic
|
|
38
|
+
* @returns {Promise<StageInstance>}
|
|
39
|
+
*/
|
|
40
|
+
editInstance(options) {
|
|
41
|
+
return this._client.editStageInstance.call(this._client, this.id, options);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get the stage instance for this channel
|
|
46
|
+
* @returns {Promise<StageInstance>}
|
|
47
|
+
*/
|
|
48
|
+
getInstance() {
|
|
49
|
+
return this._client.getStageInstance.call(this._client, this.id);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
toJSON(props = []) {
|
|
53
|
+
return super.toJSON([
|
|
54
|
+
...props,
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = StageChannel;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a stage instance
|
|
7
|
+
* @prop {StageChannel} channel The associated stage channel
|
|
8
|
+
* @prop {Boolean} discoverableDisabled Whether or not stage discovery is disabled
|
|
9
|
+
* @prop {Guild} guild The guild of the associated stage channel
|
|
10
|
+
* @prop {String} id The ID of the stage instance
|
|
11
|
+
* @prop {Number} privacyLevel The privacy level of the stage instance. 1 is public, 2 is guild only
|
|
12
|
+
* @prop {String} topic The stage instance topic
|
|
13
|
+
*/
|
|
14
|
+
class StageInstance extends Base {
|
|
15
|
+
constructor(data, client) {
|
|
16
|
+
super(data.id);
|
|
17
|
+
this._client = client;
|
|
18
|
+
this.channel = client.getChannel(data.channel_id) || { id: data.channel_id };
|
|
19
|
+
this.guild = client.guilds.get(data.guild_id) || { id: data.guild_id };
|
|
20
|
+
this.update(data);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
update(data) {
|
|
24
|
+
if (data.discoverable_disabled !== undefined) {
|
|
25
|
+
this.discoverableDisabled = data.discoverable_disabled;
|
|
26
|
+
}
|
|
27
|
+
if (data.privacy_level !== undefined) {
|
|
28
|
+
this.privacyLevel = data.privacy_level;
|
|
29
|
+
}
|
|
30
|
+
if (data.topic !== undefined) {
|
|
31
|
+
this.topic = data.topic;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Delete this stage instance
|
|
37
|
+
* @returns {Promise}
|
|
38
|
+
*/
|
|
39
|
+
delete() {
|
|
40
|
+
return this._client.deleteStageInstance.call(this._client, this.channel.id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Update this stage instance
|
|
45
|
+
* @arg {Object} options The properties to edit
|
|
46
|
+
* @arg {Number} [options.privacyLevel] The privacy level of the stage instance. 1 is public, 2 is guild only
|
|
47
|
+
* @arg {String} [options.topic] The stage instance topic
|
|
48
|
+
* @returns {Promise<StageInstance>}
|
|
49
|
+
*/
|
|
50
|
+
edit(options) {
|
|
51
|
+
return this._client.editStageInstance.call(this._client, this.channel.id, options);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = StageInstance;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const Base = require("./Base");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a subscription to a premium application SKU
|
|
7
|
+
* @prop {Number?} canceledAt Timestamp of when the subscription was canceled
|
|
8
|
+
* @prop {String?} country The ISO3166-1 alpha-2 country code of the payment source used to purchase the subscription. Missing unless queried with a private OAuth scope
|
|
9
|
+
* @prop {Number} currentPeriodEnd Timestamp of the end of the current subscription period
|
|
10
|
+
* @prop {Number} currentPeriodStart Timestamp of the start of the current subscription period
|
|
11
|
+
* @prop {Array<String>} entitlementIDs The IDs of the entitlements granted for this subscription
|
|
12
|
+
* @prop {String} id The ID of the subscription
|
|
13
|
+
* @prop {Array<String>?} renewalSKUIDs The IDs of the SKUs that this user will be subscribed to at renewal
|
|
14
|
+
* @prop {Array<String>} skuIDs The IDs of the SKUs subscribed to
|
|
15
|
+
* @prop {Number} status The current status of the subscription. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/subscription#subscription-statuses) for a list of statuses
|
|
16
|
+
* @prop {String} userID The ID of the user who is subscribed
|
|
17
|
+
*/
|
|
18
|
+
class Subscription extends Base {
|
|
19
|
+
constructor(data, client) {
|
|
20
|
+
super(data.id);
|
|
21
|
+
this._client = client;
|
|
22
|
+
this.userID = data.user_id;
|
|
23
|
+
this.update(data);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
update(data) {
|
|
27
|
+
if (data.canceled_at !== undefined) {
|
|
28
|
+
this.canceledAt = data.canceled_at ? Date.parse(data.canceled_at) : null;
|
|
29
|
+
}
|
|
30
|
+
if (data.country !== undefined) {
|
|
31
|
+
this.country = data.country;
|
|
32
|
+
}
|
|
33
|
+
if (data.current_period_end !== undefined) {
|
|
34
|
+
this.currentPeriodEnd = Date.parse(data.current_period_end);
|
|
35
|
+
}
|
|
36
|
+
if (data.current_period_start !== undefined) {
|
|
37
|
+
this.currentPeriodStart = Date.parse(data.current_period_start);
|
|
38
|
+
}
|
|
39
|
+
if (data.entitlement_ids !== undefined) {
|
|
40
|
+
this.entitlementIDs = data.entitlement_ids;
|
|
41
|
+
}
|
|
42
|
+
if (data.renewal_sku_ids !== undefined) {
|
|
43
|
+
this.renewalSKUIDs = data.renewal_sku_ids;
|
|
44
|
+
}
|
|
45
|
+
if (data.sku_ids !== undefined) {
|
|
46
|
+
this.skuIDs = data.sku_ids;
|
|
47
|
+
}
|
|
48
|
+
if (data.status !== undefined) {
|
|
49
|
+
this.status = data.status;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
toJSON(props = []) {
|
|
54
|
+
return super.toJSON([
|
|
55
|
+
"canceledAt",
|
|
56
|
+
"country",
|
|
57
|
+
"currentPeriodEnd",
|
|
58
|
+
"currentPeriodStart",
|
|
59
|
+
"entitlementIDs",
|
|
60
|
+
"renewalSKUIDs",
|
|
61
|
+
"skuIDs",
|
|
62
|
+
"status",
|
|
63
|
+
"userID",
|
|
64
|
+
...props,
|
|
65
|
+
]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = Subscription;
|