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.

About c.rest

If you’re using createRest(), please replace it accordingly.

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.

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.

Support

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