Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oddyamill/discord-workers
https://github.com/oddyamill/discord-workers
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/oddyamill/discord-workers
- Owner: oddyamill
- Created: 2024-04-04T11:43:36.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-04-13T12:05:28.000Z (7 months ago)
- Last Synced: 2024-04-14T02:19:40.418Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# `@oddyamill/discord-workers`
Discord 🥰 Cloudflare Workers```typescript
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!',
})
},
}
```