3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-11 04:45:02 +00:00

Add !slowmode command

This commit is contained in:
Dragory 2020-08-09 17:28:21 +03:00
parent 2d8decdb4f
commit 5215dd0738
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
10 changed files with 122 additions and 2 deletions

View file

@ -58,6 +58,19 @@ export const WEEKS = 7 * 24 * HOURS;
export const EMPTY_CHAR = "\u200b";
// https://discord.com/developers/docs/reference#snowflakes
export const MIN_SNOWFLAKE = 0b000000000000000000000000000000000000000000_00001_00001_000000000001;
// 0b111111111111111111111111111111111111111111_11111_11111_111111111111 without _ which BigInt doesn't support
export const MAX_SNOWFLAKE = BigInt("0b1111111111111111111111111111111111111111111111111111111111111111");
const snowflakePattern = /^[1-9]\d+$/;
export function isValidSnowflake(str: string) {
if (!str.match(snowflakePattern)) return false;
if (parseInt(str, 10) < MIN_SNOWFLAKE) return false;
if (BigInt(str) > MAX_SNOWFLAKE) return false;
return true;
}
export const DISCORD_HTTP_ERROR_NAME = "DiscordHTTPError";
export const DISCORD_REST_ERROR_NAME = "DiscordRESTError";