-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
52 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use anyhow::Context; | ||
use serenity::{ | ||
http::Http, | ||
model::prelude::{ChannelId, GuildChannel, GuildId}, | ||
}; | ||
use std::sync::Arc; | ||
|
||
pub async fn get_channel( | ||
channel_id: ChannelId, | ||
guild_id: GuildId, | ||
http: &Arc<Http>, | ||
) -> anyhow::Result<GuildChannel> { | ||
let guild_channels = guild_id | ||
.channels(&http) | ||
.await | ||
.context("チャンネルリストの取得に失敗しました")?; | ||
|
||
let channel = match guild_channels.get(&channel_id) { | ||
Some(channel) => channel.clone(), | ||
None => { | ||
let guild_threads = guild_id.get_active_threads(http).await?; | ||
let thread = match guild_threads.threads.iter().find(|c| c.id == channel_id) { | ||
Some(channel) => channel.clone(), | ||
None => { | ||
return Err(anyhow::anyhow!("引用元チャンネルは見つかりませんでした.")); | ||
} | ||
}; | ||
thread | ||
} | ||
}; | ||
|
||
Ok(channel) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pub mod cache; | ||
pub mod channel; | ||
pub mod embed; | ||
pub mod message; |