Clean up merge, finish delete, clean up warnings
This commit is contained in:
parent
751bc8aca5
commit
2bcf7c8d42
|
|
@ -1,6 +1,8 @@
|
||||||
|
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<()> {
|
||||||
|
|
@ -39,16 +41,18 @@ 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!("Quarantine channel {channel} defined with quarantine role {role}", channel = channel, role = role)).await?;
|
ctx.reply(format!("OK: 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)?;
|
|
||||||
|
|
||||||
ctx.reply(format!("Quarantine channel {channel} is no longer defined.", channel = channel)).await?;
|
let db = &ctx.data().database;
|
||||||
|
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(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
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;
|
||||||
|
|
@ -7,8 +6,7 @@ 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::{Rank, Xp};
|
use crate::badgey::models::xp::Xp;
|
||||||
|
|
||||||
|
|
||||||
pub struct BadgeyHandler {
|
pub struct BadgeyHandler {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
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, RoleId};
|
use poise::serenity_prelude::{ChannelId, Context, Member, Mentionable};
|
||||||
|
|
||||||
use crate::badgey::models::quarantine_channel::QuarantineChannel;
|
use crate::badgey::models::quarantine_channel::QuarantineChannel;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
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;
|
||||||
|
|
@ -32,9 +31,9 @@ impl QuarantineChannel {
|
||||||
.map_err(|e| ManifoldError::from(e))
|
.map_err(|e| ManifoldError::from(e))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove(&self, conn: &Db, needle: i64) -> ManifoldResult<usize> {
|
pub fn remove(&self, conn: &Db) -> ManifoldResult<usize> {
|
||||||
Ok(delete(quarantine_table::dsl::quarantine_channels)
|
Ok(delete(quarantine_table::dsl::quarantine_channels)
|
||||||
.filter(quarantine_table::qc_role_id.eq(needle))
|
.filter(quarantine_table::qc_role_id.eq(self.qc_role_id))
|
||||||
.execute(&mut conn.get()?)?)
|
.execute(&mut conn.get()?)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue