From df9f4683c297411f5ee72754a351d08f7a997b00 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 11 Nov 2026 06:05:55 +0800 Subject: [PATCH] chore(deps): bump twilight 0.17 -> 0.18 and adapt the Discord adapter twilight 0.18 replaced the `MessageCreate` newtype-over-`Box` with a plain struct: pub struct MessageCreate { pub channel_type: Option, #[serde(flatten)] pub message: Message, } impl Deref for MessageCreate { type Target = Message; ... } The tuple field is now private, so `msg.0` no longer compiles. Adapted the adapter to `msg.guild_id` (via Deref) and `&msg.message`. Both crates move together through the new `twilight-*` dependabot group, so twilight-http (pulled in by twilight-gateway) stays on the same version and `cargo deny`'s multiple-versions ban stays clean. Verified: cargo clippy -p easybot-adapter-discord --all-targets -- -D warnings, cargo test -p easybot-adapter-discord (37 + 27 pass), cargo check --workspace --all-targets --features "default,plugin-system", cargo deny check. --- CHANGELOG.md | 8 ++++++++ Cargo.lock | 24 +++++++++++------------ crates/easybot-adapter-discord/Cargo.toml | 4 ++-- crates/easybot-adapter-discord/src/lib.rs | 4 ++-- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49e2faea..46ffc657 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,14 @@ 没有任何 step、恰好 15 分钟整 `cancelled`,**并非 job 超时**)。改为批量后一轮最多 合并 5 条、只跑一次全量 CI。 + +- **Discord 适配器升级到 twilight 0.18** — 0.18 去掉了 `MessageCreate` 的 + newtype + `Box` 包装(内部字段变私有,`msg.0` 不再可见),改为 + `struct MessageCreate { channel_type, #[serde(flatten)] message: Message }` 并实现 + `Deref`。适配器相应改为 `msg.guild_id` / `&msg.message` + (`crates/easybot-adapter-discord/src/lib.rs`)。`twilight-*` 现已成组升级, + `cargo deny` 的 `multiple-versions` 也保持干净。 + ### Fixed - **`Coverage` 工作流在未配置 `CODECOV_TOKEN` 时必然红灯** — 仓库启用分支保护后,Codecov diff --git a/Cargo.lock b/Cargo.lock index ab97e1f8..94063413 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4063,9 +4063,9 @@ dependencies = [ [[package]] name = "twilight-gateway" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59267541c31f888c1587da5e7cbab182ae6efd98faedd9ea2e35a4eef43ff204" +checksum = "d8c9e5765f6cd5abb3cc936bd6bcf92f69414e2fe247764e150982664441cd50" dependencies = [ "bitflags", "fastrand", @@ -4084,9 +4084,9 @@ dependencies = [ [[package]] name = "twilight-gateway-queue" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "366a73fe47f61a3d522c3aaf70475e60634b0ae59e7b94272ed7496fffa7ceb7" +checksum = "89d36c3d0dfd786f7fb636feb479d1d65144b2e217fc763e1acd8ac0e9e99778" dependencies = [ "tokio", "tracing", @@ -4094,9 +4094,9 @@ dependencies = [ [[package]] name = "twilight-http" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b868001d7bfb953732b3f1cd92f63cb88cd2ea902f590b1d084c66aea60e48" +checksum = "f6e0c109c978d39708f6db201cb560a3bd01bd40ac2bedd1d8aa957e7bfb7f64" dependencies = [ "fastrand", "http", @@ -4115,9 +4115,9 @@ dependencies = [ [[package]] name = "twilight-http-ratelimiting" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0515b0c30814068a7540fcb5f58b634259ca453fa335d42c3b2c8f2b06ac6a59" +checksum = "076ca13229e378a4579b78e7579327e007ad462a50512cceb3b624dc1c3afb88" dependencies = [ "hashbrown 0.16.1", "tokio", @@ -4127,9 +4127,9 @@ dependencies = [ [[package]] name = "twilight-model" -version = "0.17.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf6bb7b93a7f765d89b3388cc710c0ae16104579e06bb30ea1ee6bd41420a8b" +checksum = "f8fdf271db1a859666b6ce10bb1bba03bf8d2bc55e13cdb1f70da75a7b8ae962" dependencies = [ "bitflags", "serde", @@ -4140,9 +4140,9 @@ dependencies = [ [[package]] name = "twilight-validate" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6a27472e023e3841d1c4e4e20253ed796e8440aada8b5205b8544f1172e661d" +checksum = "b60c92a02111538020a9d3f19fade997c81ab20554d38abecd0c9c10dc9b5ad9" dependencies = [ "twilight-model", ] diff --git a/crates/easybot-adapter-discord/Cargo.toml b/crates/easybot-adapter-discord/Cargo.toml index d341e410..350171a3 100644 --- a/crates/easybot-adapter-discord/Cargo.toml +++ b/crates/easybot-adapter-discord/Cargo.toml @@ -17,8 +17,8 @@ reqwest = { workspace = true } base64.workspace = true # Discord Gateway SDK (v0.17) -twilight-gateway = { version = "0.17", default-features = false, features = ["rustls-platform-verifier", "twilight-http", "zlib"] } -twilight-model = "0.17" +twilight-gateway = { version = "0.18", default-features = false, features = ["rustls-platform-verifier", "twilight-http", "zlib"] } +twilight-model = "0.18" [dev-dependencies] wiremock = "0.6" diff --git a/crates/easybot-adapter-discord/src/lib.rs b/crates/easybot-adapter-discord/src/lib.rs index 5f8e5128..a6ea47a0 100644 --- a/crates/easybot-adapter-discord/src/lib.rs +++ b/crates/easybot-adapter-discord/src/lib.rs @@ -538,7 +538,7 @@ impl DiscordAdapter { heartbeat.beat_success(); // stream-health: message received // Resolve guild owner from cache - let guild_id_str = msg.0.guild_id.map(|g| g.to_string()); + let guild_id_str = msg.guild_id.map(|g| g.to_string()); let owner_id = guild_id_str.as_ref().and_then(|gid| { guild_owner_cache.try_lock().ok() .and_then(|cache| cache.get(gid).cloned()) @@ -583,7 +583,7 @@ impl DiscordAdapter { .and_then(|cache| cache.get(gid).cloned()) }); if let Some(inbound) = DiscordAdapter::convert_message( - &msg.0, + &msg.message, &bot_user_id, owner_id.as_deref(), guild_name.as_deref(),