Readded some guild data code. fixed some weird cases with macro command. removed restrict command. changed db to be 'as it was'. removed execution limiters since commands are quite heavily ratelimited anyway

This commit is contained in:
2021-10-30 20:57:33 +01:00
parent db7cca6296
commit 72228911f2
12 changed files with 150 additions and 368 deletions

View File

@ -14,17 +14,20 @@ impl CommandMacro {
let pool = ctx.data.read().await.get::<SQLPool>().cloned().unwrap();
let guild_id = guild_id.into();
sqlx::query!("SELECT * FROM macro WHERE guild_id = ?", guild_id.0)
.fetch_all(&pool)
.await
.unwrap()
.iter()
.map(|row| Self {
guild_id: GuildId(row.guild_id),
name: row.name.clone(),
description: row.description.clone(),
commands: serde_json::from_str(&row.commands).unwrap(),
})
.collect::<Vec<Self>>()
sqlx::query!(
"SELECT * FROM macro WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?)",
guild_id.0
)
.fetch_all(&pool)
.await
.unwrap()
.iter()
.map(|row| Self {
guild_id,
name: row.name.clone(),
description: row.description.clone(),
commands: serde_json::from_str(&row.commands).unwrap(),
})
.collect::<Vec<Self>>()
}
}