If you have built a Discord bot you have run into numbers like 1484790591312105563, 274877975552 and 33281 and copied them from somewhere without really knowing what they mean. They are all simple once you see the format. This post goes through four of them with code you can run in a browser console.

Snowflake IDs

Every user, server, channel, message and role on Discord has an ID called a snowflake. It is a 64-bit integer, and the first 42 bits are a timestamp. That means every ID tells you exactly when the thing was created.

The layout looks like this:

Bits Field
63 to 22 Milliseconds since the Discord epoch (2015-01-01)
21 to 17 Internal worker ID
16 to 12 Internal process ID
11 to 0 Increment

The Discord epoch is 1420070400000, the first millisecond of 2015 in Unix time. To get the creation date, shift the ID right by 22 bits and add the epoch:

const DISCORD_EPOCH = 1420070400000n; function snowflakeToDate(id) { const ms = (BigInt(id) >> 22n) + DISCORD_EPOCH; return new Date(Number(ms)); } snowflakeToDate("1484790591312105563"); 

Use BigInt. A snowflake is bigger than Number.MAX_SAFE_INTEGER, so if you parse it as a normal number the last digits get rounded and you end up with a different ID. This is also why the Discord API sends IDs as strings in JSON.

This is handy for spotting new accounts in a moderation bot, or checking how old a server really is. If you just want the answer without code, the snowflake decoder on DiscordBase does the same thing.

Permission integers

Bot invite links have a permissions= parameter with a number like 274877975552. That number is a bitfield. Each permission is one bit, and you add them together with bitwise OR.

const P = { VIEW_CHANNEL: 1n << 10n, SEND_MESSAGES: 1n << 11n, MANAGE_MESSAGES: 1n << 13n, EMBED_LINKS: 1n << 14n, READ_MESSAGE_HISTORY: 1n << 16n, ADMINISTRATOR: 1n << 3n, }; const perms = P.VIEW_CHANNEL | P.SEND_MESSAGES | P.EMBED_LINKS | P.READ_MESSAGE_HISTORY; console.log(perms.toString()); // 84992 

Going the other way, you check each bit with AND:

function decode(value) { const n = BigInt(value); return Object.entries(P).filter(([, bit]) => (n & bit) === bit).map(([name]) => name); } decode("84992"); // ["VIEW_CHANNEL", "SEND_MESSAGES", "EMBED_LINKS", "READ_MESSAGE_HISTORY"] 

Some permission bits are above 31, so BigInt matters here too. JavaScript's normal bitwise operators work on 32-bit integers and will silently give you the wrong result.

The full list is in the Discord permissions docs. A small tip: ask for the permissions your bot actually uses. People are much more likely to add a bot that does not ask for ADMINISTRATOR. If you want to tick boxes instead of doing bit math, there is a Discord permissions calculator that builds the number and the invite link for you.

Gateway intents

Intents work the same way. When your bot connects to the gateway, it sends an intents number that says which events it wants.

const I = { GUILDS: 1 << 0, GUILD_MEMBERS: 1 << 1, // privileged GUILD_PRESENCES: 1 << 8, // privileged GUILD_MESSAGES: 1 << 9, GUILD_MESSAGE_REACTIONS: 1 << 10, DIRECT_MESSAGES: 1 << 12, MESSAGE_CONTENT: 1 << 15, // privileged }; const intents = I.GUILDS | I.GUILD_MESSAGES | I.MESSAGE_CONTENT; console.log(intents); // 33281 

The three privileged intents have to be turned on in the Developer Portal as well. If you send them in code without enabling them, the gateway closes the connection with code 4014. Once a bot is in 100 or more servers, you also need Discord's approval to keep using them.

The most common mistake is leaving out MESSAGE_CONTENT. Your bot still gets message events, but content is an empty string, and it looks like a bug in your code. The intents calculator marks the privileged ones so you know which toggles to flip.

Timestamp tags

Discord can show a date in each reader's own time zone. You write <t:UNIX_SECONDS:STYLE> in a message and the client formats it.

const unix = Math.floor(new Date("2026-12-01T18:00:00Z").getTime() / 1000); console.log(`<t:${unix}:F>`); // full date and time console.log(`<t:${unix}:R>`); // "in 2 weeks", updates live 

The styles are t and T (short and long time), d and D (short and long date), f and F (short and long date with time) and R (relative). The relative one is good for event countdowns. The value is in seconds, not milliseconds, which is the usual mistake when you come from Date.now(). A Discord timestamp generator gives you all the styles side by side if you would rather click than count.

Bonus: checking if an invite still works

Invites expire or get deleted, and a dead link on your README or website is easy to miss. You can check one without a bot token:

const res = await fetch("https://discord.com/api/v10/invites/CODE?with_counts=true"); if (!res.ok) { console.log("invite is dead"); // error code 10006, Unknown Invite } else { const data = await res.json(); console.log(data.guild.name, data.approximate_member_count, data.approximate_presence_count); } 

Keep the request rate low if you check many invites, since this endpoint is rate limited like the rest of the API.

Wrapping up

None of this is complicated once you know it is bits and a timestamp. I keep running into these while working on DiscordBase, a directory of Discord servers, so I put browser versions of all of them on one page of free Discord tools. And if you are looking for places to talk about code, there is a list of programming Discord servers there too.