2020-08-18 19:09:21 +00:00
|
|
|
use regex_command_attr::command;
|
|
|
|
|
|
|
|
use serenity::{
|
|
|
|
client::Context,
|
|
|
|
model::{
|
|
|
|
channel::{
|
|
|
|
Message,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
framework::standard::CommandResult,
|
|
|
|
};
|
|
|
|
|
2020-08-22 00:24:12 +00:00
|
|
|
use crate::{
|
|
|
|
models::ChannelData,
|
|
|
|
SQLPool,
|
|
|
|
};
|
2020-08-18 19:09:21 +00:00
|
|
|
|
|
|
|
#[command]
|
|
|
|
#[supports_dm(false)]
|
|
|
|
#[permission_level(Restricted)]
|
|
|
|
async fn blacklist(ctx: &Context, msg: &Message, args: String) -> CommandResult {
|
|
|
|
let pool = ctx.data.read().await
|
|
|
|
.get::<SQLPool>().cloned().expect("Could not get SQLPool from data");
|
|
|
|
|
2020-08-22 00:24:12 +00:00
|
|
|
let mut channel = ChannelData::from_id(msg.channel(&ctx), pool.clone()).await.unwrap();
|
|
|
|
|
|
|
|
channel.blacklisted = !channel.blacklisted;
|
|
|
|
channel.commit_changes(pool).await;
|
|
|
|
|
|
|
|
if channel.blacklisted {
|
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
}
|
2020-08-18 19:09:21 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|