Lightweight native Discord client for Windows, Linux and macOS, written in Rust. No Electron, no browser engine.
Rust desktop-appdiscorddiscord-clienteguielectron-alternativelightweightlinuxmacosnative-apprustwindows
Owner crown and boost gem in the server member list
VRonGitHub9e7be60458e6
diff --git a/apps/rustcord/src/demo.rs b/apps/rustcord/src/demo.rsindex 447b206..6406a0b 100644--- a/apps/rustcord/src/demo.rs+++ b/apps/rustcord/src/demo.rs@@ -520,6 +520,8 @@ fn member_list(guild: u64) -> Value {let presence = |id: u64, status: &str, activities: Value| json!({ "user": { "id": id.to_string() }, "status": status, "activities": activities });let member = |id: u64, status: &str, activities: Value| json!({ "member": {"user": user(id), "roles": member_roles(id, guild), "presence": presence(id, status, activities),+ // Clippy boosts the server (the gem after the name).+ "premium_since": if id == CLIPPY { json!("2026-03-04T18:00:00+00:00") } else { Value::Null },} });let group = |id: String, count: u32| json!({ "group": { "id": id, "count": count } });let role = |i: usize| (if guild == G_RUST { ROLES[i].0 } else { ROLES[i].1 }).to_string();diff --git a/apps/rustcord/src/store.rs b/apps/rustcord/src/store.rsindex b70f2d7..60a0f57 100644--- a/apps/rustcord/src/store.rs+++ b/apps/rustcord/src/store.rs@@ -67,7 +67,15 @@ pub struct Typist {pub enum ListItem {/// A role group ("online"/"offline" or a role id) and how many are in it.Group { id: String, count: u32 },- Member { user: User, nick: Option<String>, roles: Vec<Id>, styles: Option<DisplayNameStyle>, presence: Presence },+ Member {+ user: User,+ nick: Option<String>,+ roles: Vec<Id>,+ styles: Option<DisplayNameStyle>,+ presence: Presence,+ /// When they started boosting the server (ISO 8601), if they do.+ boosting_since: Option<String>,+ },}#[derive(Clone, Debug, Default)]@@ -111,6 +119,7 @@ fn parse_list_item(v: &Value) -> Option<ListItem> {roles: ids(&m["roles"]),styles: member_styles(m),presence,+ boosting_since: m["premium_since"].as_str().map(String::from),})}@@ -781,6 +790,15 @@ impl Store {self.guild_perms(gid) & perm != 0}+ /// Who gets the crown in the server's member list: the owner, unless a+ /// role with Administrator is shown separately (hoisted), whether or not+ /// anyone has it. That is Discord's rule.+ pub fn crowned_owner(&self, gid: Id) -> Option<Id> {+ let g = self.guilds.get(&gid)?;+ let hoisted_admin = g.guild.roles.iter().any(|r| r.hoist && r.permission_bits() & permissions::ADMINISTRATOR != 0);+ g.guild.owner_id.filter(|_| !hoisted_admin)+ }+/// Position of our highest role (roles below it are ones we can manage).pub fn my_top_role(&self, gid: Id) -> i64 {let Some(g) = self.guilds.get(&gid) else { return 0 };@@ -1327,7 +1345,7 @@ impl Store {// Keep the shared presence/user/member caches warm from the list.let mut fresh_members = Vec::new();for item in list.items.iter().flatten() {- if let ListItem::Member { user, presence, nick, roles, styles } = item {+ if let ListItem::Member { user, presence, nick, roles, styles, .. } = item {fresh_presences.push((user.clone(), presence.clone()));fresh_members.push((user.id, MemberInfo { nick: nick.clone(), roles: roles.clone(), styles: styles.clone() }));}@@ -1942,6 +1960,25 @@ mod tests {assert_eq!(rows(&store, gid), ["general", " older (last)", "help", " synced (last)"]);}+ /// Discord's crown rule: the owner has it unless a role with+ /// Administrator is displayed separately, even one nobody has.+ #[test]+ fn the_owner_loses_the_crown_to_a_hoisted_admin_role() {+ let crowned = |roles: serde_json::Value| {+ let mut store = Store::default();+ store.load_ready(&json!({+ "user": { "id": "1", "username": "me" },+ "guilds": [{ "id": "500", "properties": { "name": "S", "owner_id": "2" }, "roles": roles, "channels": [] }],+ }));+ store.crowned_owner(Id(500))+ };+ let admin = (1u64 << 3).to_string();+ assert_eq!(crowned(json!([])), Some(Id(2)));+ assert_eq!(crowned(json!([{ "id": "7", "name": "Mods", "hoist": true, "permissions": "8192" }])), Some(Id(2)), "hoisted, not admin");+ assert_eq!(crowned(json!([{ "id": "7", "name": "Admin", "hoist": false, "permissions": admin }])), Some(Id(2)), "admin, not hoisted");+ assert_eq!(crowned(json!([{ "id": "7", "name": "Admin", "hoist": true, "permissions": admin }])), None);+ }+/// The compact READY (IDENTIFY with capabilities): everyone once in/// `users` and named by ID elsewhere, our own members in `merged_members`,/// a server's details under `properties`, read states that aren'tdiff --git a/apps/rustcord/src/ui/group_dm.rs b/apps/rustcord/src/ui/group_dm.rsindex a6d7b8a..f5ecfa0 100644--- a/apps/rustcord/src/ui/group_dm.rs+++ b/apps/rustcord/src/ui/group_dm.rs@@ -12,7 +12,7 @@ use serde_json::json;/// Discord's limit: ten people in a group DM, you included.pub(super) const MAX_MEMBERS: usize = 10;/// The owner's crown (`--icon-feedback-warning`, read from the page).-const CROWN: Color32 = Color32::from_rgb(206, 129, 0);+pub(super) const CROWN: Color32 = Color32::from_rgb(206, 129, 0);const BRAND: Color32 = Color32::from_rgb(0x58, 0x65, 0xf2);const BRAND_HOVER: Color32 = Color32::from_rgb(0x47, 0x52, 0xc4);const CRITICAL: Color32 = Color32::from_rgb(0xd2, 0x2d, 0x39);@@ -116,20 +116,21 @@ impl RustCord {let galley = painter.layout_no_wrap(name, font, color);let name_w = galley.size().x;painter.galley(pos2(av.right() + 12.0, y - galley.size().y / 2.0), galley, color);- let mut x = av.right() + 12.0 + name_w + 4.0;+ // After the name, as Discord orders them: the server tag,+ // then the APP tag and the owner's crown.+ let mut x = av.right() + 12.0 + name_w;+ if let Some((tag, badge)) = user.server_tag() {+ x += 4.0 + super::paint_tag_chip(ui, &painter, x + 4.0, y, &tag, badge.as_deref(), &t);+ }+ if let Some(right) = super::paint_bot_badge(&painter, x + 4.0, y, user, &t) {+ x = right;+ }if owner == Some(user.id) {- let crown = Rect::from_min_size(pos2(x, y - 7.0), vec2(14.0, 14.0));+ let crown = Rect::from_min_size(pos2(x + 4.0, y - 7.0), vec2(14.0, 14.0));painter.text(crown.center(), Align2::CENTER_CENTER, icon::CROWN, icon_font(14.0), CROWN);if ui.rect_contains_pointer(crown) {resp.clone().on_hover_text("Group Owner");}- x = crown.right() + 4.0;- }- if let Some(right) = super::paint_bot_badge(&painter, x, y, user, &t) {- x = right + 4.0;- }- if let Some((tag, badge)) = user.server_tag() {- super::paint_tag_chip(ui, &painter, x, y, &tag, badge.as_deref(), &t);}if let Some(sub) = &sub {sub.paint(ui, &painter, pos2(av.right() + 12.0, inner.center().y + 9.0), t.text_muted);diff --git a/apps/rustcord/src/ui/members.rs b/apps/rustcord/src/ui/members.rsindex 7c88d69..c530ad3 100644--- a/apps/rustcord/src/ui/members.rs+++ b/apps/rustcord/src/ui/members.rs@@ -9,6 +9,9 @@ use eframe::egui::{self, pos2, vec2, Align2, Color32, FontId, Frame, Margin, Order, Rect, RichText, ScrollArea, Sense, Stroke, Ui,};+/// The boost gem's pink (Discord's GUILD_BOOSTING_PINK).+const BOOST_PINK: Color32 = Color32::from_rgb(0xff, 0x73, 0xfa);+fn rgb(c: u32) -> Color32 {Color32::from_rgb((c >> 16) as u8, (c >> 8) as u8, c as u8)}@@ -39,6 +42,7 @@ impl RustCord {};let list = self.store.member_lists.get(&(gid, list_id));+ let crowned = self.store.crowned_owner(gid);let mut open: Option<(User, egui::Pos2)> = None;// Right-click: the member menu (moderation.rs).let mut menu: Option<(User, egui::Pos2)> = None;@@ -68,7 +72,7 @@ impl RustCord {p.text(pos2(r.left() + 16.0, r.center().y), Align2::LEFT_CENTER, format!("{} — {}", role_name(id), count), crate::style::medium(14.0), t.channel_default);ui.add_space(4.0);}- Some(ListItem::Member { user, nick, roles: member_roles, presence, .. }) => {+ Some(ListItem::Member { user, nick, roles: member_roles, presence, boosting_since, .. }) => {let styled = self.user_in(user, Some(gid));let user: &discord::model::User = &styled;let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), super::dense(44.0)), Sense::click());@@ -112,12 +116,30 @@ impl RustCord {let shapes = super::nameplate_shapes(ui, inner, 6.0, user, super::Plate::MemberList, resp.hovered(), false, Some(av.right() + 12.0 + name_w));ui.painter().set(plate_slot, egui::Shape::Vec(shapes));}- let mut x = av.right() + 12.0 + name_w + 4.0;- if let Some(right) = super::paint_bot_badge(&painter, x, y, user, &t) {- x = right + 4.0;- }+ // After the name, as Discord orders them: the server tag,+ // then the APP tag, the owner's crown and the boost gem.+ let mut x = av.right() + 12.0 + name_w;if let Some((tag, badge)) = user.server_tag() {- super::paint_tag_chip(ui, &painter, x, y, &tag, badge.as_deref(), &t);+ x += 4.0 + super::paint_tag_chip(ui, &painter, x + 4.0, y, &tag, badge.as_deref(), &t);+ }+ if let Some(right) = super::paint_bot_badge(&painter, x + 4.0, y, user, &t) {+ x = right;+ }+ if crowned == Some(user.id) {+ let crown = Rect::from_min_size(pos2(x + 4.0, y - 7.0), vec2(14.0, 14.0));+ painter.text(crown.center(), Align2::CENTER_CENTER, icon::CROWN, icon_font(14.0), super::group_dm::CROWN);+ if ui.rect_contains_pointer(crown) {+ resp.clone().on_hover_text("Server Owner");+ }+ x = crown.right();+ }+ if let Some(since) = boosting_since {+ let gem = Rect::from_min_size(pos2(x + 3.0, y - 6.0), vec2(14.0, 14.0));+ painter.text(gem.center(), Align2::CENTER_CENTER, icon::BOOST, icon_font(14.0), BOOST_PINK);+ if ui.rect_contains_pointer(gem) {+ let date = chrono::DateTime::parse_from_rfc3339(since).map(|d| super::popups::long_date(d.timestamp_millis() as u64)).unwrap_or_default();+ resp.clone().on_hover_text(format!("Server boosting since {date}"));+ }}if let Some(sub) = &sub {sub.paint(ui, &painter, pos2(av.right() + 12.0, inner.center().y + 9.0), t.text_muted);diff --git a/crates/discord/src/model.rs b/crates/discord/src/model.rsindex 5ae0c09..2231cce 100644--- a/crates/discord/src/model.rs+++ b/crates/discord/src/model.rs@@ -799,6 +799,8 @@ pub struct Role {pub permissions: String,pub icon: Option<String>,pub unicode_emoji: Option<String>,+ /// "Display role members separately": its own group in the member list.+ pub hoist: bool,/// Bot / booster roles: Discord assigns these, nobody can by hand.pub managed: bool,/// Anyone may @mention it (otherwise only with Mention Everyone).