|
|
|
|
|
|
|
|
|
use serenity::prelude::*;
|
|
|
|
|
use serenity::model::prelude::*;
|
|
|
|
|
use serenity::model::channel::Message;
|
|
|
|
|
|
|
|
|
|
use crate::{utils, Owner};
|
|
|
|
|
|
|
|
|
|
const SM_TEST_CHANNEL_ID: u64 = 280548893135994880;
|
|
|
|
|
const BEL_WORK_USER_ID: u64 = 474259726427750420;
|
|
|
|
|
|
|
|
|
|
// COLOR ROLE IDS
|
|
|
|
|
const ROLE_ID_RED: u64 = 279338933748236289;
|
|
|
|
|
const ROLE_ID_GREEN: u64 = 279338847102566400;
|
|
|
|
|
const ROLE_ID_BLUE: u64 = 279338904526782464;
|
|
|
|
|
const ROLE_ID_YELLOW: u64 = 279339011921805312;
|
|
|
|
|
const ROLE_ID_PINK: u64 = 279339051444862976;
|
|
|
|
|
const ROLE_ID_ORANGE: u64 = 279339077382438912;
|
|
|
|
|
const ROLE_ID_PURPLE: u64 = 284310454908747787;
|
|
|
|
|
|
|
|
|
|
// RACE ROLE IDS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if handle_meme(ctx.clone(), msg.clone()).await
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let command_lower = msg.content.to_lowercase();
|
|
|
|
|
let mut command_iter = command_lower.split_whitespace();
|
|
|
|
|
let command_start = command_iter.next();
|
|
|
|
|
|
|
|
|
|
let data = ctx.data.read().await;
|
|
|
|
|
let owner_id = match data.get::<Owner>()
|
|
|
|
|
{
|
|
|
|
|
Some(o) => o.load(std::sync::atomic::Ordering::Relaxed),
|
|
|
|
|
None => { utils::Logger::log_error(ctx.clone(), &format!("Couldn't get bot owner id")).await; return; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (UserId::from(owner_id) == msg.author.id || UserId::from(BEL_WORK_USER_ID) == msg.author.id) && command_start == Some(".dotestmsg")
|
|
|
|
|
{
|
|
|
|
|
if let Some(msg) = utils::send_msg(ctx.clone(), ChannelId::from(SM_TEST_CHANNEL_ID), "Test message!").await
|
|
|
|
|
{
|
|
|
|
|
println!("Test message id is: {:#?}", msg.id)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
println!("Failed to get test message id");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if command_start == Some(".randomizer")
|
|
|
|
|
{
|
|
|
|
|
let item = utils::get_random_item();
|
|
|
|
|
utils::send_msg(ctx.clone(), msg.channel_id, &format!("You found {}!", item)).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if command_start == Some(".colors") || command_start == Some(".color")
|
|
|
|
|
{
|
|
|
|
|
utils::send_msg(ctx.clone(), msg.channel_id, "Valid colors are: green blue red purple pink yellow orange").await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if command_start == Some(".setcolor")
|
|
|
|
|
{
|
|
|
|
|
if let Some(arg) = command_iter.next()
|
|
|
|
|
{
|
|
|
|
|
match arg
|
|
|
|
|
{
|
|
|
|
|
// TODO: add color roles
|
|
|
|
|
"red" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_RED), server_id).await; return; }
|
|
|
|
|
"green" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_GREEN), server_id).await; return; }
|
|
|
|
|
"blue" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_BLUE), server_id).await; return; }
|
|
|
|
|
"yellow" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_YELLOW), server_id).await; return; }
|
|
|
|
|
"orange" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_ORANGE), server_id).await; return; }
|
|
|
|
|
"pink" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_PINK), server_id).await; return; }
|
|
|
|
|
"purple" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_PURPLE), server_id).await; return; }
|
|
|
|
|
_ => utils::Logger::log_error(ctx.clone(), &format!("unknown .color argument: {}", arg)).await
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn handle_reaction_add(ctx: Context, reaction_add: Reaction)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////// HELPERS
|
|
|
|
|
async fn set_color(ctx: Context, msg: Message, role_id: RoleId, server_id: GuildId)
|
|
|
|
|
{
|
|
|
|
|
// Unset all color roles
|
|
|
|
|
let colors = [ROLE_ID_RED, ROLE_ID_GREEN, ROLE_ID_BLUE, ROLE_ID_YELLOW, ROLE_ID_PINK, ROLE_ID_ORANGE, ROLE_ID_PURPLE];
|
|
|
|
|
for color in colors
|
|
|
|
|
{
|
|
|
|
|
if let Err(why) = utils::remove_role(ctx.clone(), msg.author.clone().into(), RoleId(color), server_id).await
|
|
|
|
|
{
|
|
|
|
|
utils::send_msg(ctx.clone(), msg.channel_id, &format!("Could not set color")).await;
|
|
|
|
|
utils::Logger::log_error(ctx.clone(), &format!("set_color failed - could not remove other color roles: {}", why)).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Set requested color role
|
|
|
|
|
match utils::add_role(ctx.clone(), msg.author.into(), role_id, server_id).await
|
|
|
|
|
{
|
|
|
|
|
Ok(role) =>
|
|
|
|
|
{
|
|
|
|
|
utils::send_msg(ctx.clone(), msg.channel_id, &format!("Added role: {}", role.name)).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Err(why) =>
|
|
|
|
|
{
|
|
|
|
|
utils::send_msg(ctx.clone(), msg.channel_id, &format!("Could not set color role")).await;
|
|
|
|
|
utils::Logger::log_error(ctx.clone(), &format!("set_color: Failed to set color role: {}", why)).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async fn handle_meme(ctx: Context, msg: Message) -> bool
|
|
|
|
|
{
|
|
|
|
|
let command_lower = msg.content.to_lowercase();
|
|
|
|
|
|
|
|
|
|
match command_lower.as_str()
|
|
|
|
|
{
|
|
|
|
|
".godwin" => { utils::send_msg(ctx, msg.channel_id, "https://imgur.com/1MVRQsc").await; return true }
|
|
|
|
|
".beer" => { utils::send_msg(ctx, msg.channel_id, "https://www.youtube.com/watch?v=IZVHBMCdXIw").await; return true }
|
|
|
|
|
".beeer" => { utils::send_msg(ctx, msg.channel_id, "https://youtu.be/nPtMHSYtPc4").await; return true }
|
|
|
|
|
".ivan" => { utils::send_msg(ctx, msg.channel_id, "http://i.imgur.com/0sjR5lE.jpg").await; return true }
|
|
|
|
|
".hotdog" => { utils::send_msg(ctx, msg.channel_id, "https://www.youtube.com/watch?v=ZXVhOPiM4mk").await; return true }
|
|
|
|
|
".edu" => { utils::send_msg(ctx, msg.channel_id, "<:ThisIsFine:243880310859759616> http://imgur.com/1STAzsl").await; return true }
|
|
|
|
|
".gari" => { utils::send_msg(ctx, msg.channel_id, "http://i.imgur.com/EYAti0a.jpg").await; return true }
|
|
|
|
|
".deerforce" => { utils::send_msg(ctx, msg.channel_id, "https://i.imgur.com/PSxFfku.png").await; return true }
|
|
|
|
|
_ => { return false; }
|
|
|
|
|
}
|
|
|
|
|
}
|