|
|
|
@ -3,7 +3,9 @@ use serenity::prelude::*;
|
|
|
|
use serenity::model::prelude::*;
|
|
|
|
use serenity::model::prelude::*;
|
|
|
|
use serenity::model::channel::Message;
|
|
|
|
use serenity::model::channel::Message;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::utils;
|
|
|
|
use crate::{utils, Owner};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const SM_TEST_CHANNEL_ID: u64 = 280548893135994880;
|
|
|
|
|
|
|
|
|
|
|
|
// COLOR ROLE IDS
|
|
|
|
// COLOR ROLE IDS
|
|
|
|
const ROLE_ID_RED: u64 = 279338933748236289;
|
|
|
|
const ROLE_ID_RED: u64 = 279338933748236289;
|
|
|
|
@ -14,6 +16,9 @@ const ROLE_ID_PINK: u64 = 279339051444862976;
|
|
|
|
const ROLE_ID_ORANGE: u64 = 279339077382438912;
|
|
|
|
const ROLE_ID_ORANGE: u64 = 279339077382438912;
|
|
|
|
const ROLE_ID_PURPLE: u64 = 284310454908747787;
|
|
|
|
const ROLE_ID_PURPLE: u64 = 284310454908747787;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// RACE ROLE IDS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
|
|
|
|
pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -27,17 +32,36 @@ pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
|
|
|
|
let mut command_iter = command_lower.split_whitespace();
|
|
|
|
let mut command_iter = command_lower.split_whitespace();
|
|
|
|
let command_start = command_iter.next();
|
|
|
|
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 && 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")
|
|
|
|
if command_start == Some(".randomizer")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let item = utils::get_random_item();
|
|
|
|
let item = utils::get_random_item();
|
|
|
|
utils::send_msg(ctx, msg.channel_id, &format!("You found {}!", item)).await;
|
|
|
|
utils::send_msg(ctx.clone(), msg.channel_id, &format!("You found {}!", item)).await;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if command_start == Some(".colors") || command_start == Some(".color")
|
|
|
|
if command_start == Some(".colors") || command_start == Some(".color")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
utils::send_msg(ctx, msg.channel_id, "Valid colors are: green blue red purple pink yellow orange").await;
|
|
|
|
utils::send_msg(ctx.clone(), msg.channel_id, "Valid colors are: green blue red purple pink yellow orange").await;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -48,20 +72,25 @@ pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
|
|
|
|
match arg
|
|
|
|
match arg
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO: add color roles
|
|
|
|
// TODO: add color roles
|
|
|
|
"red" => { set_color(ctx, msg, RoleId(ROLE_ID_RED), server_id).await; return; }
|
|
|
|
"red" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_RED), server_id).await; return; }
|
|
|
|
"green" => { set_color(ctx, msg, RoleId(ROLE_ID_GREEN), server_id).await; return; }
|
|
|
|
"green" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_GREEN), server_id).await; return; }
|
|
|
|
"blue" => { set_color(ctx, msg, RoleId(ROLE_ID_BLUE), server_id).await; return; }
|
|
|
|
"blue" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_BLUE), server_id).await; return; }
|
|
|
|
"yellow" => { set_color(ctx, msg, RoleId(ROLE_ID_YELLOW), server_id).await; return; }
|
|
|
|
"yellow" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_YELLOW), server_id).await; return; }
|
|
|
|
"orange" => { set_color(ctx, msg, RoleId(ROLE_ID_ORANGE), server_id).await; return; }
|
|
|
|
"orange" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_ORANGE), server_id).await; return; }
|
|
|
|
"pink" => { set_color(ctx, msg, RoleId(ROLE_ID_PINK), server_id).await; return; }
|
|
|
|
"pink" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_PINK), server_id).await; return; }
|
|
|
|
"purple" => { set_color(ctx, msg, RoleId(ROLE_ID_PURPLE), server_id).await; return; }
|
|
|
|
"purple" => { set_color(ctx.clone(), msg, RoleId(ROLE_ID_PURPLE), server_id).await; return; }
|
|
|
|
_ => utils::Logger::log_error(ctx, &format!("unknown .color argument: {}", arg)).await
|
|
|
|
_ => utils::Logger::log_error(ctx.clone(), &format!("unknown .color argument: {}", arg)).await
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub async fn handle_reaction_add(ctx: Context, reaction_add: Reaction)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////// HELPERS
|
|
|
|
///////////////////// HELPERS
|
|
|
|
async fn set_color(ctx: Context, msg: Message, role_id: RoleId, server_id: GuildId)
|
|
|
|
async fn set_color(ctx: Context, msg: Message, role_id: RoleId, server_id: GuildId)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|