File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ pub struct User {
1717}
1818```
1919
20- ` Snowflake ` is a type alias for ` String ` . Use ` User::avatar_url() ` to build a CDN URL from the hash, and ` User::mention() ` for ` <@!id> ` .
20+ ` Snowflake ` is a type alias for ` String ` . Inspect ` avatar ` and ` id ` directly when building UI links or message content .
2121
2222## ` Member `
2323
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ pub struct User {
1717}
1818```
1919
20- ` Snowflake ` 是 ` String ` 的类型别名。` User::avatar_url() ` 用哈希拼出 CDN 地址, ` User::mention() ` 返回 ` <@!id> ` 的 mention 串 。
20+ ` Snowflake ` 是 ` String ` 的类型别名。构造 UI 链接或消息内容时,直接检查 ` avatar ` 与 ` id ` 字段 。
2121
2222## ` Member `
2323
Original file line number Diff line number Diff line change @@ -22,18 +22,6 @@ pub struct Member {
2222 pub mute : bool ,
2323}
2424
25- impl Member {
26- /// Gets the member's mention string.
27- pub fn mention ( & self ) -> String {
28- self . user . mention ( )
29- }
30-
31- /// Gets the member's avatar URL.
32- pub fn avatar_url ( & self ) -> Option < String > {
33- self . user . avatar_url ( )
34- }
35- }
36-
3725impl HasId for Member {
3826 fn id ( & self ) -> Option < & Snowflake > {
3927 Some ( & self . user . id )
Original file line number Diff line number Diff line change @@ -25,27 +25,6 @@ pub struct User {
2525 pub union_user_account : String ,
2626}
2727
28- impl User {
29- /// Gets the user's avatar URL if they have one.
30- ///
31- /// Returns the full URL to the user's avatar image.
32- pub fn avatar_url ( & self ) -> Option < String > {
33- ( !self . avatar . is_empty ( ) ) . then ( || {
34- format ! (
35- "https://thirdqq.qlogo.cn/headimg_dl?dst_uin={}&spec=640" ,
36- self . id
37- )
38- } )
39- }
40-
41- /// Gets the user's mention string.
42- ///
43- /// Returns a string that can be used to mention this user in messages.
44- pub fn mention ( & self ) -> String {
45- format ! ( "<@!{}>" , self . id)
46- }
47- }
48-
4928impl HasId for User {
5029 fn id ( & self ) -> Option < & Snowflake > {
5130 Some ( & self . id )
Original file line number Diff line number Diff line change @@ -32,7 +32,6 @@ fn user_uses_required_zero_value_fields() {
3232 assert ! ( !user. bot) ;
3333 assert_eq ! ( user. union_openid, "" ) ;
3434 assert_eq ! ( user. union_user_account, "" ) ;
35- assert ! ( user. avatar_url( ) . is_none( ) ) ;
3635}
3736
3837#[ test]
@@ -53,7 +52,6 @@ fn user_keeps_official_json_shape() {
5352 assert_eq ! ( value[ "bot" ] , true ) ;
5453 assert_eq ! ( value[ "union_openid" ] , "union-openid" ) ;
5554 assert_eq ! ( value[ "union_user_account" ] , "union-account" ) ;
56- assert ! ( user. avatar_url( ) . is_some( ) ) ;
5755}
5856
5957#[ test]
@@ -77,12 +75,6 @@ fn user_from_bot_info_preserves_union_fields() {
7775 assert_eq ! ( user. union_user_account, "UNION_ACCOUNT_XXXXXX" ) ;
7876}
7977
80- #[ test]
81- fn test_user_mention ( ) {
82- let user = test_user ( "123456789" , "TestUser" ) ;
83- assert_eq ! ( user. mention( ) , "<@!123456789>" ) ;
84- }
85-
8678#[ test]
8779fn test_member_name_fallback ( ) {
8880 let user = test_user ( "123456789" , "TestUser" ) ;
You can’t perform that action at this time.
0 commit comments