forked from discordjs/discord.js-modules
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(RateLimits): optionally error on ratelimits
Ported from discordjs/discord.js#5659 Co-authored-by: Ven <vendicated@riseup.net> Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
- Loading branch information
1 parent
7e3e1b4
commit 989d2fc
Showing
7 changed files
with
136 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { RateLimitData } from '../REST'; | ||
|
||
export class RateLimitError extends Error implements RateLimitData { | ||
public timeToReset: number; | ||
public limit: number; | ||
public method: string; | ||
public hash: string; | ||
public url: string; | ||
public route: string; | ||
public majorParameter: string; | ||
public global: boolean; | ||
public constructor({ timeToReset, limit, method, hash, url, route, majorParameter, global }: RateLimitData) { | ||
super(); | ||
this.timeToReset = timeToReset; | ||
this.limit = limit; | ||
this.method = method; | ||
this.hash = hash; | ||
this.url = url; | ||
this.route = route; | ||
this.majorParameter = majorParameter; | ||
this.global = global; | ||
} | ||
|
||
/** | ||
* The name of the error | ||
*/ | ||
public get name(): string { | ||
return `${RateLimitError.name}[${this.route}]`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters