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

Method try_from

components/runtime-models/src/internal/channel.rs:35–66  ·  view source on GitHub ↗
(v: twilight_model::channel::Channel)

Source from the content-addressed store, hash-verified

33 type Error = anyhow::Error;
34
35 fn try_from(v: twilight_model::channel::Channel) -> Result<Self, anyhow::Error> {
36 match v.kind {
37 TwilightChannelType::GuildCategory => Ok(Self::Category(v.try_into()?)),
38 TwilightChannelType::AnnouncementThread => {
39 Ok(Self::NewsThread(Box::new(v.try_into()?)))
40 }
41 TwilightChannelType::PrivateThread => Ok(Self::PrivateThread(Box::new(v.try_into()?))),
42 TwilightChannelType::PublicThread => Ok(Self::PublicThread(Box::new(v.try_into()?))),
43
44 TwilightChannelType::GuildText | TwilightChannelType::GuildAnnouncement => {
45 Ok(Self::Text(v.try_into()?))
46 }
47
48 TwilightChannelType::GuildVoice => Ok(Self::Voice(v.try_into()?)),
49 TwilightChannelType::GuildStageVoice => Ok(Self::Stage(v.try_into()?)),
50
51 TwilightChannelType::Private => {
52 panic!("Bot does not support private channels, we should never reach this path")
53 }
54 TwilightChannelType::Group => {
55 panic!("Bot does not support private channels, we should never reach this path")
56 }
57 TwilightChannelType::GuildDirectory => Ok(Self::GuildDirectory(v.try_into()?)),
58 TwilightChannelType::GuildMedia | TwilightChannelType::GuildForum => {
59 Ok(Self::Forum(v.try_into()?))
60 }
61 other => Err(anyhow::anyhow!(
62 "Unimplemented channel type {}",
63 u8::from(other)
64 )),
65 }
66 }
67}
68
69#[derive(Clone, Debug, Serialize, TS)]

Callers

nothing calls this directly

Calls 4

NotBigU64Class · 0.85
NewsThreadClass · 0.70
PrivateThreadClass · 0.70
PublicThreadClass · 0.70

Tested by

no test coverage detected