If you build Discord bots, you keep hitting the same small questions:
- When was this account or server created?
- What permissions are hiding in
274878286912? - Which integer do I pass for these three intents?
- Why does the gateway close my connection with
4014?
The usual answers are a random web calculator, a REPL with a bitshift you half remember, or a scroll through the docs. I wanted one command for each of them, so I built dkit.
What it does
$ dkit snowflake 175928847299117063
175928847299117063
Created 2016-04-30T11:18:25.796Z
Unix ms 1462015105796
Discord ms 41944705796
Worker ID 1
Process ID 0
Increment 7
Permissions work in both directions:
$ dkit perms --names SEND_MESSAGES,MANAGE_ROLES
Permissions 268437504
hex 0x0000000010000800
SEND_MESSAGES 0x0000000000000800 [T/V/S]
MANAGE_ROLES 0x0000000010000000 [2FA, T/V/S]
Intents come with a warning about privileged ones, which is the classic reason a bot suddenly sees empty message content:
$ dkit intents GUILDS,GUILD_MESSAGES,MESSAGE_CONTENT
Intents 33281
hex 0x8201 (3 of 21 known intents)
GUILDS 1 << 0 21 events
GUILD_MESSAGES 1 << 9 4 events
MESSAGE_CONTENT 1 << 15 no events [privileged]
Privileged intents in this value:
- MESSAGE_CONTENT
There is also dkit invite, which builds a correctly encoded OAuth2 invite URL, and --json on every command if you want to script it.
Design decisions I care about
Offline, always. dkit never makes a network request and never asks for a bot token. That means it is safe to run on a shared machine, and you can paste its output into a bug report without thinking twice.
No dependencies. Standard library only, so installing it pulls in nothing else.
Honest data. None of the Discord constants are hard-coded in the logic. They live in JSON files that record the official source URL and the date they were last checked against the docs. If a value is ever wrong, there is exactly one place to fix it.
Big numbers done right. Permission values already go beyond 32 bits. dkit uses Python's arbitrary-precision integers, and in JSON mode it emits permission values as strings, the same way the Discord API does.
What I learned shipping my first PyPI package
- The first upload of a name is the moment it becomes yours. I found out the hard way that PyPI can refuse a name even when
pip index versionssays it is free, so check early and have a second name ready. - Test on TestPyPI first, but expect the name there to be taken more often than on the real index.
- Read the long description of your own package page before you upload. It is frozen for that version.
Try it, break it
pip install dkit-cli
The command is dkit. The source is on GitHub: https://github.com/Bytewave1/dkit
I'd really like feedback, bug reports and wrong values. There are also a few issues marked "good first issue" (channel types, timestamp formatting, shell completion) if you want to contribute your first PR.
dkit is an unofficial tool and is not affiliated with or endorsed by Discord.
Top comments (0)