@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
package/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016-2021 abalabahaha
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016-2021 abalabahaha
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,80 +1,109 @@
1
- Eris [![NPM version](https://img.shields.io/npm/v/@zygout/eris.svg?style=flat-square&color=informational)](https://npmjs.com/package/@zygout/eris)
2
- ====
3
-
4
- A Node.js wrapper for interfacing with Discord.
5
-
6
- This is a maintained fork of [Eris](https://github.com/abalabahaha/eris), which has had no release since 0.18.0 in September 2024. It keeps the Eris API and follows the current Discord API: voice with end-to-end encryption (DAVE), Components V2, modals with labels, polls, soundboard, monetization, lobbies and more.
7
-
8
- Installing
9
- ----------
10
-
11
- You will need Node.js 10.4+. Refer to [the Getting Started section of the Eris docs](https://abal.moe/Eris/docs) for more details.
12
-
13
- ```
14
- npm install eris@npm:@zygout/eris
15
- ```
16
-
17
- This installs the package under the name `eris`, so `require("eris")`, the examples and code written for Eris work as is. To use its own name instead, run `npm install @zygout/eris` and `require("@zygout/eris")`.
18
-
19
- This also installs the optional packages used for voice. If you don't need voice support, leave them out with `--omit=optional` (`--no-optional` on npm 6 and older).
20
-
21
- Voice support relies on:
22
-
23
- - `@snazzah/davey`, for end-to-end encryption (the DAVE protocol). Discord requires it for voice calls: without it, Discord refuses the connection with close code `4017`.
24
- - `@stablelib/xchacha20poly1305`, for transport encryption when AES-256-GCM is not available in your Node.js build. `sodium-native` works too.
25
- - `opusscript`, to encode audio to Opus. `@discordjs/opus` is faster and is used instead when it is installed.
26
- - [FFmpeg](https://ffmpeg.org) on your `PATH`, to play files that are not already Opus in an Ogg, WebM or DCA container.
27
-
28
- Ping Pong Example
29
- -----------------
30
-
31
- ```js
32
- const Eris = require("eris");
33
-
34
- // Replace TOKEN with your bot account's token
35
- const bot = new Eris("Bot TOKEN", {
36
- intents: [
37
- "guilds",
38
- "guildMessages",
39
- "directMessages",
40
- "messageContent" // Privileged: enable "Message Content Intent" on your application's Bot page first
41
- ]
42
- });
43
-
44
- bot.on("ready", () => { // When the bot is ready
45
- console.log("Ready!"); // Log "Ready!"
46
- });
47
-
48
- bot.on("error", (err) => {
49
- console.error(err); // or your preferred logger
50
- });
51
-
52
- bot.on("messageCreate", (msg) => { // When a message is created
53
- if(msg.content === "!ping") { // If the message content is "!ping"
54
- bot.createMessage(msg.channel.id, "Pong!");
55
- // Send a message in the same channel with "Pong!"
56
- } else if(msg.content === "!pong") { // Otherwise, if the message is "!pong"
57
- bot.createMessage(msg.channel.id, "Ping!");
58
- // Respond with "Ping!"
59
- }
60
- });
61
-
62
- bot.connect(); // Get the bot to connect to Discord
63
- ```
64
-
65
- Without the `messageContent` intent, `msg.content` is empty, except in DMs and in messages that mention your bot. Slash commands don't need it: see [applicationCommands.js](examples/applicationCommands.js).
66
-
67
- More examples can be found in [the examples folder](examples), including messages made of Components V2 and modals in [componentsV2.js](examples/componentsV2.js).
68
-
69
- Useful Links
70
- ------------
71
-
72
- - [The Eris website](https://abal.moe/Eris/) documents Eris 0.18. What this fork adds is documented in the JSDoc comments of `lib/` and in `index.d.ts`.
73
- - [The GitHub repo](https://github.com/ZyGout/eris) is where this fork is developed. Report bugs and ask questions in its issues.
74
- - [The npm package webpage](https://npmjs.com/package/@zygout/eris) is the webpage for the npm package.
75
- - [The original Eris repo](https://github.com/abalabahaha/eris) is where Eris was developed up to 0.18.0.
76
-
77
- License
78
- -------
79
-
80
- Refer to the [LICENSE](LICENSE) file.
1
+ Eris [![NPM version](https://img.shields.io/npm/v/@zygout/eris.svg?style=flat-square&color=informational)](https://npmjs.com/package/@zygout/eris)
2
+ ====
3
+
4
+ A Node.js wrapper for interfacing with Discord.
5
+
6
+ This is a maintained fork of [Eris](https://github.com/abalabahaha/eris). Eris has had no release since 0.18.0 in September 2024, and its pull requests are no longer merged. This fork keeps it up to date with the Discord API, keeps its API and style, and publishes new versions to npm as [`@zygout/eris`](https://npmjs.com/package/@zygout/eris).
7
+
8
+ About this fork
9
+ ---------------
10
+
11
+ - **Kept up to date.** What Discord adds or changes in its API (endpoints, gateway events, components, voice) is added here, and bugs are fixed as they are reported. Each version is published to npm and listed with its changes on [the releases page](https://github.com/ZyGout/eris/releases).
12
+ - **The Eris API.** Classes, methods, events and options keep their Eris names. New features follow the same style: structure classes with camelCase properties, `Collection`s, JSDoc and typings. Most bots move over by only changing the dependency.
13
+ - **Versions.** Versions follow [semver](https://semver.org), starting from 0.19.0. While the version starts with 0, a minor release (0.19 to 0.20) can contain breaking changes, listed in its release notes. A patch release (0.19.0 to 0.19.1) never does.
14
+ - **Contributing.** Report bugs and ask for features in [the issues](https://github.com/ZyGout/eris/issues). Pull requests target the `dev` branch: see [CONTRIBUTING.md](CONTRIBUTING.md).
15
+
16
+ ### Since Eris 0.18.0
17
+
18
+ - Voice works again: voice gateway v8, the encryption modes Discord now requires, and DAVE end-to-end encryption, which Discord requires for every call.
19
+ - Messages made of Components V2, and modals with labels, text displays, file uploads, radio groups and checkboxes.
20
+ - Monetization: entitlements, SKUs, subscriptions and premium buttons.
21
+ - Lobbies, user-installable apps (`contexts`, `integrationTypes`), entry point commands, activity instances, message search, guild tags, nameplates, gradient role colors, and the other fields Discord now sends.
22
+ - Fixes, such as command localizations and `defaultMemberPermissions` that never reached Discord, reaction buttons in DMs, and requests and logins that retried forever.
23
+
24
+ ### Moving from Eris 0.18
25
+
26
+ Install the fork under the `eris` name (see [Installing](#installing)), then check these changes. Some come from work merged into Eris after 0.18.0 and never released:
27
+
28
+ - `createGuild`, `createGuildFromTemplate`, `deleteGuild`, `editGuildMFALevel`, `Guild#delete`, `Guild#editMFALevel` and `GuildTemplate#createGuild` are removed, since Discord no longer lets bots use them.
29
+ - The auto moderation methods (`createAutoModerationRule`, `editAutoModerationRule`, `getAutoModerationRule` and `getAutoModerationRules`) give `AutoModerationRule` objects with camelCase properties, such as `triggerType`, instead of the raw objects from Discord. The `autoModerationRule*` events give `AutoModerationRule` objects too, and `autoModerationRuleUpdate` now passes `(guild, rule, oldRule)` instead of `(guild, oldRule, newRule)`.
30
+ - `VoiceConnection#sendBuffer` and `sendNonce` are removed (`sendHeader` replaces them), and `VoiceConnection#modes` is an array.
31
+ - Voice no longer uses `tweetnacl`. It encrypts with Node's `crypto`, or with `sodium-native` or `@stablelib/xchacha20poly1305`.
32
+ - `Constants.GuildFeatures` no longer lists the features Discord retired, such as `COMMERCE` and `PRIVATE_THREADS`.
33
+ - In TypeScript, the rows of `ModalSubmitInteraction#data.components` can also be labels and text displays. Check a row's `type` before reading its `components`.
34
+
35
+ Some names were renamed but still work, marked as deprecated: `Constants.ComponentTypes.SELECT_MENU` (now `STRING_SELECT`, next to the new user, role, mentionable and channel selects), `Constants.ActivityTypes.GAME` (now `PLAYING`), and the TypeScript types `SelectMenuOptions`, `CreateAutoModerationRuleOptions` and `EditAutoModerationRuleOptions`.
36
+
37
+ Installing
38
+ ----------
39
+
40
+ You will need Node.js 10.4+. Refer to [the Getting Started section of the Eris docs](https://abal.moe/Eris/docs) for more details.
41
+
42
+ ```
43
+ npm install eris@npm:@zygout/eris
44
+ ```
45
+
46
+ This installs the package under the name `eris`, so `require("eris")`, the examples and code written for Eris work as is. To use its own name instead, run `npm install @zygout/eris` and `require("@zygout/eris")`.
47
+
48
+ This also installs the optional packages used for voice. If you don't need voice support, leave them out with `--omit=optional` (`--no-optional` on npm 6 and older).
49
+
50
+ Voice support relies on:
51
+
52
+ - `@snazzah/davey`, for end-to-end encryption (the DAVE protocol). Discord requires it for voice calls: without it, Discord refuses the connection with close code `4017`.
53
+ - `@stablelib/xchacha20poly1305`, for transport encryption when AES-256-GCM is not available in your Node.js build. `sodium-native` works too.
54
+ - `opusscript`, to encode audio to Opus. `@discordjs/opus` is faster and is used instead when it is installed.
55
+ - [FFmpeg](https://ffmpeg.org) on your `PATH`, to play files that are not already Opus in an Ogg, WebM or DCA container.
56
+
57
+ Ping Pong Example
58
+ -----------------
59
+
60
+ ```js
61
+ const Eris = require("eris");
62
+
63
+ // Replace TOKEN with your bot account's token
64
+ const bot = new Eris("Bot TOKEN", {
65
+ intents: [
66
+ "guilds",
67
+ "guildMessages",
68
+ "directMessages",
69
+ "messageContent" // Privileged: enable "Message Content Intent" on your application's Bot page first
70
+ ]
71
+ });
72
+
73
+ bot.on("ready", () => { // When the bot is ready
74
+ console.log("Ready!"); // Log "Ready!"
75
+ });
76
+
77
+ bot.on("error", (err) => {
78
+ console.error(err); // or your preferred logger
79
+ });
80
+
81
+ bot.on("messageCreate", (msg) => { // When a message is created
82
+ if(msg.content === "!ping") { // If the message content is "!ping"
83
+ bot.createMessage(msg.channel.id, "Pong!");
84
+ // Send a message in the same channel with "Pong!"
85
+ } else if(msg.content === "!pong") { // Otherwise, if the message is "!pong"
86
+ bot.createMessage(msg.channel.id, "Ping!");
87
+ // Respond with "Ping!"
88
+ }
89
+ });
90
+
91
+ bot.connect(); // Get the bot to connect to Discord
92
+ ```
93
+
94
+ Without the `messageContent` intent, `msg.content` is empty, except in DMs and in messages that mention your bot. Slash commands don't need it: see [applicationCommands.js](examples/applicationCommands.js).
95
+
96
+ More examples can be found in [the examples folder](examples), including messages made of Components V2 and modals in [componentsV2.js](examples/componentsV2.js).
97
+
98
+ Useful Links
99
+ ------------
100
+
101
+ - [The Eris website](https://abal.moe/Eris/) documents Eris 0.18. What this fork adds is documented in the JSDoc comments of `lib/` and in `index.d.ts`.
102
+ - [The GitHub repo](https://github.com/ZyGout/eris) is where this fork is developed. Report bugs and ask questions in its issues.
103
+ - [The npm package webpage](https://npmjs.com/package/@zygout/eris) is the webpage for the npm package.
104
+ - [The original Eris repo](https://github.com/abalabahaha/eris) is where Eris was developed up to 0.18.0.
105
+
106
+ License
107
+ -------
108
+
109
+ Refer to the [LICENSE](LICENSE) file.
package/esm.mjs CHANGED
@@ -1,72 +1,72 @@
1
- import Eris from "./index.js";
2
-
3
- export default function (token, options) {
4
- return new Eris.Client(token, options);
5
- }
6
-
7
- export const {
8
- AutoModerationRule,
9
- ApplicationCommand,
10
- AutocompleteInteraction,
11
- Base,
12
- Bucket,
13
- CategoryChannel,
14
- Channel,
15
- Client,
16
- Collection,
17
- Command,
18
- CommandClient,
19
- CommandInteraction,
20
- ComponentInteraction,
21
- Constants,
22
- DiscordHTTPError,
23
- DiscordRESTError,
24
- DMChannel,
25
- Entitlement,
26
- ExtendedUser,
27
- ForumChannel,
28
- GroupChannel,
29
- Guild,
30
- GuildChannel,
31
- GuildIntegration,
32
- GuildPreview,
33
- GuildScheduledEvent,
34
- GuildTemplate,
35
- Interaction,
36
- Invite,
37
- Lobby,
38
- LobbyMember,
39
- MediaChannel,
40
- Member,
41
- Message,
42
- ModalSubmitInteraction,
43
- NewsChannel,
44
- NewsThreadChannel,
45
- Permission,
46
- PermissionOverwrite,
47
- PingInteraction,
48
- PrivateChannel,
49
- PrivateThreadChannel,
50
- PublicThreadChannel,
51
- RequestHandler,
52
- Role,
53
- SequentialBucket,
54
- Shard,
55
- SharedStream,
56
- SKU,
57
- SoundboardSound,
58
- StageChannel,
59
- StageInstance,
60
- Subscription,
61
- TextChannel,
62
- ThreadChannel,
63
- ThreadMember,
64
- UnavailableGuild,
65
- UnknownInteraction,
66
- User,
67
- VERSION,
68
- VoiceChannel,
69
- VoiceConnection,
70
- VoiceConnectionManager,
71
- VoiceState,
72
- } = Eris;
1
+ import Eris from "./index.js";
2
+
3
+ export default function (token, options) {
4
+ return new Eris.Client(token, options);
5
+ }
6
+
7
+ export const {
8
+ AutoModerationRule,
9
+ ApplicationCommand,
10
+ AutocompleteInteraction,
11
+ Base,
12
+ Bucket,
13
+ CategoryChannel,
14
+ Channel,
15
+ Client,
16
+ Collection,
17
+ Command,
18
+ CommandClient,
19
+ CommandInteraction,
20
+ ComponentInteraction,
21
+ Constants,
22
+ DiscordHTTPError,
23
+ DiscordRESTError,
24
+ DMChannel,
25
+ Entitlement,
26
+ ExtendedUser,
27
+ ForumChannel,
28
+ GroupChannel,
29
+ Guild,
30
+ GuildChannel,
31
+ GuildIntegration,
32
+ GuildPreview,
33
+ GuildScheduledEvent,
34
+ GuildTemplate,
35
+ Interaction,
36
+ Invite,
37
+ Lobby,
38
+ LobbyMember,
39
+ MediaChannel,
40
+ Member,
41
+ Message,
42
+ ModalSubmitInteraction,
43
+ NewsChannel,
44
+ NewsThreadChannel,
45
+ Permission,
46
+ PermissionOverwrite,
47
+ PingInteraction,
48
+ PrivateChannel,
49
+ PrivateThreadChannel,
50
+ PublicThreadChannel,
51
+ RequestHandler,
52
+ Role,
53
+ SequentialBucket,
54
+ Shard,
55
+ SharedStream,
56
+ SKU,
57
+ SoundboardSound,
58
+ StageChannel,
59
+ StageInstance,
60
+ Subscription,
61
+ TextChannel,
62
+ ThreadChannel,
63
+ ThreadMember,
64
+ UnavailableGuild,
65
+ UnknownInteraction,
66
+ User,
67
+ VERSION,
68
+ VoiceChannel,
69
+ VoiceConnection,
70
+ VoiceConnectionManager,
71
+ VoiceState,
72
+ } = Eris;