Wip commit

This commit is contained in:
jude
2024-01-06 19:48:17 +00:00
parent cce0de7c75
commit e4e9af2bb4
37 changed files with 1051 additions and 1366 deletions

View File

@ -6,7 +6,7 @@ pub mod timer;
pub mod user_data;
use chrono_tz::Tz;
use poise::serenity_prelude::{async_trait, model::id::UserId, ChannelType};
use poise::serenity_prelude::{async_trait, model::id::UserId};
use crate::{
models::{channel_data::ChannelData, guild_data::GuildData, user_data::UserData},
@ -53,20 +53,7 @@ impl CtxData for Context<'_> {
async fn channel_data(&self) -> Result<ChannelData, Box<dyn std::error::Error + Sync + Send>> {
// If we're in a thread, get the parent channel.
let recv_channel = self.channel_id().to_channel(&self).await?;
let channel = match recv_channel.guild() {
Some(guild_channel) => {
if guild_channel.kind == ChannelType::PublicThread {
guild_channel.parent_id.unwrap().to_channel_cached(&self).unwrap()
} else {
self.channel_id().to_channel_cached(&self).unwrap()
}
}
None => self.channel_id().to_channel_cached(&self).unwrap(),
};
let channel = self.channel_id().to_channel(&self).await?;
ChannelData::from_channel(&channel, &self.data().database).await
}
@ -82,7 +69,7 @@ impl Data {
) -> Result<Vec<CommandMacro<Data, Error>>, Error> {
let rows = sqlx::query!(
"SELECT name, description, commands FROM macro WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?)",
guild_id.0
guild_id.get()
)
.fetch_all(&self.database)
.await?.iter().map(|row| CommandMacro {