Skip to content

Commit 3cda59a

Browse files
update: README improvements
1 parent 1398c85 commit 3cda59a

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,56 @@
88

99
It handles various interactions and organizes them into modular routes, making your bot's code cleaner, easier to understand, and easier to maintain. It works seamlessly in both serverless and persistent server environments.
1010

11-
**Currently in development**
11+
The core is production-ready and can be used in your new http interaction bots.
12+
13+
```js
14+
import Client from "discord.https";
15+
import NodeAdapter from "@discordhttps/nodejs-adapter";
16+
import { InteractionResponseType } from "discord-api-types/v10";
17+
18+
const client = new Client({
19+
token: "YOUR BOT TOKEN",
20+
publicKey: "YOUR PUBLIC KEY",
21+
httpAdapter: new NodeAdapter(),
22+
});
23+
24+
client.commandcommand(
25+
(builder) => builder.setName("hi").setDescription("reply hello!"),
26+
async (interaction, client, _, res) => {
27+
res.writeHead(200, {
28+
"Content-Type": "application/json",
29+
});
30+
const username = interaction.user
31+
? interaction.user.global_name
32+
: interaction.member.user.global_name;
33+
res.end(
34+
JSON.stringify({
35+
type: InteractionResponseType.ChannelMessageWithSource,
36+
data: {
37+
content: `Hello! ${username}`,
38+
},
39+
})
40+
);
41+
}
42+
);
43+
44+
await client.listen("interactions", 3000, () => {
45+
console.log(
46+
"Listening for interactions on port 3000 at the /interactions endpoint"
47+
);
48+
});
49+
```
50+
51+
**You can view example/reference implementations here:**
52+
53+
- Nodejs Runtime: [https://github.com/discordhttps/nodejs-example](https://github.com/discordhttps/nodejs-example)
54+
- V8 isolates runtime(Cloudflare Workers): [https://github.com/discordhttps/cloudflare-example](https://github.com/discordhttps/cloudflare-example)
55+
56+
> Note: Utility methods such as <interaction>.editReply() and <interaction>.deferReply() are currently in development, so you won’t need to manually handle the raw response object in the future.
1257
1358
### To do:
1459

15-
- [ ] Build structures → reference: https://www.npmjs.com/package/@discordjs/structures
60+
- [ ] Build structures → reference: [discord.js - structures](https://github.com/discordjs/discord.js/tree/main/packages/discord.js/src/structures)
1661
- [ ] Build a simplified `npx create-app` command [in progress]
1762
- [ ] Implement tests
1863
- [x] HTTP adapters to support all hosting environments. Currently implemented: Node.js adapter for [Node.js runtime](https://github.com/discord-http/nodejs-adapter) and [Cloudflare adapter for V8 isolates runtime](https://github.com/discord-http/cloudflare-adapter)

0 commit comments

Comments
 (0)