honocord 2.0.0 → 2.1.0

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: {
@@ -1639,10 +1649,10 @@ var CacheManager = class {
1639
1649
  await this.users.set(i.member.user);
1640
1650
  await this.members.set(i.guild_id, i.member);
1641
1651
  }
1642
- if (i.channel && i.channel.type !== discord_api_types_v10.ChannelType.DM && i.channel.type !== discord_api_types_v10.ChannelType.GroupDM) await this.channels.set(i.channel);
1652
+ if (i.channel) await this.channels.set(i.channel);
1643
1653
  }
1644
1654
  async populateMessageComponent(i) {
1645
- if (i.channel && i.channel.type !== discord_api_types_v10.ChannelType.DM && i.channel.type !== discord_api_types_v10.ChannelType.GroupDM) await this.channels.set(i.channel);
1655
+ if (i.channel) await this.channels.set(i.channel);
1646
1656
  if (i.user) await this.users.set(i.user);
1647
1657
  if (i.member && i.guild_id) {
1648
1658
  await this.users.set(i.member.user);
@@ -2114,6 +2124,7 @@ Object.defineProperty(exports, 'ButtonStyle', {
2114
2124
  return discord_api_types_v10.ButtonStyle;
2115
2125
  }
2116
2126
  });
2127
+ exports.CacheManager = CacheManager;
2117
2128
  Object.defineProperty(exports, 'ChannelSelectMenuBuilder', {
2118
2129
  enumerable: true,
2119
2130
  get: function () {
@@ -2156,6 +2167,7 @@ Object.defineProperty(exports, 'EmbedBuilder', {
2156
2167
  return _discordjs_builders.EmbedBuilder;
2157
2168
  }
2158
2169
  });
2170
+ exports.Fetcher = Fetcher;
2159
2171
  Object.defineProperty(exports, 'FileBuilder', {
2160
2172
  enumerable: true,
2161
2173
  get: function () {