You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5 KiB
Rust

// use serenity::async_trait;
use serenity::model::channel::Message;
// use serenity::model::gateway::Ready;
use serenity::prelude::*;
use serenity::model::prelude::*;
use crate::utils;
pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
{
if server_id == utils::ADMIN_SERVER_ID
{
if msg.content == ".log_test"
{
utils::Logger::log_message(ctx, "This is a test log message!").await;
return;
}
if msg.content == ".shutdown"
{
return;
}
}
let command_lower = msg.content.to_lowercase();
let mut command_iter = command_lower.split_whitespace();
let command_start = command_iter.next();
if command_start == Some(".argstest")
{
if let Some(arg) = command_iter.next()
{
match arg
{
"red" => utils::send_msg(ctx, msg.channel_id, "arg was red!").await,
_ => utils::Logger::log_error(ctx, &format!("unknown .argstest argument: {}", arg)).await
};
}
return;
}
if msg.content == ".role_test"
{
let test_role = RoleId(1129106677619228702 as u64);
match utils::add_role(ctx.clone(), msg.author.id, test_role, server_id).await
{
Ok(role) => utils::send_msg(ctx, msg.channel_id, &format!("Added role {:?}", role.name)).await,
Err(why) => utils::Logger::log_error(ctx, &format!("failed to add role to user - {}", why)).await,
}
return;
}
}