diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-03 01:55:57 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-03 01:55:57 +0200 |
commit | 7268779dc3e9a428d3a95012ca4ba5e1e3d0ca7a (patch) | |
tree | 9e6f0ce883e13f6320f45abd68955498f8dc2c7c /util/src | |
parent | :sparkles: User instance rights (diff) | |
download | server-7268779dc3e9a428d3a95012ca4ba5e1e3d0ca7a.tar.xz |
:sparkles: add ``right`` option to route()
Diffstat (limited to 'util/src')
-rw-r--r-- | util/src/util/BitField.ts | 1 | ||||
-rw-r--r-- | util/src/util/Constants.ts | 4 | ||||
-rw-r--r-- | util/src/util/Token.ts | 5 | ||||
-rw-r--r-- | util/src/util/index.ts | 1 |
4 files changed, 8 insertions, 3 deletions
diff --git a/util/src/util/BitField.ts b/util/src/util/BitField.ts index 986077ba..fb887e05 100644 --- a/util/src/util/BitField.ts +++ b/util/src/util/BitField.ts @@ -143,6 +143,5 @@ export class BitField { } export function BitFlag(x: bigint | number) { - if (!x) throw new Error("You need to pass a bitflag"); return BigInt(1) << BigInt(x); } diff --git a/util/src/util/Constants.ts b/util/src/util/Constants.ts index d2cc5130..5fdf5bc0 100644 --- a/util/src/util/Constants.ts +++ b/util/src/util/Constants.ts @@ -726,7 +726,9 @@ export const DiscordApiErrors = { /** * An error encountered while performing an API request (Fosscord only). Here are the potential errors: */ -export const FosscordApiErrors = {}; +export const FosscordApiErrors = { + MISSING_RIGHTS: new ApiError("You lack rights to perform that action ({})", 50013, undefined, [""]), +}; /** * The value set for a guild's default message notifications, e.g. `ALL`. Here are the available types: diff --git a/util/src/util/Token.ts b/util/src/util/Token.ts index 111d59a2..7c4cc61d 100644 --- a/util/src/util/Token.ts +++ b/util/src/util/Token.ts @@ -10,7 +10,10 @@ export function checkToken(token: string, jwtSecret: string): Promise<any> { jwt.verify(token, jwtSecret, JWTOptions, async (err, decoded: any) => { if (err || !decoded) return rej("Invalid Token"); - const user = await User.findOne({ id: decoded.id }, { select: ["data", "bot", "disabled", "deleted"] }); + const user = await User.findOne( + { id: decoded.id }, + { select: ["data", "bot", "disabled", "deleted", "rights"] } + ); if (!user) return rej("Invalid Token"); // we need to round it to seconds as it saved as seconds in jwt iat and valid_tokens_since is stored in milliseconds if (decoded.iat * 1000 < new Date(user.data.valid_tokens_since).setSeconds(0, 0)) diff --git a/util/src/util/index.ts b/util/src/util/index.ts index d73bf4ca..9c51d3b8 100644 --- a/util/src/util/index.ts +++ b/util/src/util/index.ts @@ -12,6 +12,7 @@ export * from "./MessageFlags"; export * from "./Permissions"; export * from "./RabbitMQ"; export * from "./Regex"; +export * from "./Rights"; export * from "./Snowflake"; export * from "./String"; export * from "./Array"; |