MCPcopy Create free account
hub / github.com/Botloader/botloader / handle_get_guild

Function handle_get_guild

components/discordbroker/src/http_api.rs:119–171  ·  view source on GitHub ↗
(
    Path(guild_id_u): Path<u64>,
    State(state): State<RouterState>,
)

Source from the content-addressed store, hash-verified

117}
118
119async fn handle_get_guild(
120 Path(guild_id_u): Path<u64>,
121 State(state): State<RouterState>,
122) -> ApiResult<Json<BrokerGuild>> {
123 let guild_id = Id::new_checked(guild_id_u).ok_or(ApiError::BadGuildId)?;
124
125 if let Some(g) = state.discord_state.guild(guild_id) {
126 let broker_guild = BrokerGuild {
127 id: g.id(),
128 name: g.name().to_string(),
129 icon: g.icon().map(|v| v.to_string()),
130 splash: g.splash().map(|v| v.to_string()),
131 discovery_splash: g.discovery_splash().map(|v| v.to_string()),
132 owner_id: g.owner_id(),
133 afk_channel_id: g.afk_channel_id(),
134 afk_timeout: g.afk_timeout().get() as u64,
135 verification_level: g.verification_level(),
136 explicit_content_filter: g.explicit_content_filter(),
137 mfa_level: g.mfa_level(),
138 application_id: g.application_id(),
139 system_channel_id: g.system_channel_id(),
140 widget_enabled: g.widget_enabled(),
141 widget_channel_id: g.widget_channel_id(),
142 rules_channel_id: g.rules_channel_id(),
143 preferred_locale: g.preferred_locale().to_string(),
144 premium_tier: g.premium_tier(),
145 premium_subscription_count: g.premium_subscription_count(),
146 banner: g.banner().map(|v| v.to_string()),
147 default_message_notifications: g.default_message_notifications(),
148 description: g.description().map(|v| v.to_string()),
149 features: g
150 .features()
151 .map(|v| Cow::from(v.clone()).to_string())
152 .collect(),
153 joined_at: g.joined_at(),
154 large: g.large(),
155 max_members: g.max_members(),
156 max_presences: g.max_presences(),
157 member_count: g.member_count(),
158 nsfw_level: g.nsfw_level(),
159 owner: g.owner(),
160 permissions: g.permissions(),
161 premium_progress_bar_enabled: g.premium_progress_bar_enabled(),
162 system_channel_flags: g.system_channel_flags(),
163 unavailable: g.unavailable().unwrap_or(false),
164 vanity_url_code: g.vanity_url_code().map(|v| v.to_owned()),
165 };
166
167 return Ok(Json(broker_guild));
168 }
169
170 Err(ApiError::GuildNotFound)
171}
172
173async fn handle_get_guild_voice_states(
174 Path(guild_id_u): Path<u64>,

Callers

nothing calls this directly

Calls 3

descriptionMethod · 0.80
nameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected