blacklist stuff

This commit is contained in:
jude
2020-08-25 17:19:08 +01:00
parent e5334af999
commit afe3dbc525
3 changed files with 24 additions and 12 deletions

View File

@ -18,20 +18,21 @@ use crate::{
#[command]
#[supports_dm(false)]
#[permission_level(Restricted)]
#[can_blacklist(false)]
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");
let mut channel = ChannelData::from_id(msg.channel(&ctx).await.unwrap(), pool.clone()).await.unwrap();
let mut channel = ChannelData::from_channel(msg.channel(&ctx).await.unwrap(), pool.clone()).await.unwrap();
channel.blacklisted = !channel.blacklisted;
channel.commit_changes(pool).await;
if channel.blacklisted {
let _ = msg.channel_id.say(&ctx, "Blacklisted").await;
}
else {
let _ = msg.channel_id.say(&ctx, "Unblacklisted").await;
}
Ok(())