3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25: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

@ -1,7 +1,13 @@
import { isValidSnowflake } from "../utils";
/**
* @return Unix timestamp in milliseconds
*/
export function snowflakeToTimestamp(snowflake: string) {
if (!isValidSnowflake(snowflake)) {
throw new Error(`Invalid snowflake: ${snowflake}`);
}
// https://discord.com/developers/docs/reference#snowflakes-snowflake-id-format-structure-left-to-right
return Number(BigInt(snowflake) >> 22n) + 1420070400000;
return Number(BigInt(snowflake) >> 22n) + 1_420_070_400_000;
}