Compare commits

..

No commits in common. "090223388d59fa907bb3bd3fc679aa3cb10458a7" and "751bc8aca549edbf58fde239c752d1bf33651b16" have entirely different histories.

4 changed files with 11 additions and 11 deletions

View File

@ -1,8 +1,6 @@
use built::chrono;
use manifold::error::{ManifoldError, ManifoldResult}; use manifold::error::{ManifoldError, ManifoldResult};
use manifold::{ManifoldContext, ManifoldData}; use manifold::{ManifoldContext, ManifoldData};
use poise::serenity_prelude as serenity; use poise::serenity_prelude as serenity;
use crate::badgey::models::quarantine_channel::QuarantineChannel;
#[poise::command(slash_command, prefix_command, required_permissions = "MODERATE_MEMBERS")] #[poise::command(slash_command, prefix_command, required_permissions = "MODERATE_MEMBERS")]
async fn void_user(_ctx: ManifoldContext<'_>, _target: serenity::User) -> ManifoldResult<()> { async fn void_user(_ctx: ManifoldContext<'_>, _target: serenity::User) -> ManifoldResult<()> {
@ -41,18 +39,16 @@ async fn add_quarantine_channel(ctx: ManifoldContext<'_>, channel: serenity::Cha
let qc = QuarantineChannel::new(role.as_u64().clone() as i64, channel.as_u64().clone() as i64); let qc = QuarantineChannel::new(role.as_u64().clone() as i64, channel.as_u64().clone() as i64);
qc.insert(&ctx.data().database)?; qc.insert(&ctx.data().database)?;
ctx.reply(format!("OK: Quarantine channel {channel} defined with quarantine role {role}", channel = channel, role = role)).await?; ctx.reply(format!("Quarantine channel {channel} defined with quarantine role {role}", channel = channel, role = role)).await?;
Ok(()) Ok(())
} }
#[poise::command(slash_command, prefix_command, required_permissions = "MANAGE_GUILD")] #[poise::command(slash_command, prefix_command, required_permissions = "MANAGE_GUILD")]
async fn remove_quarantine_channel(ctx: ManifoldContext<'_>, channel: serenity::ChannelId) -> ManifoldResult<()> { async fn remove_quarantine_channel(ctx: ManifoldContext<'_>, channel: serenity::ChannelId) -> ManifoldResult<()> {
let qc = QuarantineChannel::get(&ctx.data().database, channel.as_u64().clone() as i64)?;
let db = &ctx.data().database; ctx.reply(format!("Quarantine channel {channel} is no longer defined.", channel = channel)).await?;
QuarantineChannel::get(db, channel.as_u64().clone() as i64)?.remove(db)?;
ctx.reply(format!("OK: Quarantine channel {channel} is no longer defined.", channel = channel)).await?;
Ok(()) Ok(())
} }

View File

@ -1,3 +1,4 @@
use built::chrono;
use manifold::error::{ManifoldError, ManifoldResult}; use manifold::error::{ManifoldError, ManifoldResult};
use manifold::events::EventHandler; use manifold::events::EventHandler;
use manifold::ManifoldData; use manifold::ManifoldData;
@ -6,7 +7,8 @@ use poise::serenity_prelude::{Context, Member, Message};
use crate::badgey::handlers; use crate::badgey::handlers;
use crate::badgey::models::custom_response::CustomResponse; use crate::badgey::models::custom_response::CustomResponse;
use crate::badgey::models::xp::Xp; use crate::badgey::models::xp::{Rank, Xp};
pub struct BadgeyHandler { pub struct BadgeyHandler {

View File

@ -1,7 +1,8 @@
use std::collections::HashMap;
use manifold::error::{ManifoldError, ManifoldResult}; use manifold::error::{ManifoldError, ManifoldResult};
use manifold::ManifoldData; use manifold::ManifoldData;
use poise::FrameworkContext; use poise::FrameworkContext;
use poise::serenity_prelude::{ChannelId, Context, Member, Mentionable}; use poise::serenity_prelude::{ChannelId, Context, Member, Mentionable, RoleId};
use crate::badgey::models::quarantine_channel::QuarantineChannel; use crate::badgey::models::quarantine_channel::QuarantineChannel;

View File

@ -1,4 +1,5 @@
use diesel::{insert_into, Identifiable, Insertable, QueryDsl, Queryable, RunQueryDsl, Selectable}; use diesel::{insert_into, Identifiable, Insertable, QueryDsl, Queryable, RunQueryDsl, Selectable};
use diesel::associations::HasTable;
use diesel::dsl::delete; use diesel::dsl::delete;
use diesel::prelude::*; use diesel::prelude::*;
use manifold::Db; use manifold::Db;
@ -31,9 +32,9 @@ impl QuarantineChannel {
.map_err(|e| ManifoldError::from(e)) .map_err(|e| ManifoldError::from(e))
} }
pub fn remove(&self, conn: &Db) -> ManifoldResult<usize> { pub fn remove(&self, conn: &Db, needle: i64) -> ManifoldResult<usize> {
Ok(delete(quarantine_table::dsl::quarantine_channels) Ok(delete(quarantine_table::dsl::quarantine_channels)
.filter(quarantine_table::qc_role_id.eq(self.qc_role_id)) .filter(quarantine_table::qc_role_id.eq(needle))
.execute(&mut conn.get()?)?) .execute(&mut conn.get()?)?)
} }