moover_rust/src/util/utilities.rs

16 lines
No EOL
641 B
Rust

use std::sync::Arc;
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()));
}
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;
}