1.2.1 • Published 6 months ago

@oddyamill/discord-workers v1.2.1

Weekly downloads
-
License
-
Repository
github
Last release
6 months ago

@oddyamill/discord-workers

Discord 🥰 Cloudflare Workers

import { respond, getInteraction, BotEnv } from '@oddyamill/discord-workers'
import { InteractionResponseType, InteractionType } from 'discord-api-types/v10'

export default {
  async fetch(request: Request, env: BotEnv) {
    const interaction = await getInteraction(request, env)

    if (interaction === undefined) {
      return new Response('Unauthorized', { status: 401 })
    }

    if (interaction.type === InteractionType.Ping) {
      return respond(InteractionResponseType.Pong, undefined)
    }

    return respond(InteractionResponseType.ChannelMessageWithSource, {
      content: 'Hi!',
    })
  },
}
1.2.1

6 months ago

1.2.0

11 months ago