Skip to content

REST API

There are 4 ways to use Discord’s REST API:

  1. c.rest
  2. createRest(c.env.DISCORD_TOKEN)
  3. Other libraries (such as @discordjs/rest)
  4. Implement your own using fetch()

1 and 2 behave the same way.
Since REST API is essentially separable, any implementation method is acceptable.

The REST API client provided by Discord Hono is a lightweight fetch wrapper with type safety.
Since it focuses on optimization for edge environments, complex features like automatic rate limit handling are intentionally omitted.

await c.rest('METHOD', 'PATH', ['PATH_VAR', QUERY_OBJ], DATA_OBJ, FILE_OBJ)
import { $channels$_$messages } from 'discord-hono'
await c.rest('POST', $channels$_$messages, [channel_id], {
content: 'this is rest',
})

The first argument is the Method from the official documentation.
The second argument is defined here.
For the third argument, enter the variable parts enclosed in {} within the Path as an array.
The fourth argument and subsequent arguments are the required data.

Receiving and Responding✅
Application Commands✅
Application✅
Application Role Connection Metadata✅
Audit Log✅
Auto Moderation✅
Channel✅
Emoji✅
Entitlement✅
Guild✅
Guild Scheduled Event✅
Guild Template✅
Invite✅
Messages✅
Poll✅
SKU✅
Soundboard✅
Stage Instance✅
Sticker⌛
Subscription✅
User✅
Voice✅
Webhook✅