Skip to content

chore(deps): bump twilight 0.17 → 0.18 and adapt the Discord adapter - #194

Merged
wangzhizhou merged 1 commit into
mainfrom
chore/twilight-0.18
Nov 10, 2026
Merged

wangzhizhou merged 1 commit into
mainfrom
chore/twilight-0.18

Conversation

@wangzhizhou

Copy link
Copy Markdown
Contributor

接管 #193(dependabot 的 twilight-* 成组升级):原 PR 只改 lock 里的版本号,easybot-adapter-discord 编译失败,本 PR 补上迁移。

0.18 的破坏性变化

MessageCreate 不再是 Box<Message> 的 newtype(.0 字段变私有),改成:

pub struct MessageCreate {
    pub channel_type: Option<ChannelType>,
    #[serde(flatten)]
    pub message: Message,
}
impl Deref for MessageCreate { type Target = Message; ... }

适配

crates/easybot-adapter-discord/src/lib.rs:

  • msg.0.guild_id → msg.guild_id(走 Deref)
  • &msg.0 → &msg.message

twilight-* 成组升级后,twilight-gateway 内部依赖的 twilight-http 也同步到 0.18,因此不会出现同 crate 双版本,cargo deny 的 multiple-versions = "deny" 保持干净。

验证

  • cargo clippy -p easybot-adapter-discord --all-targets --locked -- -D warnings ✅
  • cargo test -p easybot-adapter-discord --locked ✅(37 + 27 通过)
  • cargo check --workspace --all-targets --features "default,plugin-system" --locked ✅
  • cargo deny check advisories bans licenses sources ✅

twilight 0.18 replaced the `MessageCreate` newtype-over-`Box<Message>` with a
plain struct:

    pub struct MessageCreate {
        pub channel_type: Option<ChannelType>,
        #[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.
@wangzhizhou
wangzhizhou added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 85ada5c Nov 10, 2026
19 checks passed
@wangzhizhou
wangzhizhou deleted the chore/twilight-0.18 branch November 10, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant