Skip to content

Commit

Permalink
feat(RESTErrors): add types for rest errors (#122)
Browse files Browse the repository at this point in the history
Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
  • Loading branch information
Fyko and vladfrangu committed May 25, 2021
1 parent c4e69c9 commit 7b47fc9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
24 changes: 24 additions & 0 deletions deno/rest/v8/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,3 +683,27 @@ export const OAuth2Routes = {

// Freeze OAuth2 route object
Object.freeze(OAuth2Routes);

export interface DiscordErrorFieldInformation {
code: string;
message: string;
}

export interface DiscordErrorGroupWrapper {
_errors: DiscordError[];
}

export type DiscordErrorData =
| DiscordErrorGroupWrapper
| DiscordErrorFieldInformation
| { [k: string]: DiscordErrorData }
| string;

/**
* https://discord.com/developers/docs/reference#error-messages
*/
export interface DiscordError {
code: number;
message: string;
errors?: DiscordErrorData;
}
24 changes: 24 additions & 0 deletions rest/v8/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,3 +683,27 @@ export const OAuth2Routes = {

// Freeze OAuth2 route object
Object.freeze(OAuth2Routes);

export interface DiscordErrorFieldInformation {
code: string;
message: string;
}

export interface DiscordErrorGroupWrapper {
_errors: DiscordError[];
}

export type DiscordErrorData =
| DiscordErrorGroupWrapper
| DiscordErrorFieldInformation
| { [k: string]: DiscordErrorData }
| string;

/**
* https://discord.com/developers/docs/reference#error-messages
*/
export interface DiscordError {
code: number;
message: string;
errors?: DiscordErrorData;
}

0 comments on commit 7b47fc9

Please sign in to comment.