summaryrefslogtreecommitdiff
path: root/src/discord/responses.ts
blob: da72967469391a44323cf2854997bc5307fb2e1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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);
  }
}