@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.
Files changed (88) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +109 -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,166 +1,166 @@
1
- "use strict";
2
-
3
- const Collection = require("../util/Collection");
4
- const GuildTextableChannel = require("./GuildTextableChannel");
5
- const Member = require("./Member");
6
- const PermissionOverwrite = require("./PermissionOverwrite");
7
-
8
- /**
9
- * Represents a guild voice channel. See GuildTextableChannel for more properties and methods
10
- * @extends GuildTextableChannel
11
- * @prop {Number?} bitrate The bitrate of the channel
12
- * @prop {Boolean} nsfw Whether the channel is an NSFW channel or not
13
- * @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in the channel
14
- * @prop {Number} position The position of the channel
15
- * @prop {String?} rtcRegion The RTC region ID of the channel (automatic when `null`)
16
- * @prop {String?} status The voice channel status
17
- * @prop {Number?} userLimit The max number of users that can join the channel
18
- * @prop {Number?} videoQualityMode The camera video quality mode of the voice channel. `1` is auto, `2` is 720p
19
- * @prop {Collection<Member>} voiceMembers Collection of Members in this channel
20
- * @prop {Number?} voiceStartTime Timestamp of when the current voice session of the channel started. Only available after a `voiceChannelStartTimeUpdate` event or `Guild#fetchChannelInfo()`
21
- */
22
- class VoiceChannel extends GuildTextableChannel {
23
- constructor(data, client) {
24
- super(data, client);
25
- this.voiceMembers = new Collection(Member);
26
- this.update(data);
27
- }
28
-
29
- update(data) {
30
- super.update(data);
31
- if (data.position !== undefined) {
32
- this.position = data.position;
33
- }
34
- if (data.permission_overwrites !== undefined) {
35
- this.permissionOverwrites = new Collection(PermissionOverwrite);
36
- data.permission_overwrites.forEach((overwrite) => {
37
- this.permissionOverwrites.add(overwrite);
38
- });
39
- }
40
- if (data.nsfw !== undefined) {
41
- this.nsfw = data.nsfw;
42
- }
43
- if (data.bitrate !== undefined) {
44
- this.bitrate = data.bitrate;
45
- }
46
- if (data.user_limit !== undefined) {
47
- this.userLimit = data.user_limit;
48
- }
49
- if (data.rtc_region !== undefined) {
50
- this.rtcRegion = data.rtc_region;
51
- }
52
- if (data.video_quality_mode !== undefined) {
53
- this.videoQualityMode = data.video_quality_mode;
54
- }
55
- if (data.status !== undefined) {
56
- this.status = data.status;
57
- }
58
- if (data.voice_start_time !== undefined) {
59
- this.voiceStartTime = data.voice_start_time ? data.voice_start_time * 1000 : null;
60
- }
61
- }
62
-
63
- /**
64
- * Create an invite for the channel
65
- * @arg {Object} [options] Invite generation options
66
- * @arg {Number} [options.maxAge] How long the invite should last in seconds
67
- * @arg {Number} [options.maxUses] How many uses the invite should last for
68
- * @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not
69
- * @arg {Boolean} [options.unique] Whether the invite is unique or not
70
- * @arg {String} [reason] The reason to be displayed in audit logs
71
- * @returns {Promise<Invite>}
72
- */
73
- createInvite(options, reason) {
74
- return this._client.createChannelInvite.call(this._client, this.id, options, reason);
75
- }
76
-
77
- /**
78
- * Delete a channel permission overwrite
79
- * @arg {String} overwriteID The ID of the overwritten user or role
80
- * @arg {String} [reason] The reason to be displayed in audit logs
81
- * @returns {Promise}
82
- */
83
- deletePermission(overwriteID, reason) {
84
- return this._client.deleteChannelPermission.call(this._client, this.id, overwriteID, reason);
85
- }
86
-
87
- /**
88
- * Create a channel permission overwrite
89
- * @arg {String} overwriteID The ID of the overwritten user or role
90
- * @arg {BigInt | Number | String} allow The permissions number for allowed permissions
91
- * @arg {BigInt | Number | String} deny The permissions number for denied permissions
92
- * @arg {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role"
93
- * @arg {String} [reason] The reason to be displayed in audit logs
94
- * @returns {Promise<PermissionOverwrite>}
95
- */
96
- editPermission(overwriteID, allow, deny, type, reason) {
97
- return this._client.editChannelPermission.call(this._client, this.id, overwriteID, allow, deny, type, reason);
98
- }
99
-
100
- /**
101
- * Get all invites in the channel
102
- * @returns {Promise<Array<Invite>>}
103
- */
104
- getInvites() {
105
- return this._client.getChannelInvites.call(this._client, this.id);
106
- }
107
-
108
- /**
109
- * Joins the channel
110
- * @arg {Object} [options] VoiceConnection constructor options
111
- * @arg {Object} [options.opusOnly] Skip opus encoder initialization. You should not enable this unless you know what you are doing
112
- * @arg {Boolean} [options.selfDeaf] Whether the bot joins the channel deafened or not
113
- * @arg {Boolean} [options.selfMute] Whether the bot joins the channel muted or not
114
- * @arg {Object} [options.shared] Whether the VoiceConnection will be part of a SharedStream or not
115
- * @returns {Promise<VoiceConnection>} Resolves with a VoiceConnection
116
- */
117
- join(options) {
118
- return this._client.joinVoiceChannel.call(this._client, this.id, options);
119
- }
120
-
121
- /**
122
- * Leaves the channel
123
- */
124
- leave() {
125
- return this._client.leaveVoiceChannel.call(this._client, this.id);
126
- }
127
-
128
- /**
129
- * Send a soundboard sound to the voice channel
130
- * @arg {Object} options The soundboard sound options
131
- * @arg {String} options.soundID The ID of the soundboard sound
132
- * @arg {String} [options.sourceGuildID] The ID of the guild where the soundboard sound was created, if not in the same guild
133
- * @returns {Promise}
134
- */
135
- sendSoundboardSound(options) {
136
- return this._client.sendSoundboardSound.call(this._client, this.id, options);
137
- }
138
-
139
- /**
140
- * Set the status of the voice channel. Note: This will not work in stage channels
141
- * @arg {String} status The new voice channel status
142
- * @arg {String} [reason] The reason to be displayed in audit logs
143
- * @returns {Promise}
144
- */
145
- setStatus(status, reason) {
146
- return this._client.setVoiceChannelStatus.call(this._client, this.id, status, reason);
147
- }
148
-
149
- toJSON(props = []) {
150
- return super.toJSON([
151
- "bitrate",
152
- "nsfw",
153
- "permissionOverwrites",
154
- "position",
155
- "rtcRegion",
156
- "status",
157
- "userLimit",
158
- "videoQualityMode",
159
- "voiceMembers",
160
- "voiceStartTime",
161
- ...props,
162
- ]);
163
- }
164
- }
165
-
166
- module.exports = VoiceChannel;
1
+ "use strict";
2
+
3
+ const Collection = require("../util/Collection");
4
+ const GuildTextableChannel = require("./GuildTextableChannel");
5
+ const Member = require("./Member");
6
+ const PermissionOverwrite = require("./PermissionOverwrite");
7
+
8
+ /**
9
+ * Represents a guild voice channel. See GuildTextableChannel for more properties and methods
10
+ * @extends GuildTextableChannel
11
+ * @prop {Number?} bitrate The bitrate of the channel
12
+ * @prop {Boolean} nsfw Whether the channel is an NSFW channel or not
13
+ * @prop {Collection<PermissionOverwrite>} permissionOverwrites Collection of PermissionOverwrites in the channel
14
+ * @prop {Number} position The position of the channel
15
+ * @prop {String?} rtcRegion The RTC region ID of the channel (automatic when `null`)
16
+ * @prop {String?} status The voice channel status
17
+ * @prop {Number?} userLimit The max number of users that can join the channel
18
+ * @prop {Number?} videoQualityMode The camera video quality mode of the voice channel. `1` is auto, `2` is 720p
19
+ * @prop {Collection<Member>} voiceMembers Collection of Members in this channel
20
+ * @prop {Number?} voiceStartTime Timestamp of when the current voice session of the channel started. Only available after a `voiceChannelStartTimeUpdate` event or `Guild#fetchChannelInfo()`
21
+ */
22
+ class VoiceChannel extends GuildTextableChannel {
23
+ constructor(data, client) {
24
+ super(data, client);
25
+ this.voiceMembers = new Collection(Member);
26
+ this.update(data);
27
+ }
28
+
29
+ update(data) {
30
+ super.update(data);
31
+ if (data.position !== undefined) {
32
+ this.position = data.position;
33
+ }
34
+ if (data.permission_overwrites !== undefined) {
35
+ this.permissionOverwrites = new Collection(PermissionOverwrite);
36
+ data.permission_overwrites.forEach((overwrite) => {
37
+ this.permissionOverwrites.add(overwrite);
38
+ });
39
+ }
40
+ if (data.nsfw !== undefined) {
41
+ this.nsfw = data.nsfw;
42
+ }
43
+ if (data.bitrate !== undefined) {
44
+ this.bitrate = data.bitrate;
45
+ }
46
+ if (data.user_limit !== undefined) {
47
+ this.userLimit = data.user_limit;
48
+ }
49
+ if (data.rtc_region !== undefined) {
50
+ this.rtcRegion = data.rtc_region;
51
+ }
52
+ if (data.video_quality_mode !== undefined) {
53
+ this.videoQualityMode = data.video_quality_mode;
54
+ }
55
+ if (data.status !== undefined) {
56
+ this.status = data.status;
57
+ }
58
+ if (data.voice_start_time !== undefined) {
59
+ this.voiceStartTime = data.voice_start_time ? data.voice_start_time * 1000 : null;
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Create an invite for the channel
65
+ * @arg {Object} [options] Invite generation options
66
+ * @arg {Number} [options.maxAge] How long the invite should last in seconds
67
+ * @arg {Number} [options.maxUses] How many uses the invite should last for
68
+ * @arg {Boolean} [options.temporary] Whether the invite grants temporary membership or not
69
+ * @arg {Boolean} [options.unique] Whether the invite is unique or not
70
+ * @arg {String} [reason] The reason to be displayed in audit logs
71
+ * @returns {Promise<Invite>}
72
+ */
73
+ createInvite(options, reason) {
74
+ return this._client.createChannelInvite.call(this._client, this.id, options, reason);
75
+ }
76
+
77
+ /**
78
+ * Delete a channel permission overwrite
79
+ * @arg {String} overwriteID The ID of the overwritten user or role
80
+ * @arg {String} [reason] The reason to be displayed in audit logs
81
+ * @returns {Promise}
82
+ */
83
+ deletePermission(overwriteID, reason) {
84
+ return this._client.deleteChannelPermission.call(this._client, this.id, overwriteID, reason);
85
+ }
86
+
87
+ /**
88
+ * Create a channel permission overwrite
89
+ * @arg {String} overwriteID The ID of the overwritten user or role
90
+ * @arg {BigInt | Number | String} allow The permissions number for allowed permissions
91
+ * @arg {BigInt | Number | String} deny The permissions number for denied permissions
92
+ * @arg {Number} type The object type of the overwrite, either 1 for "member" or 0 for "role"
93
+ * @arg {String} [reason] The reason to be displayed in audit logs
94
+ * @returns {Promise<PermissionOverwrite>}
95
+ */
96
+ editPermission(overwriteID, allow, deny, type, reason) {
97
+ return this._client.editChannelPermission.call(this._client, this.id, overwriteID, allow, deny, type, reason);
98
+ }
99
+
100
+ /**
101
+ * Get all invites in the channel
102
+ * @returns {Promise<Array<Invite>>}
103
+ */
104
+ getInvites() {
105
+ return this._client.getChannelInvites.call(this._client, this.id);
106
+ }
107
+
108
+ /**
109
+ * Joins the channel
110
+ * @arg {Object} [options] VoiceConnection constructor options
111
+ * @arg {Object} [options.opusOnly] Skip opus encoder initialization. You should not enable this unless you know what you are doing
112
+ * @arg {Boolean} [options.selfDeaf] Whether the bot joins the channel deafened or not
113
+ * @arg {Boolean} [options.selfMute] Whether the bot joins the channel muted or not
114
+ * @arg {Object} [options.shared] Whether the VoiceConnection will be part of a SharedStream or not
115
+ * @returns {Promise<VoiceConnection>} Resolves with a VoiceConnection
116
+ */
117
+ join(options) {
118
+ return this._client.joinVoiceChannel.call(this._client, this.id, options);
119
+ }
120
+
121
+ /**
122
+ * Leaves the channel
123
+ */
124
+ leave() {
125
+ return this._client.leaveVoiceChannel.call(this._client, this.id);
126
+ }
127
+
128
+ /**
129
+ * Send a soundboard sound to the voice channel
130
+ * @arg {Object} options The soundboard sound options
131
+ * @arg {String} options.soundID The ID of the soundboard sound
132
+ * @arg {String} [options.sourceGuildID] The ID of the guild where the soundboard sound was created, if not in the same guild
133
+ * @returns {Promise}
134
+ */
135
+ sendSoundboardSound(options) {
136
+ return this._client.sendSoundboardSound.call(this._client, this.id, options);
137
+ }
138
+
139
+ /**
140
+ * Set the status of the voice channel. Note: This will not work in stage channels
141
+ * @arg {String} status The new voice channel status
142
+ * @arg {String} [reason] The reason to be displayed in audit logs
143
+ * @returns {Promise}
144
+ */
145
+ setStatus(status, reason) {
146
+ return this._client.setVoiceChannelStatus.call(this._client, this.id, status, reason);
147
+ }
148
+
149
+ toJSON(props = []) {
150
+ return super.toJSON([
151
+ "bitrate",
152
+ "nsfw",
153
+ "permissionOverwrites",
154
+ "position",
155
+ "rtcRegion",
156
+ "status",
157
+ "userLimit",
158
+ "videoQualityMode",
159
+ "voiceMembers",
160
+ "voiceStartTime",
161
+ ...props,
162
+ ]);
163
+ }
164
+ }
165
+
166
+ module.exports = VoiceChannel;
@@ -1,84 +1,84 @@
1
- "use strict";
2
-
3
- const Base = require("./Base");
4
-
5
- /**
6
- * Represents a member's voice state in a guild
7
- * @prop {String?} channelID The ID of the member's current voice channel
8
- * @prop {Boolean} deaf Whether the member is server deafened or not
9
- * @prop {String} id The ID of the member
10
- * @prop {Boolean} mute Whether the member is server muted or not
11
- * @prop {Number?} requestToSpeakTimestamp Timestamp of the member's latest request to speak
12
- * @prop {Boolean} selfDeaf Whether the member is self deafened or not
13
- * @prop {Boolean} selfMute Whether the member is self muted or not
14
- * @prop {Boolean} selfStream Whether the member is streaming using "Go Live"
15
- * @prop {Boolean} selfVideo Whether the member's camera is enabled
16
- * @prop {String?} sessionID The ID of the member's current voice session
17
- * @prop {Boolean} suppress Whether the member is suppressed or not
18
- */
19
- class VoiceState extends Base {
20
- constructor(data) {
21
- data.id = data.user_id; // Thanks Discord
22
- super(data.id);
23
- this.mute = false;
24
- this.deaf = false;
25
- this.requestToSpeakTimestamp = null;
26
- this.selfMute = false;
27
- this.selfDeaf = false;
28
- this.selfStream = false;
29
- this.selfVideo = false;
30
- this.suppress = false;
31
- this.update(data);
32
- }
33
-
34
- update(data) {
35
- if (data.channel_id !== undefined) {
36
- this.channelID = data.channel_id;
37
- this.sessionID = data.channel_id === null ? null : data.session_id;
38
- } else if (this.channelID === undefined) {
39
- this.channelID = this.sessionID = null;
40
- }
41
- if (data.mute !== undefined) {
42
- this.mute = data.mute;
43
- }
44
- if (data.deaf !== undefined) {
45
- this.deaf = data.deaf;
46
- }
47
- if (data.request_to_speak_timestamp !== undefined) {
48
- this.requestToSpeakTimestamp = Date.parse(data.request_to_speak_timestamp);
49
- }
50
- if (data.self_mute !== undefined) {
51
- this.selfMute = data.self_mute;
52
- }
53
- if (data.self_deaf !== undefined) {
54
- this.selfDeaf = data.self_deaf;
55
- }
56
- if (data.self_video !== undefined) {
57
- this.selfVideo = data.self_video;
58
- }
59
- if (data.self_stream !== undefined) {
60
- this.selfStream = data.self_stream;
61
- }
62
- if (data.suppress !== undefined) { // Bots ignore this
63
- this.suppress = data.suppress;
64
- }
65
- }
66
-
67
- toJSON(props = []) {
68
- return super.toJSON([
69
- "channelID",
70
- "deaf",
71
- "mute",
72
- "requestToSpeakTimestamp",
73
- "selfDeaf",
74
- "selfMute",
75
- "selfStream",
76
- "selfVideo",
77
- "sessionID",
78
- "suppress",
79
- ...props,
80
- ]);
81
- }
82
- }
83
-
84
- module.exports = VoiceState;
1
+ "use strict";
2
+
3
+ const Base = require("./Base");
4
+
5
+ /**
6
+ * Represents a member's voice state in a guild
7
+ * @prop {String?} channelID The ID of the member's current voice channel
8
+ * @prop {Boolean} deaf Whether the member is server deafened or not
9
+ * @prop {String} id The ID of the member
10
+ * @prop {Boolean} mute Whether the member is server muted or not
11
+ * @prop {Number?} requestToSpeakTimestamp Timestamp of the member's latest request to speak
12
+ * @prop {Boolean} selfDeaf Whether the member is self deafened or not
13
+ * @prop {Boolean} selfMute Whether the member is self muted or not
14
+ * @prop {Boolean} selfStream Whether the member is streaming using "Go Live"
15
+ * @prop {Boolean} selfVideo Whether the member's camera is enabled
16
+ * @prop {String?} sessionID The ID of the member's current voice session
17
+ * @prop {Boolean} suppress Whether the member is suppressed or not
18
+ */
19
+ class VoiceState extends Base {
20
+ constructor(data) {
21
+ data.id = data.user_id; // Thanks Discord
22
+ super(data.id);
23
+ this.mute = false;
24
+ this.deaf = false;
25
+ this.requestToSpeakTimestamp = null;
26
+ this.selfMute = false;
27
+ this.selfDeaf = false;
28
+ this.selfStream = false;
29
+ this.selfVideo = false;
30
+ this.suppress = false;
31
+ this.update(data);
32
+ }
33
+
34
+ update(data) {
35
+ if (data.channel_id !== undefined) {
36
+ this.channelID = data.channel_id;
37
+ this.sessionID = data.channel_id === null ? null : data.session_id;
38
+ } else if (this.channelID === undefined) {
39
+ this.channelID = this.sessionID = null;
40
+ }
41
+ if (data.mute !== undefined) {
42
+ this.mute = data.mute;
43
+ }
44
+ if (data.deaf !== undefined) {
45
+ this.deaf = data.deaf;
46
+ }
47
+ if (data.request_to_speak_timestamp !== undefined) {
48
+ this.requestToSpeakTimestamp = Date.parse(data.request_to_speak_timestamp);
49
+ }
50
+ if (data.self_mute !== undefined) {
51
+ this.selfMute = data.self_mute;
52
+ }
53
+ if (data.self_deaf !== undefined) {
54
+ this.selfDeaf = data.self_deaf;
55
+ }
56
+ if (data.self_video !== undefined) {
57
+ this.selfVideo = data.self_video;
58
+ }
59
+ if (data.self_stream !== undefined) {
60
+ this.selfStream = data.self_stream;
61
+ }
62
+ if (data.suppress !== undefined) { // Bots ignore this
63
+ this.suppress = data.suppress;
64
+ }
65
+ }
66
+
67
+ toJSON(props = []) {
68
+ return super.toJSON([
69
+ "channelID",
70
+ "deaf",
71
+ "mute",
72
+ "requestToSpeakTimestamp",
73
+ "selfDeaf",
74
+ "selfMute",
75
+ "selfStream",
76
+ "selfVideo",
77
+ "sessionID",
78
+ "suppress",
79
+ ...props,
80
+ ]);
81
+ }
82
+ }
83
+
84
+ module.exports = VoiceState;
@@ -1,76 +1,76 @@
1
- const util = require("util");
2
- const Base = require("../structures/Base");
3
-
4
- let EventEmitter;
5
- try {
6
- EventEmitter = require("eventemitter3");
7
- } catch {
8
- EventEmitter = require("events").EventEmitter;
9
- }
10
-
11
- class BrowserWebSocketError extends Error {
12
- constructor(message, event) {
13
- super(message);
14
- this.event = event;
15
- }
16
- }
17
-
18
- /**
19
- * Represents a browser's websocket usable by Eris
20
- * @extends EventEmitter
21
- * @prop {String} url The URL to connect to
22
- */
23
- class BrowserWebSocket extends EventEmitter {
24
- constructor(url) {
25
- super();
26
-
27
- if (typeof window === "undefined") {
28
- throw new Error("BrowserWebSocket cannot be used outside of a browser environment");
29
- }
30
-
31
- this._ws = new window.WebSocket(url);
32
- this._ws.onopen = () => this.emit("open");
33
- this._ws.onmessage = this._onMessage.bind(this);
34
- this._ws.onerror = (event) => this.emit("error", new BrowserWebSocketError("Unknown error", event));
35
- this._ws.onclose = (event) => this.emit("close", event.code, event.reason);
36
- }
37
-
38
- get readyState() {
39
- return this._ws.readyState;
40
- }
41
-
42
- close(code, reason) {
43
- return this._ws.close(code, reason);
44
- }
45
-
46
- removeEventListener(type, listener) {
47
- return this.removeListener(type, listener);
48
- }
49
-
50
- send(data) {
51
- return this._ws.send(data);
52
- }
53
-
54
- terminate() {
55
- return this._ws.close();
56
- }
57
-
58
- async _onMessage(event) {
59
- if (event.data instanceof window.Blob) {
60
- this.emit("message", await event.data.arrayBuffer());
61
- } else {
62
- this.emit("message", event.data);
63
- }
64
- }
65
-
66
- [util.inspect.custom]() {
67
- return Base.prototype[util.inspect.custom].call(this);
68
- }
69
- }
70
-
71
- BrowserWebSocket.CONNECTING = 0;
72
- BrowserWebSocket.OPEN = 1;
73
- BrowserWebSocket.CLOSING = 2;
74
- BrowserWebSocket.CLOSED = 3;
75
-
76
- module.exports = BrowserWebSocket;
1
+ const util = require("util");
2
+ const Base = require("../structures/Base");
3
+
4
+ let EventEmitter;
5
+ try {
6
+ EventEmitter = require("eventemitter3");
7
+ } catch {
8
+ EventEmitter = require("events").EventEmitter;
9
+ }
10
+
11
+ class BrowserWebSocketError extends Error {
12
+ constructor(message, event) {
13
+ super(message);
14
+ this.event = event;
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Represents a browser's websocket usable by Eris
20
+ * @extends EventEmitter
21
+ * @prop {String} url The URL to connect to
22
+ */
23
+ class BrowserWebSocket extends EventEmitter {
24
+ constructor(url) {
25
+ super();
26
+
27
+ if (typeof window === "undefined") {
28
+ throw new Error("BrowserWebSocket cannot be used outside of a browser environment");
29
+ }
30
+
31
+ this._ws = new window.WebSocket(url);
32
+ this._ws.onopen = () => this.emit("open");
33
+ this._ws.onmessage = this._onMessage.bind(this);
34
+ this._ws.onerror = (event) => this.emit("error", new BrowserWebSocketError("Unknown error", event));
35
+ this._ws.onclose = (event) => this.emit("close", event.code, event.reason);
36
+ }
37
+
38
+ get readyState() {
39
+ return this._ws.readyState;
40
+ }
41
+
42
+ close(code, reason) {
43
+ return this._ws.close(code, reason);
44
+ }
45
+
46
+ removeEventListener(type, listener) {
47
+ return this.removeListener(type, listener);
48
+ }
49
+
50
+ send(data) {
51
+ return this._ws.send(data);
52
+ }
53
+
54
+ terminate() {
55
+ return this._ws.close();
56
+ }
57
+
58
+ async _onMessage(event) {
59
+ if (event.data instanceof window.Blob) {
60
+ this.emit("message", await event.data.arrayBuffer());
61
+ } else {
62
+ this.emit("message", event.data);
63
+ }
64
+ }
65
+
66
+ [util.inspect.custom]() {
67
+ return Base.prototype[util.inspect.custom].call(this);
68
+ }
69
+ }
70
+
71
+ BrowserWebSocket.CONNECTING = 0;
72
+ BrowserWebSocket.OPEN = 1;
73
+ BrowserWebSocket.CLOSING = 2;
74
+ BrowserWebSocket.CLOSED = 3;
75
+
76
+ module.exports = BrowserWebSocket;