(
&self,
arg: OpWebhookSpecifier,
)
| 1329 | |
| 1330 | #[allow(async_fn_in_trait)] |
| 1331 | async fn discord_webhook_get( |
| 1332 | &self, |
| 1333 | arg: OpWebhookSpecifier, |
| 1334 | ) -> Result<DiscordWebhook, anyhow::Error> { |
| 1335 | let rt_ctx = get_rt_ctx(&self.state); |
| 1336 | |
| 1337 | let parsed_id = parse_str_snowflake_id(&arg.webhook_id)?; |
| 1338 | let has_provided_token = arg.token.is_some(); |
| 1339 | |
| 1340 | let webhook = discord_request(&self.state, async move { |
| 1341 | let mut req = rt_ctx.discord_config.client.webhook(parsed_id.cast()); |
| 1342 | |
| 1343 | if let Some(token) = &arg.token { |
| 1344 | req = req.token(&token) |
| 1345 | } |
| 1346 | |
| 1347 | req.await |
| 1348 | }) |
| 1349 | .await? |
| 1350 | .model() |
| 1351 | .await?; |
| 1352 | |
| 1353 | if !has_provided_token { |
| 1354 | if webhook.guild_id != Some(rt_ctx.guild_id) { |
| 1355 | return Err(anyhow!("This webhook does not belong to this server")); |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | Ok(webhook.into()) |
| 1360 | } |
| 1361 | |
| 1362 | #[allow(async_fn_in_trait)] |
| 1363 | async fn discord_webhook_get_guild( |
nothing calls this directly
no test coverage detected