(
&self,
arg: OpExecuteWebhook,
)
| 1524 | |
| 1525 | #[allow(async_fn_in_trait)] |
| 1526 | async fn discord_webhook_execute( |
| 1527 | &self, |
| 1528 | arg: OpExecuteWebhook, |
| 1529 | ) -> Result<Message, anyhow::Error> { |
| 1530 | let rt_ctx = get_rt_ctx(&self.state); |
| 1531 | |
| 1532 | let parsed_id: Id<WebhookMarker> = parse_str_snowflake_id(&arg.webhook_id)?.cast(); |
| 1533 | |
| 1534 | let attachments = convert_attachments(arg.fields.attachments.unwrap_or_default())?; |
| 1535 | |
| 1536 | let message = discord_request_any(&self.state, async move { |
| 1537 | let maybe_embeds = arg |
| 1538 | .fields |
| 1539 | .embeds |
| 1540 | .unwrap_or_default() |
| 1541 | .into_iter() |
| 1542 | .map(Into::into) |
| 1543 | .collect::<Vec<_>>(); |
| 1544 | |
| 1545 | let components = arg |
| 1546 | .fields |
| 1547 | .components |
| 1548 | .unwrap_or_default() |
| 1549 | .into_iter() |
| 1550 | .map(TryInto::try_into) |
| 1551 | .collect::<Result<Vec<_>, _>>()?; |
| 1552 | |
| 1553 | let mut mc = rt_ctx |
| 1554 | .discord_config |
| 1555 | .client |
| 1556 | .execute_webhook(parsed_id, &arg.token) |
| 1557 | .embeds(&maybe_embeds) |
| 1558 | .components(&components); |
| 1559 | |
| 1560 | if let Some(content) = &arg.fields.content { |
| 1561 | mc = mc.content(content) |
| 1562 | } |
| 1563 | |
| 1564 | let mentions = arg.fields.allowed_mentions.map(Into::into); |
| 1565 | if mentions.is_some() { |
| 1566 | mc = mc.allowed_mentions(mentions.as_ref()); |
| 1567 | } |
| 1568 | |
| 1569 | if attachments.len() > 0 { |
| 1570 | mc = mc.attachments(&attachments); |
| 1571 | } |
| 1572 | |
| 1573 | if let Some(avatar_url) = &arg.avatar_url { |
| 1574 | mc = mc.avatar_url(avatar_url) |
| 1575 | } |
| 1576 | |
| 1577 | if let Some(username) = &arg.username { |
| 1578 | mc = mc.username(username) |
| 1579 | } |
| 1580 | |
| 1581 | Ok(mc.wait().await?.model().await?) |
| 1582 | }) |
| 1583 | .await?; |
nothing calls this directly
no test coverage detected