honocord 2.0.1 → 2.1.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/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Honocord - Imagine an interactions bot
2
2
 
3
+ > [!IMPORTANT]
4
+ > No, this ain't abandoned - I'm just busy with other projects and life stuff. I you want something added or want to help out, open an issue or PR and I'll try to get to it when I can. Thanks for understanding!
5
+
3
6
  Honocord is a powerful, type-safe library for building Discord bots using interactions with the Hono web framework.
4
7
 
5
8
  ## What is Honocord?
@@ -37,5 +40,50 @@ If you encounter issues or have questions:
37
40
 
38
41
  Browse the [Examples](https://github.com/The-LukeZ/honocord-examples) repo for complete, working implementations:
39
42
 
40
- - **cloudflare-workers** - Basic bot on Cloudflare Workers
43
+ - **cloudflare-workers** - Bot on Cloudflare Workers with Caching
41
44
  - **custom-hono-integration** - Integration with existing Hono apps (with Bun)
45
+ - **webhook-events** - Handling Discord webhook events alongside interactions
46
+ - **caching-mongo** - Example of a simple MongoDB cache adapter implementation
47
+
48
+ ## Testing
49
+
50
+ Tests are located in `src/tests/` and follow the directory structure of the modules they test:
51
+
52
+ ```tree
53
+ src/
54
+ ├── tests/
55
+ │ ├── interactions/
56
+ │ │ └── BaseInteraction.test.ts
57
+ │ └── utils/
58
+ │ └── Autocomplete.test.ts
59
+ ├── interactions/
60
+ ├── utils/
61
+ └── ...
62
+ ```
63
+
64
+ Run tests with:
65
+
66
+ ```bash
67
+ pnpm test # Run all tests
68
+ pnpm test --watch # Run in watch mode
69
+ ```
70
+
71
+ Tests use [Vitest](https://vitest.dev/) for fast unit testing with TypeScript support.
72
+
73
+ ## Contributing
74
+
75
+ The repository is organized as a monorepo with the following structure:
76
+
77
+ - **`src/`** - Core Honocord library
78
+ - **`packages/`** - Optional cache adapters (`cache-base`, `cache-memory`, `cache-do`, `cache-mongo`)
79
+ - **`docs/`** - Documentation site (Astro)
80
+
81
+ ### Building
82
+
83
+ ```bash
84
+ pnpm build # Build the root package
85
+ pnpm build:all # Build root and all cache packages
86
+ pnpm typecheck # Type check the root package
87
+ ```
88
+
89
+ All packages use [tsdown](https://tsdown.dev/) for zero-config builds.
package/dist/index.cjs CHANGED
@@ -933,6 +933,16 @@ var ModalComponentResolver = class {
933
933
  }
934
934
  return mentionables.length > 0 ? mentionables : required ? [] : null;
935
935
  }
936
+ getFiles(custom_id, required) {
937
+ const component = this.getComponent(custom_id);
938
+ if (component.type !== discord_api_types_v10.ComponentType.FileUpload) throw new TypeError("Component is not a file upload", { cause: {
939
+ custom_id,
940
+ type: component.type
941
+ } });
942
+ const attachments = component.values.map((id) => this._resolved.attachments?.get(id)).filter(Boolean);
943
+ if (attachments.length === 0) return required ? new _discordjs_collection.Collection() : null;
944
+ return new _discordjs_collection.Collection(attachments.map((attachment) => [attachment.id, attachment]));
945
+ }
936
946
  getRadioGroupValue(custom_id, required) {
937
947
  const component = this.getComponent(custom_id);
938
948
  if (component.type !== discord_api_types_v10.ComponentType.RadioGroup) throw new TypeError("Component is not a radio group", { cause: {