Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add `dkit cdn`: build Discord CDN image URLs offline from an ID and a hash

Open
#89 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start with the image-formatting documentation at developers/reference.mdx, then inspect dkit.core.parse and core/data.py for the existing snowflake parser and dataset registration. The issue also names src/dkit/data/cdn.json, .github/workflows/ci.yml, README.md, CHANGELOG.md, and required tests. Done means the CLI builds the documented CDN URLs offline and meets the listed behavior, coverage, lint, formatting, and documentation criteria.

Written by the indexing model from the issue text.

Description

enhancement new command

Building an avatar, icon or banner URL means remembering the path of each endpoint, the a_ prefix for animated hashes, the allowed sizes and the default avatar rule. dkit could build the URL offline.

Proposed behaviour

A suggested interface (if you want a different one, please propose it in a comment on this issue before you start coding):

$ dkit cdn avatar 80351110224678912 a_1269e74af4df7417b13759eae50c83dc --format webp --size 256
https://cdn.discordapp.com/avatars/80351110224678912/a_1269e74af4df7417b13759eae50c83dc.webp?size=256
$ dkit cdn default-avatar 80351110224678912        # index 5 (see below)
$ dkit cdn --list                                  # every endpoint type with its path
$ dkit --json cdn guild-icon GUILD_ID HASH

Rules that come straight from the docs ("Image Formatting" in developers/reference.mdx):

  • Base URL https://cdn.discordapp.com/, formats JPEG (.jpg, .jpeg), PNG, WebP, GIF and Lottie (.json). The format is the extension at the end of the URL.
  • ?size= can be any power of two between 16 and 4096. Anything else is a usage error (exit 2) with a hint.
  • A hash that starts with a_ is available in an animated format, as GIF or as animated WebP (.webp plus ?animated=true).
  • Default user avatar: the index is (user_id >> 22) % 6 for users on the new username system and discriminator % 5 for legacy users. For example (80351110224678912 >> 22) % 6 is 5. The size parameter is ignored for default avatars and stickers.
  • Sticker GIFs are not on the CDN base URL, they live at https://media.discordapp.net/stickers/<sticker_id>.gif.
  • IDs are snowflakes: reuse parse_snowflake from dkit.core.parse.

Data

  • New src/dkit/data/cdn.json with the endpoint table (type, path template, whether it supports GIF), the formats and the size rule, with source, source_rendered and last_verified.
  • Copy the endpoint table by machine from the docs. Footnotes you do not implement (for example custom emoji recommendations) can be stored as notes. If something is not documented, say so (CONTRIBUTING rule 4).
  • Register the dataset in DATASETS (core/data.py) and raise the JSON file count in the wheel check in .github/workflows/ci.yml by one (it is 10 on main today; if another data PR is merged before yours, rebase and raise it once more).

Acceptance criteria

  • Tests for several endpoint types, formats, valid and invalid sizes, a_ hashes, the default avatar rule (both branches) and --json.
  • 100% line and branch coverage, ruff check and ruff format --check clean.
  • README section and an entry under [Unreleased] in CHANGELOG.md (single ### Added block, ends with the issue number, no removed lines).
  • The command never makes a request, it only builds the URL (CONTRIBUTING rule 2).

Please comment on this issue before you start (see CONTRIBUTING.md). AI-assisted contributions are welcome, please mention it in the PR description.

Dominant language
Python
Stars
1
Forks
7
Avg merge
11h 50m
Merged PRs (30d)
35

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Bytewave1/dkit

All issues in Bytewave1/dkit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.