diff options
Diffstat (limited to 'src/discord/responses.ts')
| -rw-r--r-- | src/discord/responses.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/discord/responses.ts b/src/discord/responses.ts new file mode 100644 index 0000000..da72967 --- /dev/null +++ b/src/discord/responses.ts @@ -0,0 +1,15 @@ +import type { DiscordResponse } from './interfaces.ts'; + +export class JSONResponse extends Response { + constructor(body: DiscordResponse | { error: string }, init?: ResponseInit) { + const jsonBody = JSON.stringify(body); + + init = init || { + headers: { + 'content-type': 'application/json;charset=UTF-8', + }, + }; + + super(jsonBody, init); + } +} |