✨ add `right` option to route()

This commit is contained in:
Flam3rboy
2021-10-03 01:55:57 +02:00
parent 62f727783d
commit 7268779dc3
6 changed files with 31 additions and 5 deletions
-1
View File
@@ -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);
}
+3 -1
View File
@@ -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:
+4 -1
View File
@@ -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))
+1
View File
@@ -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";