moover_rust/src/util/utilities.rs

16 lines
641 B
Rust
Raw Normal View History

use std::sync::Arc;
2024-09-28 16:39:32 +00:00
use serenity::{all::{ChannelId, CreateMessage, GuildId, Message}, http::Http};
use anyhow::Context;
pub async fn get_system_channel(guild_id: GuildId, http: Arc<Http>) -> anyhow::Result<ChannelId> {
return http.get_guild(guild_id).await?.system_channel_id
.context(format!("System channel of guild: {} not found", guild_id.get()));
2024-09-28 16:39:32 +00:00
}
pub async fn replace_msg(http: Arc<Http>, msg: Message, content: String) -> Result<Message, serenity::Error> {
msg.delete(http.clone()).await?;
return ChannelId::new(msg.channel_id.get()).send_message(http.clone(), CreateMessage::new().content(content)).await;
}