(
&self,
arg: OpEditWebhook,
)
| 1410 | |
| 1411 | #[allow(async_fn_in_trait)] |
| 1412 | async fn discord_webhook_edit( |
| 1413 | &self, |
| 1414 | arg: OpEditWebhook, |
| 1415 | ) -> Result<DiscordWebhook, anyhow::Error> { |
| 1416 | let rt_ctx = get_rt_ctx(&self.state); |
| 1417 | |
| 1418 | let parsed_id = parse_discord_id(&arg.webhook_id)?; |
| 1419 | |
| 1420 | let webhook = discord_request_any(&self.state, async move { |
| 1421 | let webhook = rt_ctx |
| 1422 | .discord_config |
| 1423 | .client |
| 1424 | .webhook(parsed_id) |
| 1425 | .await? |
| 1426 | .model() |
| 1427 | .await?; |
| 1428 | if webhook.guild_id != Some(rt_ctx.guild_id) { |
| 1429 | return Err(anyhow!("This webhook does not belong to this server")); |
| 1430 | } |
| 1431 | |
| 1432 | let mut req = rt_ctx.discord_config.client.update_webhook(parsed_id); |
| 1433 | |
| 1434 | if let Some(icon) = &arg.icon { |
| 1435 | req = req.avatar(icon.as_deref()) |
| 1436 | } |
| 1437 | |
| 1438 | if let Some(name) = &arg.name { |
| 1439 | req = req.name(&name) |
| 1440 | } |
| 1441 | |
| 1442 | if let Some(channel_id) = &arg.channel_id { |
| 1443 | let parsed_channel_id = parse_discord_id(&channel_id)?; |
| 1444 | req = req.channel_id(parsed_channel_id) |
| 1445 | } |
| 1446 | |
| 1447 | Ok(req.await?) |
| 1448 | }) |
| 1449 | .await? |
| 1450 | .model() |
| 1451 | .await?; |
| 1452 | |
| 1453 | Ok(webhook.into()) |
| 1454 | } |
| 1455 | |
| 1456 | #[allow(async_fn_in_trait)] |
| 1457 | async fn discord_webhook_edit_with_token( |
nothing calls this directly
no test coverage detected