Updated query builder with bindings

This commit is contained in:
2024-12-21 22:31:11 -05:00
parent 7718cf19c3
commit 2cd2715d0d
8 changed files with 169 additions and 86 deletions

View File

@@ -89,9 +89,7 @@ pub async fn enqueue_track(
let mut playlist_items: Vec<YtDlpItem> = Vec::new();
if let Some(handler_lock) = manager.get(guild_id) {
let mut handler = handler_lock.lock().await;
let guild = GuildCache::find_by_id(guild_id.get() as i64)
.await?
.unwrap();
let guild = GuildCache::find_by_id(guild_id.get() as i64).await.unwrap();
let valid = is_valid_url(&track_url);
// Check if the URL is valid

View File

@@ -64,10 +64,7 @@ pub async fn set_volume(manager: &Arc<Songbird>, guild_id: &GuildId, volume: i32
let bound_volume = volume as f32 / 100.0;
// Update the guild cache
let mut guild_cache = GuildCache::find_by_id(guild_id.get() as i64)
.await
.unwrap()
.unwrap();
let mut guild_cache = GuildCache::find_by_id(guild_id.get() as i64).await.unwrap();
guild_cache.volume = volume;
guild_cache.update().await.unwrap();

View File

@@ -66,7 +66,6 @@ pub async fn run(ctx: &Context, command: &CommandInteraction) {
None => edit_response(&ctx, &command, format!("🎲 {}\n-# {}", total, response)).await,
};
// Check for dice tracks
}
Err(why) => {
edit_response(&ctx, &command, format!("Invalid dice string: {}", why)).await;
@@ -161,17 +160,23 @@ pub fn parse_dice(dice: &str) -> SirenResult<(u32, u32, i32)> {
if [4, 6, 8, 10, 12, 20, 100].contains(&n) {
n
} else {
return Err(Error::new(400, format!(
"Expected one of d4, d6, d8, d10, d12, d20, d100 but received d{}",
n
)));
return Err(Error::new(
400,
format!(
"Expected one of d4, d6, d8, d10, d12, d20, d100 but received d{}",
n
),
));
}
}
Err(_) => {
return Err(Error::new(400, format!(
"Expected one of d4, d6, d8, d10, d12, d20, d100 but received d{}",
sides_part
)))
return Err(Error::new(
400,
format!(
"Expected one of d4, d6, d8, d10, d12, d20, d100 but received d{}",
sides_part
),
))
}
};

View File

@@ -116,7 +116,7 @@ impl EventHandler for BotHandler {
for guild in ready.guilds {
// Check if guild exists in database
let guild_id = guild.id.get() as i64;
if let None = GuildCache::find_by_id(guild_id).await.unwrap() {
if let None = GuildCache::find_by_id(guild_id).await {
let guild_cache = GuildCache {
id: guild_id,
name: guild.id.name(&ctx.cache),