feat: unset a channel as a logger

Closes #3
This commit is contained in:
2023-11-23 22:36:10 +01:00
parent 3bcef90fb9
commit 592604aaa8
2 changed files with 63 additions and 8 deletions

View File

@@ -39,7 +39,9 @@ WHERE guild_id = ?1
.fetch_all(&self.pool)
.await
.map_err(|e| {
error!("Error getting logging channels for guild {guild_id}: {e:?}");
error!(
"Error getting logging channels for guild {guild_id}: {e:?}"
);
e
})?;
Ok(channels.iter().map(|id| id.channel_id as u64).collect())
@@ -70,4 +72,27 @@ VALUES ( ?1, ?2 )
})
.map(|_| ())
}
pub async fn remove_logging_channel(
&self,
guild_id: GuildId,
channel_id: ChannelId,
) -> Result<()> {
let guild_id = guild_id.0 as i64;
let channel_id = channel_id.0 as i64;
let mut conn = self.pool.acquire().await?;
sqlx::query!(r#"
DELETE FROM guild_log_channels
WHERE guild_id = ?1 AND channel_id = ?2
"#,
guild_id,
channel_id)
.execute(&mut *conn)
.await
.map_err(|e| {
error!("Error removing channel {channel_id} as a logger for guild {guild_id}: {e:?}");
e
})
.map(|_| ())
}
}