One GIF upload took latency to Discord from 39 ms to over 450 ms, which was the music lag. The card is smaller and about 15 fps, goes still when uploads get slow, and panels no longer hold up skips. The waveform reads at a gentler rate and recent pictures are reused. deploy/shape-upload.sh keeps voice ahead of uploads. Music links get the private-network check, music ffmpeg can only open web addresses, casino bets are checked and taken in one step, zstd-safe updated. Co-Authored-By: Claude Opus 5.5 <[email protected]>
24 KiB
Dezio (Rust) — roadmap
Port of the Python bot in ~/Projects/Discord Bot (kept until this reaches parity). Backups: ~/Projects/Discord Bot-backups/dezio-python-2026-10-23.tar.gz, Chromebook /root/dezio-python-2026-10-23-pre-rust.tar.gz.
Stack: tokio, twilight (gateway/http/model — has Components V2 Container etc.), songbird for voice, serde. Build on the PC (~/.cargo/env), copy the release binary to the Chromebook (x86_64).
Never log in with the real token on the PC (the live bot would answer twice).
Order: 1 core (config, JsonStore with debounce, V2 card builder, command framework, prefix D! + slash) → 2 admin/moderation/logs → 3 utility/search/info/help → 4 media (/download incl. parallel convert) → 5 fun/AI/games/casino → 6 music + Last.fm → 7 dashboard + Game Boy Activity server + TUI → 8 data migration check against the old data/*.json.
FINAL STEP (owner request): fix the Chromebook's start-at-boot service (systemd unit for the Rust binary; previously the bot ran by hand in screen).
Status
- Stage 1 (2026-10-23): paths, JsonStore (same file format, debounced atomic saves), V2
Cardbuilder, one command framework forD!+ slash (per-guild prefix from data/prefixes.json, permission check, user-install contexts, slash sync with hash), commandspingandprefix. 5 unit tests pass; release binary builds (14 MB). NOT run against Discord: the bot only connects whenDEZIO_LIVE=1(set that on the Chromebook only). - Stage 2a (2026-10-23): member/role cache (twilight-cache-inmemory, members requested on GuildCreate), converters (durations, member lookup by name/mention/id/reply), error cards (user errors / 403 / unexpected), permission + role-hierarchy checks, Moderation (kick, ban, unban, timeout, untimeout, nick, role, slowmode), purge (all 15 filters, bulk + one-by-one, Stop button, progress card), help (categories, paged, detail pages, select menu, works after restarts). 18 unit tests incl. a check that every help page fits Discord's V2 limits.
- Not yet in 2a: /unban and /timeout autocomplete,
helpautocomplete, bot-permission pre-checks, per-command cooldowns. - Next: stage 2b = logs (audit-log matching, 1174 lines in Python), welcome, role menus, channel tools, dashboard cog.
Stage 2b status (2026-10-23)
- Done: cdn link refresher, welcome/goodbye/autorole/sticky roles (setup panel with channel + role selects, edit modal, test; join/leave/pending handlers), reqwest HTTPS (tested), 21 unit tests.
- Still to do in 2b: logs (audit-log matching), channel tools (lock/media/reddit/nsfw/pin), role menus.
Role menus — owner request (keep presets, but configurable in Discord AND on the website)
Today: stock categories live in assets/data/role_menus.json (name, emoji, role names); each server only picks which preset names to use (data/role_menus.json: {guild: {cat: {roles:[names], stock:"one"|"many"}, public_messages:{cat:{channel,message}}}}), and only through the Discord editor; the dashboard has no role-menu page. Plan (backward compatible with the existing file):
- Presets stay as templates. A server's category may override
nameandemoji, edit itsroles(add/remove/reorder, any name, not just preset ones; missing roles are created with a colour on publish), switchstockone/many, and can be a brand-newcustomcategory. "Reset to preset" restores the template. - Discord:
/cosmeticseditor gets rename/emoji/add role/remove role/reset, plus "New custom menu". - Website: a Role menus page with the same operations, saving to the same file; the bot re-publishes in place.
- Role menus, Discord side DONE (2026-10-23):
/cosmetics(D!cosmetics) overview + editor — rename/emoji, add own roles, tick roles, pick one/many, reset to preset, new/delete custom menus, Publish (creates/deletes roles, posts or edits the dropdown in place); member dropdowns work from the message itself. Reads the existing data/role_menus.json (checked against a copy of the real file). The website page comes with the Rust dashboard (stage 7); the file format above is the shared contract. - Still open in 2b: logs, channel tools (lock/media/reddit/nsfw/pin).
Stage 2b — DONE (2026-10-23)
- Channel tools:
/lockD!lockD!unlock(saved overwrites in the Python bot's own format),/media,/redditD!unreddit,/setnsfwD!nsfw, right-click "Pin Message" with a persistent Unpin button (framework now supports message context menus). - Logger: audit-log matching (pushed entries, claims, merged message-delete/voice credits), batched webhook delivery (falls back to the bot),
/loggingsetup panel, and handlers for bans, joins (with the invite used), leaves/kicks, AutoMod, pins, prune, message delete/edit/bulk (with transcript), member nick/roles/timeout/boost/screening, voice, channels + permission changes, threads, stages, webhooks, roles, emoji, stickers, server settings, scheduled events. Reads the existing data/logging.json. - Differences from Python worth knowing: other people's username/avatar changes are noticed through member updates (Discord only sends the bot's own user updates); message edit/delete logs need the message to be in the 3000-message cache, as before.
- 35 unit tests. Nothing tested against Discord yet.
- Next: stage 3 = utility/search/info (userinfo, serverinfo, avatar, weather, wiki, define, calculator, snipe, afk, embed builder…).
Stage 3a — DONE (2026-10-23)
- Info cards: userinfo, serverinfo, channelinfo, roleinfo, avatar, banner + "Show Avatar"/"Show Banner" right-click apps (framework now has user menus), card colours taken from avatars/icons (
colors.rs: median-cut palette like the Python version, cached), per-user/server prefs (prefs.rs, data/users.json + servers.json), snipe (deleted/edited/reactions, opt-out, paging), afk (+ welcome-back list), mpreg. 47 unit tests. - Still open in stage 3 (3b): tools.py (calculate with keypad, color, translate, weather, viruscheck), search.py (web/image search, wikipedia, define, urban, rule34), embeds.py (/embed builder + "Edit Embed"), and the rest of other.py (dm_echo, /ad, smash, serverclone, owner DMs on join/leave).
Stage 3b (tools) — DONE (2026-10-23)
- Calculator (own expression parser: big integers,
2^10,sin 30,5!,√16, old16 sqrtstyle, same error messages; the button keypad keeps its state on the card itself so it survives restarts), colour tool (swatch PNG drawn with the bundled Noto fonts, formats, matches, Lighter/Darker/Complement/Random buttons), translate (D!tr, "Translate Message" app, Google + MyMemory fallback), weather (Open-Meteo + ZIP + OpenStreetMap geocoding, autocomplete, °C/°F memory, private "saved place"), VirusTotal (link/file, free-tier limits). - Framework: autocomplete, file-attachment options, replies with a file, private "thinking" answers.
- Verified against the live services: Paris / Denver Colorado / Springfield, IL / 10001 / Tokyo geocode and forecast correctly (
cargo test live_weather -- --ignored). 65 unit tests. - Still open in stage 3 (3c): search.py (web/image search, wikipedia, define, urban, rule34), embeds.py (/embed builder + "Edit Embed"), rest of other.py (dm_echo, /ad, smash, serverclone, owner DMs on join/leave).
Stage 3c — DONE (2026-10-23) — stage 3 complete
- Search:
/search+D!image(DuckDuckGo html/lite/instant, Bing → Openverse → Zenserp images), Wikipedia (sections, languages, "other matches", random,fr: Paris), define (+ pronunciation audio, Urban Dictionary fallback),D!urban, rule34 (age-restricted only, same blocklist, TBIB/Xbooru). Generic pager (pager.rs) for result pages. - Embed builder (
/embed, "Edit Embed"): the preview embed is the draft, so editors survive restarts; text/images/author/footer/fields/JSON/import. dm_echo,/ad(+ the persistent edit button/form),smash/smashstats, owner-onlyserverclone(with a confirm prompt:confirm.rs), and DMs to server owners when the bot is added/removed.- Framework: cooldowns, owner-only commands.
- Verified against the live services: web search, image search, Wikipedia (8 sections, 59 languages), dictionary, Urban Dictionary (
cargo test live_search -- --ignored). 81 unit tests; 53 commands/menus registered. - Next: stage 4 = media (/download incl. the parallel convert, images/effects, quote, emoji).
Stage 4 — DONE (2026-10-23) — media
- Text engine (
text.rs, cosmic-text): real shaping + per-character font fallback, so Latin, CJK, Arabic (right-to-left), Indic, Thai, symbols and COLOUR emoji all draw. Fonts ship inassets/fonts/(Noto Sans +fallback/: CJK, Arabic, Hebrew, Indic scripts, Symbols, Math, Noto Color Emoji ≈ 75 MB with the rest of assets). Google Fonts picked by name are downloaded once (no API key now: the public CSS endpoint) intodata/fonts/google/. - Quotes (
media/quote.rs): right-click → Create Quote, or replyD!quote. Default = the familiar "quote bot" look (greyscale portrait fading into black on the left, centred quote, "- Name", "@handle", small watermark — 1200×630). Presets: Classic, Portrait (630×790: picture fading into black, big quote marks, text, divider line, small avatar icon + @handle), and the four older circle styles. On the card: preset, font (any Google Font), layout, flip, B&W/colour, quote marks, name, @handle, divider, icon (off/avatar/server), bold, and a form for size / text colour / background / gradient / watermark. Save as my default / Save for this server (Manage Server) / Reset. The watermark defaults to "Dezio" (editable, empty = none).- Shared file for the dashboard:
data/quote.json={"users": {"<id>": Style}, "servers": {"<id>": Style}}; everyStylekey has a default, so partial objects are fine. Keys: preset, layout (wide|portrait), image (fade|circle|none), grayscale, flip, bg, bg2 (gradient end or null), text, author, muted, font, bold, size (0 = fit), marks, name, handle, line, icon (none|avatar|server), watermark, quote_chars. Resolution order: your style → server style → Classic.
- Shared file for the dashboard:
- Image effects (
media/images.rs):/image(D!fx): all 10 effects and 14 filters, GIFs/animated WebP keep their animation, size-aware re-render for the upload limit. NEWconvertoption (also/convertandD!convert <format>): picture/GIF/video → gif, mp4, webm, png, jpg, webp or mp3 (ffmpeg; retries smaller settings until it fits; a still picture becomes a 3 s clip). Sources: attachment, replied message (attachments, embed video/image, stickers), link, custom emoji, @user avatar./petpet+D!petpet. - Emoji (
media/emoji.rs):/steal,/combine(Emoji Kitchen),D!emojibrowser and the Get Assets menu with "Add to this server". - /download (
media/download/): the whole Python pipeline ported (yt-dlp + ffmpeg + gallery-dl as child processes): sizes checked before downloading (CDN asked when yt-dlp doesn't know), H.264+AAC preferred, size watchdog that drops to a smaller stream, VP9/AV1/HEVC converted while downloading (one ffmpeg reads yt-dlp's stream URLs directly; falls back to download-then-convert), ffprobe validation, one-pass compression, slideshows/carousels via gallery-dl, audio mode (Opus 96 kbps), progress card with Cancel, Delete + Original post buttons, upload retries, one job at a time. Verified against a local server (H.264, VP9, convert-while-downloading, audio, forced squeeze, cancel) and real links (a direct mp4 and a YouTube video). - Framework:
Command::slash_as(a slash name different from the text command:/image=D!fx),find_slash. - Not tested against Discord. Known gaps: no per-command "I need Attach Files" pre-check; the quote card's controls stop working after a restart (sessions live in memory, as the Python view did).
- Next: stage 5 = fun / AI / games / casino.
Stage 6 — DONE (2026-10-23) — music + Last.fm
- Music (
commands/music/): songbird (with Discord's required voice encryption) for voice; yt-dlp lookups in separate processes; ffmpeg → PCM read ahead in a 15 s buffer (a stall plays silence instead of rushing; position counts real frames only)./play(search or link, playlists, YouTube mixes load 25 first then the rest),/pause/resume/skip/stop/queue/nowplaying/seek/loop/shuffle/unqueue/volume/join/leave+D!mhelp, aliases as before. Now-playing panel with buttons that carrymusic:<action>:<guild>(work after restarts), card colour from the cover, bitrate = channel bitrate (≤96 kbps), idle leave after 5 min, prefetch of the next stream, volume saved per server. - Last.fm (
commands/lastfm/):/fm(now playing, top, recent, profile, link),D!ta/tab/tt/recent/fmprofile/fmset, Who Knows (D!wk/wkt/wka, prefix only),D!chartcollage (prefix only) (drawn with the new text engine), Pixel Jumble (D!px, prefix only: a linked member starts a round from their own albums, then anyone can answer by typing in chat or with the button),/lyrics(LRCLIB + lyrics.ovh), "Listen to song" button (yt-dlp → Opus file, private, deletes itself). Cards use the games engine (owner-only buttons, switch views, idle end). Reads data/lastfm.json. - Verified live: Last.fm API (profile, top artists, not-found, album info); YouTube search → stream → ffmpeg → 204 real audio frames. NOT verified: actually joining a voice channel (needs Discord).
- Known gap: on a stage channel the bot asks to speak but can't auto-unsuppress (twilight's builder has no "suppress: false").
- Next: stage 7 = dashboard (+ role-menu page, quote styles page), Game Boy Activity server, TUI.
Stage 7 — DONE (2026-10-23) — dashboard, Game Boy Activity, console
- Dashboard (
src/web/, axum): the website,/dashboard(the same pages as before, extended), Discord sign-in (OAuth, sessions in data/dashboard_sessions.json — same format as Python, so people stay signed in), CSRF + same-origin checks, live Manage Server checks from the member cache. API:/api/me,/api/user(Last.fm link, AFK, download quality, weather, privacy, quote style),/api/guilds/<id>(prefix, music volume, snipe, logging channels, welcome/goodbye + autoroles, AI personality/lock, server quote style, role menus),/api/places,/api/quote/preview(the bot draws the preview, so it's exactly what Create Quote makes).DASHBOARD_URL,DASHBOARD_CLIENT_SECRET,DASHBOARD_HOST/PORTas before.- New pages: Quote style (preset, layout, picture mode, toggles, icon, any Google Font, size, colours, gradient, watermark, live preview; saved as the person's default or the server's default → data/quote.json) and Role menus (edit presets, add roles, one/many, reset to preset, new custom menus, publish to a channel — the same data and publish code as
/cosmetics).
- New pages: Quote style (preset, layout, picture mode, toggles, icon, any Google Font, size, colours, gradient, watermark, live preview; saved as the person's default or the server's default → data/quote.json) and Role menus (edit presets, add roles, one/many, reset to preset, new custom menus, publish to a channel — the same data and publish code as
- Game Boy Activity (
src/web/activity.rs,commands/gameboy.rs): the same API as the Python server (config, token, web-session, library with covers from SteamGridDB, ROM download, battery saves, save states, legacy saves);/gameboylaunches the Activity (raw interaction callback type 12),D!gameboyposts a Play card; slash sync keeps Discord's "Launch" entry-point command. - Console (
src/tui.rs, ratatui): live stats header, Activity / Console / Commands / Servers tabs, command box (help,sync,status <text|reset>,send <channel> <text>,servers,leave <id>,clear,quit). Starts when the bot runs in a terminal;--headlessor no terminal (systemd) logs as plain text. Not ported: cog reload/load/unload (nothing to reload in a binary) and the Python self-test tab (the Rust tests replace it). - Status: "Watching In N servers | /help | D!help" (+ owner
setstatus/resetstat). --web-devserves only the web pages with a made-up signed-in session (cookiedezio_session=devtoken, http://127.0.0.1:8099) for looking at the dashboard without Discord. Checked in the browser: the quote editor draws wide and portrait previews (Latin/Japanese/Arabic/emoji) and saves.- 7 web tests (pages + security headers, sign-in gate, CSRF/origin refusals, settings saved and validated, quote preview PNG, ROM library + saves per player).
- Not tested: the server-settings endpoints (they need a live server cache), OAuth against Discord, the Activity inside Discord.
- Note: ~/Projects/Dezio/data/ holds leftovers from the unit tests (fake ids); it's git-ignored and gets replaced by the real Python data in stage 8.
- Next: stage 8 = run against the real data/*.json from the Python bot, a final comparison of every command, then deploy + the Chromebook boot service.
Stage 8 — IN PROGRESS (2026-10-23) — parity check
- Data: compared every file in the Python
data/with what the Rust code reads (afk, ads, ai, casino, channels, confessions, cookieclicker, lastfm, logging, prefixes, reaction_roles, role_menus, snipes, status_roles, sticky_roles, temp_roles, welcome): same names and shapes, so the Python files can be copied over as they are.users.json/servers.jsondon't exist in Python's data yet (created on first use). - Command comparison (every Python command, alias and slash name vs the Rust registry) found one gap: reaction roles, temporary roles and status roles (
roles.py). Now ported insrc/commands/reactionroles.rs:D!rr add|remove|list|<mode> [minutes],/reactionrole,/rr-type,/rep(+D!rep), the reaction add/remove handler (normal, toggle, unique, verify, temporary), a 30 s expiry loop, and status-role sync on presence changes, joins and/repchanges. Uses the real data (4 reaction-role messages, one/hurtmestatus role). - Not ported on purpose: the owner-only
D!dashboard(the web server starts by itself),D!selftest(Rust tests replace it). - Still to do: deploy to the Chromebook and fix its start-at-boot service (needs the owner's go-ahead because it replaces the running Python bot); Python files stay until the owner says to delete them.
Stage 8 — DONE (2026-10-23) — deployed
- Chromebook (192.168.1.71): Rust bot in
/root/Dezio(binary, assets, web, copy of Python's data + .env).dezio-bot.servicenow runs/root/Dezio/dezio --headless(DEZIO_LIVE=1), enabled at boot, Restart=always; the health-check timer still checks :8080. Python bot stopped (its files in/root/Discord Botuntouched). - Backups:
/root/dezio-bot.service.bak(old unit),/root/dezio-python-data-*-pre-switch.tar.gz,/root/dezio-python-2026-10-23-pre-rust.tar.gz. - Rollback:
systemctl stop dezio-bot; cp /root/dezio-bot.service.bak /etc/systemd/system/dezio-bot.service; systemctl daemon-reload; systemctl start dezio-bot. - Fix found on first start: slash descriptions over 100 characters made Discord refuse the whole sync; they're now cut to 100.
- Source: forgejo:astar76/Dezio.git (branch master).
Dashboard and website redesign (2026-11-06)
- Direction: a mixing desk at night. Graphite surfaces, orchid accent, the logo's diamond facet as the mark on controls. Tokens in
web/site/assets/tokens.css, fonts self-hosted inweb/site/assets/fonts/(the CSP blocks font CDNs), vector logo inweb/site/images/mark.svg. - Dashboard controls live in
web/dashboard/static/controls.js(faders, switches, segments, searchable pickers, colour picker). Every control fires a bubblinginput; sections go through one save bar. - The server page has only been looked at with faked API answers (
--web-devhas no Discord cache). Not checked on the live bot yet. - Fixed: role menus published from the dashboard no longer claim roles they didn't make (taking one out used to delete a server's own role); zero ids no longer panic
D!ban; announcement channels show in the pickers; static files revalidate after an update. - Music panel: an animated GIF drawn by
commands/music/card.rs, laid out like the website's player: cover and title, moving bars, clock and progress. Each GIF is 30 s at 20 fps, storing only changed pixels and is replaced about every 20 s while people listen, its clock started ahead by the measured upload time; a new panel posts a still JPEG first, and paused stays still. Bar heights follow the song's real loudness (source::peaks), their shape is drawn, not a real spectrum. Bar colours come from the album cover (greys for a cover with no colour). Typed searches go to YouTube Music for the real artist, album, year and square art, falling back to plain YouTube; links keep their own details. Without Attach Files the panel falls back to the text card. The 🔗 button shows the song's link to whoever pressed it, privately. - Voice: a failed join now forgets the call, and a song whose position stands still for 45 s tells the channel and leaves. Joins failed on 2026-11-06 because the Chromebook's network gives an IPv6 address with no IPv6 route; /etc/gai.conf now prefers IPv4 (backup /root/gai.conf.bak-2026-11-06). A running bot only picks that up after a restart.
- Known gap, unchanged: on a stage channel the bot can't unsuppress itself (twilight's
suppress()only sets true).
Drawn cards and Dezio's own emojis (2026-11-06)
cardart.rsis the shared kit (text, backdrops, tiles, GIFs that store only changed pixels). Colour follows the content: blackjack on green felt, slots in wine red, weather skies by condition, Last.fm from the album art, dark only where it suits, like the music player.- Casino spins are one GIF that plays once and lands on the real result, then the same final frame as a still with the buttons back (
games/art.rs). Balance isart::wallet. Slot symbols and weather icons are colour emoji drawn into the picture. tools/weather_art.rs: sky by condition, detail tiles, 24-hour chart with chance of rain, 5-day ranges. The place name stays off the picture on purpose.emojis.rs: application emojis fromassets/emojis/dz_*.png(SVG sources beside them), uploaded at startup if missing, swapped in for the plain emoji on every button throughui::emoji_buttonandgames::btn.assets/emojismust be copied when deploying.commands/info_art.rs:userinfo(banner, status, role chips in role colours),serverinfo(members and boost meters),channelinfo(a colour per channel type) androleinfo. The mention and ID stay as text under each picture.richestand Who Knows usecardart::chart;pager::start_drawnpages through drawn pictures.commands/info_copy.rs: the buttons under info cards open a private message with values in code blocks. Long lists (every role, channel, emoji, member, permission) go on pages instead of being cut short. Button ids carry what they need (ii:<kind>:<action>:<id>), so they survive restarts.commands/action_art.rs: pictures for moderation results, AFK, snipe, stolen emojis, VirusTotal reports and download progress. Download progress is a picture every 5 s;Live::freezestops those edits before the finished file goes up, because each edit replaces the message's files. Upload limit is 20 MiB by default since Discord's change on 2026-09-03 (upload_limit), more with boost levels 2 and 3./queuestays text: it's a private, self-deleting list of clickable links. A download's finished message is the video or file itself, so it gets no card.- Security pass: powerful roles are refused in role menus and autoroles (
State::role_gives_power), redirects are checked at every hop, HSTS, Game Boy page frameable only by Discord. Not done: rate limits, Forgejo on its own subdomain, narrower invite permissions,cargo audit(not installed).
Speed and security pass (2026-11-07)
- Measured on the Chromebook: 425 KB/s down, 114 KB/s up. Voice shares that upload, so a 664 KB GIF took latency to Discord from 39 ms to 450-785 ms. That was the music lag.
- The music card is now 640 wide at about 15 fps and turns into a still picture if uploads take over 12 s.
deploy/shape-upload.shkeeps the queue on the server so voice goes first; it has to be run by hand on the server. - The waveform reads at 10x speed, panels no longer hold up skips, recent avatars and covers are kept for 10 minutes.
- yt-dlp takes about 7 s per song because of its JS step. The faster clients were tested: android_vr gets a 403, android and others give the 360p video stream, about 4x the bandwidth.
- Attacked over the public address: traversal, forged sessions and bearer tokens, oversized bodies, open redirects, cross-site requests and Host tricks all failed. ffmpeg file reads through crafted playlists and concat files were refused. @everyone can't be sent through confessions, phone, AI or echo.
- Patched: music links now get the private-network check, music ffmpeg can only open web addresses, casino bets are checked and taken in one step. zstd-safe updated.
- Still open: rustls 0.22 (twilight-gateway), rustls-webpki 0.102, ringbuf and libcrux (songbird) need new upstream releases. All Forgejo repos are public. Redirects inside yt-dlp and ffmpeg aren't checked.