@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,108 +1,108 @@
1
- "use strict";
2
-
3
- const BaseTransformer = require("./BaseTransformer");
4
-
5
- class OggOpusTransformer extends BaseTransformer {
6
- constructor(options = {}) {
7
- super(options);
8
-
9
- this._remainder = null;
10
- this._bitstream = null;
11
- }
12
-
13
- process(buffer) {
14
- if (buffer.length - buffer._index <= 26) {
15
- return true;
16
- }
17
-
18
- if (buffer.toString("utf8", buffer._index, buffer._index + 4) !== "OggS") {
19
- return new Error("Invalid OGG magic string: " + buffer.toString("utf8", buffer._index, buffer._index + 4));
20
- }
21
-
22
- const typeFlag = buffer.readUInt8(buffer._index + 5);
23
- if (typeFlag === 1) {
24
- return new Error("OGG continued page not supported");
25
- }
26
-
27
- const bitstream = buffer.readUInt32BE(buffer._index + 14);
28
-
29
- buffer._index += 26;
30
-
31
- const segmentCount = buffer.readUInt8(buffer._index);
32
- if (buffer.length - buffer._index - 1 < segmentCount) {
33
- return true;
34
- }
35
-
36
- const segments = [];
37
- let size = 0;
38
- let byte = 0;
39
- let total = 0;
40
- let i = 0;
41
- for (; i < segmentCount; i++) {
42
- byte = buffer.readUInt8(++buffer._index);
43
- if (byte < 255) {
44
- segments.push(size + byte);
45
- size = 0;
46
- } else {
47
- size += byte;
48
- }
49
- total += byte;
50
- }
51
-
52
- ++buffer._index;
53
-
54
- if (buffer.length - buffer._index < total) {
55
- return true;
56
- }
57
-
58
- for (let segment of segments) {
59
- buffer._index += segment;
60
- byte = (segment = buffer.subarray(buffer._index - segment, buffer._index)).toString("utf8", 0, 8);
61
- if (this.head) {
62
- if (byte === "OpusTags") {
63
- this.emit("debug", segment.toString());
64
- } else if (bitstream === this._bitstream) {
65
- this.push(segment);
66
- }
67
- } else if (byte === "OpusHead") {
68
- this._bitstream = bitstream;
69
- this.emit("debug", (this.head = segment.toString()));
70
- } else {
71
- this.emit("debug", "Invalid codec: " + byte);
72
- }
73
- }
74
- }
75
-
76
- _final(cb) {
77
- if (!this._bitstream) {
78
- this.emit("error", new Error("No Opus stream was found"));
79
- }
80
- cb();
81
- }
82
-
83
- _transform(chunk, enc, cb) {
84
- if (this._remainder) {
85
- chunk = Buffer.concat([this._remainder, chunk]);
86
- this._remainder = null;
87
- }
88
-
89
- chunk._index = 0;
90
-
91
- while (chunk._index < chunk.length) {
92
- const offset = chunk._index;
93
- const ret = this.process(chunk);
94
- if (ret) {
95
- this._remainder = chunk.subarray(offset);
96
- if (ret instanceof Error) {
97
- this.emit("error", ret);
98
- }
99
- cb();
100
- return;
101
- }
102
- }
103
-
104
- this.setTransformCB(cb);
105
- }
106
- }
107
-
108
- module.exports = OggOpusTransformer;
1
+ "use strict";
2
+
3
+ const BaseTransformer = require("./BaseTransformer");
4
+
5
+ class OggOpusTransformer extends BaseTransformer {
6
+ constructor(options = {}) {
7
+ super(options);
8
+
9
+ this._remainder = null;
10
+ this._bitstream = null;
11
+ }
12
+
13
+ process(buffer) {
14
+ if (buffer.length - buffer._index <= 26) {
15
+ return true;
16
+ }
17
+
18
+ if (buffer.toString("utf8", buffer._index, buffer._index + 4) !== "OggS") {
19
+ return new Error("Invalid OGG magic string: " + buffer.toString("utf8", buffer._index, buffer._index + 4));
20
+ }
21
+
22
+ const typeFlag = buffer.readUInt8(buffer._index + 5);
23
+ if (typeFlag === 1) {
24
+ return new Error("OGG continued page not supported");
25
+ }
26
+
27
+ const bitstream = buffer.readUInt32BE(buffer._index + 14);
28
+
29
+ buffer._index += 26;
30
+
31
+ const segmentCount = buffer.readUInt8(buffer._index);
32
+ if (buffer.length - buffer._index - 1 < segmentCount) {
33
+ return true;
34
+ }
35
+
36
+ const segments = [];
37
+ let size = 0;
38
+ let byte = 0;
39
+ let total = 0;
40
+ let i = 0;
41
+ for (; i < segmentCount; i++) {
42
+ byte = buffer.readUInt8(++buffer._index);
43
+ if (byte < 255) {
44
+ segments.push(size + byte);
45
+ size = 0;
46
+ } else {
47
+ size += byte;
48
+ }
49
+ total += byte;
50
+ }
51
+
52
+ ++buffer._index;
53
+
54
+ if (buffer.length - buffer._index < total) {
55
+ return true;
56
+ }
57
+
58
+ for (let segment of segments) {
59
+ buffer._index += segment;
60
+ byte = (segment = buffer.subarray(buffer._index - segment, buffer._index)).toString("utf8", 0, 8);
61
+ if (this.head) {
62
+ if (byte === "OpusTags") {
63
+ this.emit("debug", segment.toString());
64
+ } else if (bitstream === this._bitstream) {
65
+ this.push(segment);
66
+ }
67
+ } else if (byte === "OpusHead") {
68
+ this._bitstream = bitstream;
69
+ this.emit("debug", (this.head = segment.toString()));
70
+ } else {
71
+ this.emit("debug", "Invalid codec: " + byte);
72
+ }
73
+ }
74
+ }
75
+
76
+ _final(cb) {
77
+ if (!this._bitstream) {
78
+ this.emit("error", new Error("No Opus stream was found"));
79
+ }
80
+ cb();
81
+ }
82
+
83
+ _transform(chunk, enc, cb) {
84
+ if (this._remainder) {
85
+ chunk = Buffer.concat([this._remainder, chunk]);
86
+ this._remainder = null;
87
+ }
88
+
89
+ chunk._index = 0;
90
+
91
+ while (chunk._index < chunk.length) {
92
+ const offset = chunk._index;
93
+ const ret = this.process(chunk);
94
+ if (ret) {
95
+ this._remainder = chunk.subarray(offset);
96
+ if (ret instanceof Error) {
97
+ this.emit("error", ret);
98
+ }
99
+ cb();
100
+ return;
101
+ }
102
+ }
103
+
104
+ this.setTransformCB(cb);
105
+ }
106
+ }
107
+
108
+ module.exports = OggOpusTransformer;
@@ -1,61 +1,61 @@
1
- "use strict";
2
-
3
- const BaseTransformer = require("./BaseTransformer");
4
-
5
- class PCMOpusTransformer extends BaseTransformer {
6
- constructor(options = {}) {
7
- super(options);
8
-
9
- this.opus = options.opusFactory();
10
- this.frameSize = options.frameSize || 2880;
11
- this.pcmSize = options.pcmSize || 11520;
12
-
13
- this._remainder = null;
14
- }
15
-
16
- _destroy(...args) {
17
- if (this.opus.delete) {
18
- this.opus.delete();
19
- }
20
-
21
- return super._destroy(...args);
22
- }
23
-
24
- _flush(cb) {
25
- if (this._remainder) {
26
- const buf = Buffer.allocUnsafe(this.pcmSize);
27
- this._remainder.copy(buf);
28
- buf.fill(0, this._remainder.length);
29
- this.push(this.opus.encode(buf, this.frameSize));
30
- this._remainder = null;
31
- }
32
- cb();
33
- }
34
-
35
- _transform(chunk, enc, cb) {
36
- if (this._remainder) {
37
- chunk = Buffer.concat([this._remainder, chunk]);
38
- this._remainder = null;
39
- }
40
-
41
- if (chunk.length < this.pcmSize) {
42
- this._remainder = chunk;
43
- return cb();
44
- }
45
-
46
- chunk._index = 0;
47
-
48
- while (chunk._index + this.pcmSize < chunk.length) {
49
- chunk._index += this.pcmSize;
50
- this.push(this.opus.encode(chunk.subarray(chunk._index - this.pcmSize, chunk._index), this.frameSize));
51
- }
52
-
53
- if (chunk._index < chunk.length) {
54
- this._remainder = chunk.subarray(chunk._index);
55
- }
56
-
57
- this.setTransformCB(cb);
58
- }
59
- }
60
-
61
- module.exports = PCMOpusTransformer;
1
+ "use strict";
2
+
3
+ const BaseTransformer = require("./BaseTransformer");
4
+
5
+ class PCMOpusTransformer extends BaseTransformer {
6
+ constructor(options = {}) {
7
+ super(options);
8
+
9
+ this.opus = options.opusFactory();
10
+ this.frameSize = options.frameSize || 2880;
11
+ this.pcmSize = options.pcmSize || 11520;
12
+
13
+ this._remainder = null;
14
+ }
15
+
16
+ _destroy(...args) {
17
+ if (this.opus.delete) {
18
+ this.opus.delete();
19
+ }
20
+
21
+ return super._destroy(...args);
22
+ }
23
+
24
+ _flush(cb) {
25
+ if (this._remainder) {
26
+ const buf = Buffer.allocUnsafe(this.pcmSize);
27
+ this._remainder.copy(buf);
28
+ buf.fill(0, this._remainder.length);
29
+ this.push(this.opus.encode(buf, this.frameSize));
30
+ this._remainder = null;
31
+ }
32
+ cb();
33
+ }
34
+
35
+ _transform(chunk, enc, cb) {
36
+ if (this._remainder) {
37
+ chunk = Buffer.concat([this._remainder, chunk]);
38
+ this._remainder = null;
39
+ }
40
+
41
+ if (chunk.length < this.pcmSize) {
42
+ this._remainder = chunk;
43
+ return cb();
44
+ }
45
+
46
+ chunk._index = 0;
47
+
48
+ while (chunk._index + this.pcmSize < chunk.length) {
49
+ chunk._index += this.pcmSize;
50
+ this.push(this.opus.encode(chunk.subarray(chunk._index - this.pcmSize, chunk._index), this.frameSize));
51
+ }
52
+
53
+ if (chunk._index < chunk.length) {
54
+ this._remainder = chunk.subarray(chunk._index);
55
+ }
56
+
57
+ this.setTransformCB(cb);
58
+ }
59
+ }
60
+
61
+ module.exports = PCMOpusTransformer;
@@ -1,50 +1,50 @@
1
- "use strict";
2
-
3
- const BaseTransformer = require("./BaseTransformer");
4
-
5
- class VolumeTransformer extends BaseTransformer {
6
- constructor(options = {}) {
7
- super(options);
8
-
9
- this._remainder = null;
10
- this.setVolume(1.0);
11
- }
12
-
13
- setVolume(volume) {
14
- if (isNaN(volume) || (volume = +volume) < 0) {
15
- throw new Error("Invalid volume level: " + volume);
16
- }
17
- this.volume = volume;
18
- this.db = 10 * Math.log(1 + this.volume) / 6.931471805599453;
19
- }
20
-
21
- _transform(chunk, enc, cb) {
22
- if (this._remainder) {
23
- chunk = Buffer.concat([this._remainder, chunk]);
24
- this._remainder = null;
25
- }
26
-
27
- if (chunk.length < 2) {
28
- return cb();
29
- }
30
-
31
- let buf;
32
- if (chunk.length & 1) {
33
- this._remainder = chunk.subarray(chunk.length - 1);
34
- buf = Buffer.allocUnsafe(chunk.length - 1);
35
- } else {
36
- buf = Buffer.allocUnsafe(chunk.length);
37
- }
38
-
39
- for (let i = 0, num; i < buf.length - 1; i += 2) {
40
- // Bind transformed chunk to to 16 bit
41
- num = ~~(this.db * chunk.readInt16LE(i));
42
- buf.writeInt16LE(num >= 32767 ? 32767 : num <= -32767 ? -32767 : num, i);
43
- }
44
-
45
- this.push(buf);
46
- this.setTransformCB(cb);
47
- }
48
- }
49
-
50
- module.exports = VolumeTransformer;
1
+ "use strict";
2
+
3
+ const BaseTransformer = require("./BaseTransformer");
4
+
5
+ class VolumeTransformer extends BaseTransformer {
6
+ constructor(options = {}) {
7
+ super(options);
8
+
9
+ this._remainder = null;
10
+ this.setVolume(1.0);
11
+ }
12
+
13
+ setVolume(volume) {
14
+ if (isNaN(volume) || (volume = +volume) < 0) {
15
+ throw new Error("Invalid volume level: " + volume);
16
+ }
17
+ this.volume = volume;
18
+ this.db = 10 * Math.log(1 + this.volume) / 6.931471805599453;
19
+ }
20
+
21
+ _transform(chunk, enc, cb) {
22
+ if (this._remainder) {
23
+ chunk = Buffer.concat([this._remainder, chunk]);
24
+ this._remainder = null;
25
+ }
26
+
27
+ if (chunk.length < 2) {
28
+ return cb();
29
+ }
30
+
31
+ let buf;
32
+ if (chunk.length & 1) {
33
+ this._remainder = chunk.subarray(chunk.length - 1);
34
+ buf = Buffer.allocUnsafe(chunk.length - 1);
35
+ } else {
36
+ buf = Buffer.allocUnsafe(chunk.length);
37
+ }
38
+
39
+ for (let i = 0, num; i < buf.length - 1; i += 2) {
40
+ // Bind transformed chunk to to 16 bit
41
+ num = ~~(this.db * chunk.readInt16LE(i));
42
+ buf.writeInt16LE(num >= 32767 ? 32767 : num <= -32767 ? -32767 : num, i);
43
+ }
44
+
45
+ this.push(buf);
46
+ this.setTransformCB(cb);
47
+ }
48
+ }
49
+
50
+ module.exports = VolumeTransformer;