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

Function get_full_guild

components/webapi/src/routes/guilds.rs:112–155  ·  view source on GitHub ↗
(
    State(state): State<AppState>,
    Extension(current_guild): Extension<CurrentUserGuild>,
)

Source from the content-addressed store, hash-verified

110}
111
112pub async fn get_full_guild(
113 State(state): State<AppState>,
114 Extension(current_guild): Extension<CurrentUserGuild>,
115) -> ApiResult<Json<FullGuild>> {
116 let guild = state
117 .state_client
118 .get_guild(current_guild.id)
119 .await
120 .map_err(|err| {
121 error!(%err, "failed fetching guild");
122 ApiErrorResponse::InternalError
123 })?;
124
125 let Some(guild) = guild else {
126 // while this is possible due to the async nature of everything,
127 // realistically this case wont hit
128 error!("guild not found while current_guild is set");
129 return Err(ApiErrorResponse::InternalError);
130 };
131
132 let channels = state
133 .state_client
134 .get_channels(current_guild.id)
135 .await
136 .map_err(|err| {
137 error!(%err, "failed fetching guild channels");
138 ApiErrorResponse::InternalError
139 })?;
140
141 let roles = state
142 .state_client
143 .get_roles(current_guild.id)
144 .await
145 .map_err(|err| {
146 error!(%err, "failed fetching guild roles");
147 ApiErrorResponse::InternalError
148 })?;
149
150 Ok(Json(FullGuild {
151 guild,
152 channels,
153 roles,
154 }))
155}
156
157#[derive(Debug, Serialize)]
158pub struct GuildPremiumSlot {

Callers

nothing calls this directly

Calls 3

get_guildMethod · 0.80
get_channelsMethod · 0.80
get_rolesMethod · 0.80

Tested by

no test coverage detected