@zygout/eris 0.19.0 → 0.19.2

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.
Files changed (88) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +71 -80
  3. package/esm.mjs +72 -72
  4. package/index.d.ts +4407 -4397
  5. package/index.js +75 -75
  6. package/lib/Client.js +4708 -4683
  7. package/lib/Constants.d.ts +990 -988
  8. package/lib/Constants.js +1163 -1161
  9. package/lib/command/Command.js +552 -552
  10. package/lib/command/CommandClient.js +460 -460
  11. package/lib/errors/DiscordHTTPError.js +63 -63
  12. package/lib/errors/DiscordRESTError.js +77 -77
  13. package/lib/gateway/Shard.js +3029 -3029
  14. package/lib/gateway/ShardManager.js +164 -164
  15. package/lib/rest/Endpoints.js +172 -172
  16. package/lib/rest/RequestHandler.js +459 -459
  17. package/lib/structures/ApplicationCommand.js +125 -125
  18. package/lib/structures/AutoModerationRule.js +143 -143
  19. package/lib/structures/AutocompleteInteraction.js +80 -80
  20. package/lib/structures/Base.js +81 -81
  21. package/lib/structures/CategoryChannel.js +77 -77
  22. package/lib/structures/Channel.js +98 -98
  23. package/lib/structures/CommandInteraction.js +473 -473
  24. package/lib/structures/ComponentInteraction.js +538 -538
  25. package/lib/structures/DMChannel.js +278 -278
  26. package/lib/structures/Entitlement.js +77 -77
  27. package/lib/structures/ExtendedUser.js +46 -46
  28. package/lib/structures/ForumChannel.js +24 -24
  29. package/lib/structures/GroupChannel.js +106 -106
  30. package/lib/structures/Guild.js +1677 -1677
  31. package/lib/structures/GuildAuditLogEntry.js +190 -190
  32. package/lib/structures/GuildChannel.js +128 -128
  33. package/lib/structures/GuildIntegration.js +99 -99
  34. package/lib/structures/GuildPreview.js +97 -97
  35. package/lib/structures/GuildScheduledEvent.js +176 -176
  36. package/lib/structures/GuildTemplate.js +76 -76
  37. package/lib/structures/GuildTextableChannel.js +260 -260
  38. package/lib/structures/Interaction.js +133 -133
  39. package/lib/structures/Invite.js +143 -143
  40. package/lib/structures/Lobby.js +108 -108
  41. package/lib/structures/LobbyMember.js +59 -59
  42. package/lib/structures/MediaChannel.js +216 -216
  43. package/lib/structures/Member.js +371 -371
  44. package/lib/structures/Message.js +708 -708
  45. package/lib/structures/ModalSubmitInteraction.js +478 -478
  46. package/lib/structures/NewsChannel.js +34 -34
  47. package/lib/structures/NewsThreadChannel.js +12 -12
  48. package/lib/structures/Permission.js +80 -80
  49. package/lib/structures/PermissionOverwrite.js +32 -32
  50. package/lib/structures/PingInteraction.js +39 -39
  51. package/lib/structures/PrivateThreadChannel.js +25 -25
  52. package/lib/structures/PublicThreadChannel.js +26 -26
  53. package/lib/structures/Role.js +163 -163
  54. package/lib/structures/SKU.js +80 -80
  55. package/lib/structures/SoundboardSound.js +79 -79
  56. package/lib/structures/StageChannel.js +59 -59
  57. package/lib/structures/StageInstance.js +55 -55
  58. package/lib/structures/Subscription.js +69 -69
  59. package/lib/structures/TextChannel.js +202 -202
  60. package/lib/structures/ThreadChannel.js +143 -143
  61. package/lib/structures/ThreadMember.js +59 -59
  62. package/lib/structures/UnavailableGuild.js +26 -26
  63. package/lib/structures/UnknownInteraction.js +502 -502
  64. package/lib/structures/User.js +296 -296
  65. package/lib/structures/VoiceChannel.js +166 -166
  66. package/lib/structures/VoiceState.js +84 -84
  67. package/lib/util/BrowserWebSocket.js +76 -76
  68. package/lib/util/Bucket.js +89 -89
  69. package/lib/util/Collection.js +202 -202
  70. package/lib/util/MultipartData.js +70 -70
  71. package/lib/util/Opus.js +33 -33
  72. package/lib/util/SequentialBucket.js +83 -83
  73. package/lib/util/emitDeprecation.js +26 -26
  74. package/lib/voice/Piper.js +300 -300
  75. package/lib/voice/SharedStream.js +238 -238
  76. package/lib/voice/VoiceConnection.js +1440 -1440
  77. package/lib/voice/VoiceConnectionManager.js +151 -151
  78. package/lib/voice/VoiceDataStream.js +22 -22
  79. package/lib/voice/streams/BaseTransformer.js +40 -40
  80. package/lib/voice/streams/DCAOpusTransformer.js +78 -78
  81. package/lib/voice/streams/FFmpegDuplex.js +192 -192
  82. package/lib/voice/streams/FFmpegOggTransformer.js +35 -35
  83. package/lib/voice/streams/FFmpegPCMTransformer.js +26 -26
  84. package/lib/voice/streams/OggOpusTransformer.js +108 -108
  85. package/lib/voice/streams/PCMOpusTransformer.js +61 -61
  86. package/lib/voice/streams/VolumeTransformer.js +50 -50
  87. package/lib/voice/streams/WebmOpusTransformer.js +258 -258
  88. package/package.json +83 -82
@@ -1,80 +1,80 @@
1
- "use strict";
2
-
3
- const Interaction = require("./Interaction");
4
- const { InteractionResponseTypes } = require("../Constants");
5
-
6
- /**
7
- * Represents an application command autocomplete interaction. See Interaction for more properties.
8
- * @extends Interaction
9
- * @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
10
- * @prop {DMChannel | TextChannel | NewsChannel} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached
11
- * @prop {Object} data The data attached to the interaction
12
- * @prop {String} data.id The ID of the Application Command
13
- * @prop {String} data.name The command name
14
- * @prop {Array<Object>?} data.options The run Application Command options
15
- * @prop {Boolean?} data.options[].focused Whether or not the option is focused
16
- * @prop {String} data.options[].name The name of the Application Command option
17
- * @prop {Array<Object>?} data.options[].options The run Application Command options (Mutually exclusive with value)
18
- * @prop {Number} data.options[].type Command option type, 1-10
19
- * @prop {(String | Number | Boolean)?} data.options[].value The value of the run Application Command (Mutually exclusive with options)
20
- * @prop {String?} data.target_id The ID the of user or message targetted by a context menu command
21
- * @prop {Number} data.type The [command type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types)
22
- * @prop {String?} guildID The ID of the guild in which the interaction was created
23
- * @prop {Member?} member The member who triggered the interaction (This is only sent when the interaction is invoked within a guild)
24
- * @prop {User?} user The user who triggered the interaction (This is only sent when the interaction is invoked within a dm)
25
- */
26
- class AutocompleteInteraction extends Interaction {
27
- constructor(data, client) {
28
- super(data, client);
29
-
30
- this.channel = this._client.getChannel(data.channel_id) || {
31
- id: data.channel_id,
32
- };
33
-
34
- this.data = data.data;
35
-
36
- if (data.guild_id !== undefined) {
37
- this.guildID = data.guild_id;
38
- }
39
-
40
- if (data.member !== undefined) {
41
- this.member = this._resolveMember(data.member, data);
42
- }
43
-
44
- if (data.user !== undefined) {
45
- this.user = this._client.users.update(data.user, client);
46
- }
47
- }
48
-
49
- /**
50
- * Acknowledges the autocomplete interaction with a result of choices
51
- * Note: You can **not** use more than 1 initial interaction response per interaction
52
- * @arg {Array<Object>} choices The autocomplete choices to return to the user
53
- * @arg {String | Number} choices[].name The choice display name
54
- * @arg {String} choices[].value The choice value to return to the bot
55
- * @returns {Promise}
56
- */
57
- async acknowledge(choices) {
58
- return this.result(choices);
59
- }
60
-
61
- /**
62
- * Acknowledges the autocomplete interaction with a result of choices
63
- * Note: You can **not** use more than 1 initial interaction response per interaction.
64
- * @arg {Array<Object>} choices The autocomplete choices to return to the user
65
- * @arg {String | Number} choices[].name The choice display name
66
- * @arg {String} choices[].value The choice value to return to the bot
67
- * @returns {Promise}
68
- */
69
- async result(choices) {
70
- if (this.acknowledged === true) {
71
- throw new Error("You have already acknowledged this interaction.");
72
- }
73
- return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
74
- type: InteractionResponseTypes.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT,
75
- data: { choices },
76
- }).then(() => this.update());
77
- }
78
- }
79
-
80
- module.exports = AutocompleteInteraction;
1
+ "use strict";
2
+
3
+ const Interaction = require("./Interaction");
4
+ const { InteractionResponseTypes } = require("../Constants");
5
+
6
+ /**
7
+ * Represents an application command autocomplete interaction. See Interaction for more properties.
8
+ * @extends Interaction
9
+ * @prop {Permission?} appPermissions The permissions the app or bot has within the channel the interaction was sent from
10
+ * @prop {DMChannel | TextChannel | NewsChannel} channel The channel the interaction was created in. Can be partial with only the id if the channel is not cached
11
+ * @prop {Object} data The data attached to the interaction
12
+ * @prop {String} data.id The ID of the Application Command
13
+ * @prop {String} data.name The command name
14
+ * @prop {Array<Object>?} data.options The run Application Command options
15
+ * @prop {Boolean?} data.options[].focused Whether or not the option is focused
16
+ * @prop {String} data.options[].name The name of the Application Command option
17
+ * @prop {Array<Object>?} data.options[].options The run Application Command options (Mutually exclusive with value)
18
+ * @prop {Number} data.options[].type Command option type, 1-10
19
+ * @prop {(String | Number | Boolean)?} data.options[].value The value of the run Application Command (Mutually exclusive with options)
20
+ * @prop {String?} data.target_id The ID the of user or message targetted by a context menu command
21
+ * @prop {Number} data.type The [command type](https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-types)
22
+ * @prop {String?} guildID The ID of the guild in which the interaction was created
23
+ * @prop {Member?} member The member who triggered the interaction (This is only sent when the interaction is invoked within a guild)
24
+ * @prop {User?} user The user who triggered the interaction (This is only sent when the interaction is invoked within a dm)
25
+ */
26
+ class AutocompleteInteraction extends Interaction {
27
+ constructor(data, client) {
28
+ super(data, client);
29
+
30
+ this.channel = this._client.getChannel(data.channel_id) || {
31
+ id: data.channel_id,
32
+ };
33
+
34
+ this.data = data.data;
35
+
36
+ if (data.guild_id !== undefined) {
37
+ this.guildID = data.guild_id;
38
+ }
39
+
40
+ if (data.member !== undefined) {
41
+ this.member = this._resolveMember(data.member, data);
42
+ }
43
+
44
+ if (data.user !== undefined) {
45
+ this.user = this._client.users.update(data.user, client);
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Acknowledges the autocomplete interaction with a result of choices
51
+ * Note: You can **not** use more than 1 initial interaction response per interaction
52
+ * @arg {Array<Object>} choices The autocomplete choices to return to the user
53
+ * @arg {String | Number} choices[].name The choice display name
54
+ * @arg {String} choices[].value The choice value to return to the bot
55
+ * @returns {Promise}
56
+ */
57
+ async acknowledge(choices) {
58
+ return this.result(choices);
59
+ }
60
+
61
+ /**
62
+ * Acknowledges the autocomplete interaction with a result of choices
63
+ * Note: You can **not** use more than 1 initial interaction response per interaction.
64
+ * @arg {Array<Object>} choices The autocomplete choices to return to the user
65
+ * @arg {String | Number} choices[].name The choice display name
66
+ * @arg {String} choices[].value The choice value to return to the bot
67
+ * @returns {Promise}
68
+ */
69
+ async result(choices) {
70
+ if (this.acknowledged === true) {
71
+ throw new Error("You have already acknowledged this interaction.");
72
+ }
73
+ return this._client.createInteractionResponse.call(this._client, this.id, this.token, {
74
+ type: InteractionResponseTypes.APPLICATION_COMMAND_AUTOCOMPLETE_RESULT,
75
+ data: { choices },
76
+ }).then(() => this.update());
77
+ }
78
+ }
79
+
80
+ module.exports = AutocompleteInteraction;
@@ -1,81 +1,81 @@
1
- "use strict";
2
-
3
- const util = require("util");
4
-
5
- /**
6
- * Provides utilities for working with many Discord structures
7
- * @prop {String} id A Discord snowflake identifying the object
8
- * @prop {Number} createdAt Timestamp of structure creation
9
- */
10
- class Base {
11
- constructor(id) {
12
- if (id) {
13
- this.id = id;
14
- }
15
- }
16
-
17
- get createdAt() {
18
- return Base.getCreatedAt(this.id);
19
- }
20
-
21
- /**
22
- * Calculates the timestamp in milliseconds associated with a Discord ID/snowflake
23
- * @arg {String} id The ID of a structure
24
- * @returns {Number}
25
- */
26
- static getCreatedAt(id) {
27
- return Base.getDiscordEpoch(id) + 1420070400000;
28
- }
29
-
30
- /**
31
- * Gets the number of milliseconds since epoch represented by an ID/snowflake
32
- * @arg {String} id The ID of a structure
33
- * @returns {Number}
34
- */
35
- static getDiscordEpoch(id) {
36
- return Math.floor(id / 4194304);
37
- }
38
-
39
- [util.inspect.custom]() {
40
- // http://stackoverflow.com/questions/5905492/dynamic-function-name-in-javascript
41
- const copy = new { [this.constructor.name]: class {} }[this.constructor.name]();
42
- for (const key in this) {
43
- if (this.hasOwnProperty(key) && !key.startsWith("_") && this[key] !== undefined) {
44
- copy[key] = this[key];
45
- }
46
- }
47
- return copy;
48
- }
49
-
50
- toString() {
51
- return `[${this.constructor.name} ${this.id}]`;
52
- }
53
-
54
- toJSON(props = []) {
55
- const json = {};
56
- if (this.id) {
57
- json.id = this.id;
58
- json.createdAt = this.createdAt;
59
- }
60
- for (const prop of props) {
61
- const value = this[prop];
62
- const type = typeof value;
63
- if (value === undefined) {
64
- continue;
65
- } else if ((type !== "object" && type !== "function" && type !== "bigint") || value === null) {
66
- json[prop] = value;
67
- } else if (value.toJSON !== undefined) {
68
- json[prop] = value.toJSON();
69
- } else if (value.values !== undefined) {
70
- json[prop] = [...value.values()];
71
- } else if (type === "bigint") {
72
- json[prop] = value.toString();
73
- } else if (type === "object") {
74
- json[prop] = value;
75
- }
76
- }
77
- return json;
78
- }
79
- }
80
-
81
- module.exports = Base;
1
+ "use strict";
2
+
3
+ const util = require("util");
4
+
5
+ /**
6
+ * Provides utilities for working with many Discord structures
7
+ * @prop {String} id A Discord snowflake identifying the object
8
+ * @prop {Number} createdAt Timestamp of structure creation
9
+ */
10
+ class Base {
11
+ constructor(id) {
12
+ if (id) {
13
+ this.id = id;
14
+ }
15
+ }
16
+
17
+ get createdAt() {
18
+ return Base.getCreatedAt(this.id);
19
+ }
20
+
21
+ /**
22
+ * Calculates the timestamp in milliseconds associated with a Discord ID/snowflake
23
+ * @arg {String} id The ID of a structure
24
+ * @returns {Number}
25
+ */
26
+ static getCreatedAt(id) {
27
+ return Base.getDiscordEpoch(id) + 1420070400000;
28
+ }
29
+
30
+ /**
31
+ * Gets the number of milliseconds since epoch represented by an ID/snowflake
32
+ * @arg {String} id The ID of a structure
33
+ * @returns {Number}
34
+ */
35
+ static getDiscordEpoch(id) {
36
+ return Math.floor(id / 4194304);
37
+ }
38
+
39
+ [util.inspect.custom]() {
40
+ // http://stackoverflow.com/questions/5905492/dynamic-function-name-in-javascript
41
+ const copy = new { [this.constructor.name]: class {} }[this.constructor.name]();
42
+ for (const key in this) {
43
+ if (this.hasOwnProperty(key) && !key.startsWith("_") && this[key] !== undefined) {
44
+ copy[key] = this[key];
45
+ }
46
+ }
47
+ return copy;
48
+ }
49
+
50
+ toString() {
51
+ return `[${this.constructor.name} ${this.id}]`;
52
+ }
53
+
54
+ toJSON(props = []) {
55
+ const json = {};
56
+ if (this.id) {
57
+ json.id = this.id;
58
+ json.createdAt = this.createdAt;
59
+ }
60
+ for (const prop of props) {
61
+ const value = this[prop];
62
+ const type = typeof value;
63
+ if (value === undefined) {
64
+ continue;
65
+ } else if ((type !== "object" && type !== "function" && type !== "bigint") || value === null) {
66
+ json[prop] = value;
67
+ } else if (value.toJSON !== undefined) {
68
+ json[prop] = value.toJSON();
69
+ } else if (value.values !== undefined) {
70
+ json[prop] = [...value.values()];
71
+ } else if (type === "bigint") {
72
+ json[prop] = value.toString();
73
+ } else if (type === "object") {
74
+ json[prop] = value;
75
+ }
76
+ }
77
+ return json;
78
+ }
79
+ }
80
+
81
+ module.exports = Base;
@@ -1,77 +1,77 @@
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 category channel. See GuildChannel for more properties and methods
9
- * @extends GuildChannel
10
- * @prop {Collection<GuildChannel>} channels A collection of guild channels that are part of this category
11
- * @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of permission overwrites in the channel
12
- * @prop {Number} position The position of the channel
13
- */
14
- class CategoryChannel extends GuildChannel {
15
- constructor(data, client) {
16
- super(data, client);
17
- this.update(data);
18
- }
19
-
20
- update(data) {
21
- super.update(data);
22
- if (data.position !== undefined) {
23
- this.position = data.position;
24
- }
25
- if (data.permission_overwrites !== undefined) {
26
- this.permissionOverwrites = new Collection(PermissionOverwrite);
27
- data.permission_overwrites.forEach((overwrite) => {
28
- this.permissionOverwrites.add(overwrite);
29
- });
30
- }
31
- }
32
-
33
- get channels() {
34
- const channels = new Collection(GuildChannel);
35
- if (this.guild && this.guild.channels) {
36
- for (const channel of this.guild.channels.values()) {
37
- if (channel.parentID === this.id) {
38
- channels.add(channel);
39
- }
40
- }
41
- }
42
- return channels;
43
- }
44
-
45
- /**
46
- * Delete a channel permission overwrite
47
- * @arg {String} overwriteID The ID of the overwritten user or role
48
- * @arg {String} [reason] The reason to be displayed in audit logs
49
- * @returns {Promise}
50
- */
51
- deletePermission(overwriteID, reason) {
52
- return this._client.deleteChannelPermission.call(this._client, this.id, overwriteID, reason);
53
- }
54
-
55
- /**
56
- * Edit a channel permission overwrite
57
- * @arg {String} overwriteID The ID of the overwritten user or role
58
- * @arg {BigInt | Number | String} allow The permissions number for allowed permissions
59
- * @arg {BigInt | Number | String} deny The permissions number for denied permissions
60
- * @arg {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role"
61
- * @arg {String} [reason] The reason to be displayed in audit logs
62
- * @returns {Promise<PermissionOverwrite>}
63
- */
64
- editPermission(overwriteID, allow, deny, type, reason) {
65
- return this._client.editChannelPermission.call(this._client, this.id, overwriteID, allow, deny, type, reason);
66
- }
67
-
68
- toJSON(props = []) {
69
- return super.toJSON([
70
- "permissionOverwrites",
71
- "position",
72
- ...props,
73
- ]);
74
- }
75
- }
76
-
77
- module.exports = CategoryChannel;
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 category channel. See GuildChannel for more properties and methods
9
+ * @extends GuildChannel
10
+ * @prop {Collection<GuildChannel>} channels A collection of guild channels that are part of this category
11
+ * @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of permission overwrites in the channel
12
+ * @prop {Number} position The position of the channel
13
+ */
14
+ class CategoryChannel extends GuildChannel {
15
+ constructor(data, client) {
16
+ super(data, client);
17
+ this.update(data);
18
+ }
19
+
20
+ update(data) {
21
+ super.update(data);
22
+ if (data.position !== undefined) {
23
+ this.position = data.position;
24
+ }
25
+ if (data.permission_overwrites !== undefined) {
26
+ this.permissionOverwrites = new Collection(PermissionOverwrite);
27
+ data.permission_overwrites.forEach((overwrite) => {
28
+ this.permissionOverwrites.add(overwrite);
29
+ });
30
+ }
31
+ }
32
+
33
+ get channels() {
34
+ const channels = new Collection(GuildChannel);
35
+ if (this.guild && this.guild.channels) {
36
+ for (const channel of this.guild.channels.values()) {
37
+ if (channel.parentID === this.id) {
38
+ channels.add(channel);
39
+ }
40
+ }
41
+ }
42
+ return channels;
43
+ }
44
+
45
+ /**
46
+ * Delete a channel permission overwrite
47
+ * @arg {String} overwriteID The ID of the overwritten user or role
48
+ * @arg {String} [reason] The reason to be displayed in audit logs
49
+ * @returns {Promise}
50
+ */
51
+ deletePermission(overwriteID, reason) {
52
+ return this._client.deleteChannelPermission.call(this._client, this.id, overwriteID, reason);
53
+ }
54
+
55
+ /**
56
+ * Edit a channel permission overwrite
57
+ * @arg {String} overwriteID The ID of the overwritten user or role
58
+ * @arg {BigInt | Number | String} allow The permissions number for allowed permissions
59
+ * @arg {BigInt | Number | String} deny The permissions number for denied permissions
60
+ * @arg {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role"
61
+ * @arg {String} [reason] The reason to be displayed in audit logs
62
+ * @returns {Promise<PermissionOverwrite>}
63
+ */
64
+ editPermission(overwriteID, allow, deny, type, reason) {
65
+ return this._client.editChannelPermission.call(this._client, this.id, overwriteID, allow, deny, type, reason);
66
+ }
67
+
68
+ toJSON(props = []) {
69
+ return super.toJSON([
70
+ "permissionOverwrites",
71
+ "position",
72
+ ...props,
73
+ ]);
74
+ }
75
+ }
76
+
77
+ module.exports = CategoryChannel;