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

Method discord_edit_message

components/runtime/src/extensions/discord.rs:599–656  ·  view source on GitHub ↗
(
        &self,
        args: OpEditChannelMessage,
    )

Source from the content-addressed store, hash-verified

597 }
598
599 async fn discord_edit_message(
600 &self,
601 args: OpEditChannelMessage,
602 ) -> Result<Message, anyhow::Error> {
603 let rt_ctx = get_rt_ctx(&self.state);
604
605 let channel = parse_get_guild_channel(&self.state, &rt_ctx, &args.channel_id).await?;
606 let message_id = parse_str_snowflake_id(&args.message_id)?;
607 let attachments = convert_attachments(args.fields.attachments.unwrap_or_default())?;
608
609 let res = discord_request_with_extra_error(&self.state, async move {
610 let maybe_embeds = args
611 .fields
612 .embeds
613 .map(|inner| inner.into_iter().map(Into::into).collect::<Vec<_>>());
614
615 let components = args
616 .fields
617 .components
618 .map(|inner| {
619 inner
620 .into_iter()
621 .map(TryInto::try_into)
622 .collect::<Result<Vec<_>, _>>()
623 })
624 .transpose()?;
625
626 let mut mc = rt_ctx
627 .discord_config
628 .client
629 .update_message(channel.id, message_id.cast())
630 .content(args.fields.content.as_deref());
631
632 if let Some(flags) = &args.fields.flags {
633 mc = mc.flags(flags.clone().into());
634 }
635
636 mc = mc.components(components.as_deref());
637
638 if let Some(embeds) = &maybe_embeds {
639 mc = mc.embeds(Some(embeds));
640 }
641
642 let mentions = args.fields.allowed_mentions.map(Into::into);
643 if mentions.is_some() {
644 mc = mc.allowed_mentions(mentions.as_ref());
645 }
646
647 if !attachments.is_empty() {
648 mc = mc.attachments(&attachments);
649 }
650
651 Ok(mc.await)
652 })
653 .await?;
654
655 res.model().await?.try_into()
656 }

Callers

nothing calls this directly

Calls 5

get_rt_ctxFunction · 0.85
parse_get_guild_channelFunction · 0.85
parse_str_snowflake_idFunction · 0.85
convert_attachmentsFunction · 0.85

Tested by

no test coverage detected