@sillyfrogster/eunia 0.1.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sillyfrogster
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,165 @@
1
+ # Eunia
2
+
3
+ Eunia is a TypeScript Discord library built for Bun. It keeps the core small,
4
+ lets you replace storage and other services, and includes a slash-first command
5
+ framework.
6
+
7
+ Eunia is in alpha. The public API may change before the first stable release.
8
+ Voice support is outside this release and will be handled separately.
9
+
10
+ ## Quick start
11
+
12
+ Eunia requires Bun 1.3.14 or newer.
13
+
14
+ Install Eunia:
15
+
16
+ ```sh
17
+ bun add @sillyfrogster/eunia@alpha
18
+ ```
19
+
20
+ Create a command class and start the client:
21
+
22
+ ```ts
23
+ import {
24
+ Client,
25
+ Command,
26
+ Intents,
27
+ type CommandContext,
28
+ } from "@sillyfrogster/eunia";
29
+
30
+ const token = process.env["DISCORD_TOKEN"]?.trim();
31
+ const guildId = process.env["DISCORD_GUILD_ID"]?.trim();
32
+ if (!token || token === "paste-your-token-here") {
33
+ throw new Error("Set DISCORD_TOKEN before starting Eunia.");
34
+ }
35
+ if (!guildId || !/^\d{17,20}$/.test(guildId)) {
36
+ throw new Error("Set DISCORD_GUILD_ID to a development guild ID.");
37
+ }
38
+
39
+ class PingCommand extends Command {
40
+ name = "ping";
41
+ description = "Check whether the bot is ready";
42
+ kind = "slash" as const;
43
+ rateLimit = { limit: 2, windowMs: 5_000, scope: "user" as const };
44
+
45
+ async run(context: CommandContext): Promise<void> {
46
+ await context.reply("Pong!");
47
+ }
48
+ }
49
+
50
+ const client = new Client({
51
+ token,
52
+ intents: [Intents.Guilds],
53
+ commands: {
54
+ commands: [new PingCommand()],
55
+ publishOnStart: {
56
+ scope: "guild",
57
+ guildId,
58
+ },
59
+ },
60
+ });
61
+
62
+ client.on("ready", (user) => {
63
+ console.log(`Ready as ${user.tag}`);
64
+ });
65
+
66
+ await client.start();
67
+ ```
68
+
69
+ `publishOnStart` uses Discord's bulk overwrite route and replaces every command
70
+ in the target guild. Use it for a development guild. For production, call
71
+ `client.commands.publish()` as part of a release step so restarts do not
72
+ publish the same commands again. A separate publishing process can set
73
+ `applicationId` in `ClientOptions` and publish without connecting the gateway.
74
+
75
+ ## What is included
76
+
77
+ - A resumable, compressed, multi-shard gateway client.
78
+ - REST rate-limit buckets, global limits, bounded bucket retention, bounded
79
+ retries, multipart uploads, and typed errors.
80
+ - Bounded memory caching with optional Redis, Valkey, or custom adapters.
81
+ - Snapshot-based users, guilds, channels, messages, members, roles, and
82
+ interactions with common methods.
83
+ - Declarative command classes, groups, subcommands, typed option fields,
84
+ command-scoped component listeners, autocomplete, guards, middleware,
85
+ permissions, cooldowns, and automatic deferral.
86
+ - Optional message prefixes that use the same command classes as slash
87
+ commands.
88
+ - Ordered modules, shared services, and custom cache namespaces for third-party
89
+ extensions.
90
+ - Raw gateway events for features that do not have a typed event yet.
91
+
92
+ See the [coverage guide](docs/coverage.md) for the current release boundary.
93
+
94
+ ## Configuration
95
+
96
+ Memory caching is the default:
97
+
98
+ ```ts
99
+ const client = new Client({
100
+ token,
101
+ intents: Intents.Guilds,
102
+ cache: { adapter: { driver: "memory" } },
103
+ });
104
+ ```
105
+
106
+ Redis and Valkey use Bun's built-in Redis client:
107
+
108
+ ```ts
109
+ const client = new Client({
110
+ token,
111
+ intents: Intents.Guilds,
112
+ cache: {
113
+ adapter: {
114
+ driver: "valkey",
115
+ url: "redis://localhost:6379",
116
+ prefix: "my-bot",
117
+ },
118
+ policies: {
119
+ messages: { maxSize: 2_000, ttl: 10 * 60_000 },
120
+ },
121
+ },
122
+ });
123
+ ```
124
+
125
+ Pass a `CacheAdapter` to use another store. Eunia always keeps a bounded hot
126
+ memory layer, so structure relations stay synchronous.
127
+
128
+ ## Modules
129
+
130
+ | Module | Purpose |
131
+ | --- | --- |
132
+ | Client | Event routing, domain accessors, modules, and public re-exports |
133
+ | Commands | Slash-first command framework with optional prefixes |
134
+ | Structures | Discord structures, Sendable normalization, and helpers |
135
+ | Cache | Bounded memory, Redis, Valkey, and custom cache adapters |
136
+ | Gateway | WebSocket sessions, heartbeats, resume, and sharding |
137
+ | REST | HTTP transport, rate limits, retries, uploads, and route binding |
138
+ | Helpers | Opt-in embed, component, and modal content templates |
139
+ | Shared | Logger interfaces and shared runtime utilities |
140
+ | Types | Discord API payloads, enums, and shared protocol types |
141
+
142
+ Eunia ships as one npm package. Its internal workspaces keep the codebase
143
+ modular without requiring users to install several packages.
144
+
145
+ ## Guides
146
+
147
+ - [Commands](docs/commands.md)
148
+ - [Caching](docs/cache.md)
149
+ - [Modules](docs/modules.md)
150
+ - [Coverage](docs/coverage.md)
151
+
152
+ ## Work on Eunia
153
+
154
+ ```sh
155
+ bun install
156
+ bun run check
157
+ bun run coverage
158
+ ```
159
+
160
+ Tests use local fakes and a local gateway. They do not need a Discord token.
161
+ Copy `.env.example` to `.env` only when you want to run a bot against Discord.
162
+
163
+ ## License
164
+
165
+ Eunia is available under the [MIT License](LICENSE).