|
|
|
|
// use serenity::async_trait;
|
|
|
|
|
use serenity::prelude::*;
|
|
|
|
|
use serenity::model::channel::{Message, Reaction};
|
|
|
|
|
// use serenity::model::gateway::Ready;
|
|
|
|
|
// use serenity::model::prelude::*;
|
|
|
|
|
|
|
|
|
|
pub mod test;
|
|
|
|
|
pub mod admin;
|
|
|
|
|
pub mod sm_server;
|
|
|
|
|
|
|
|
|
|
use crate::utils;
|
|
|
|
|
|
|
|
|
|
pub async fn initialize(_ctx: Context) -> Result<(), String>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn parse(ctx: Context, msg: Message)
|
|
|
|
|
{
|
|
|
|
|
if let Some(server_id) = msg.guild_id
|
|
|
|
|
{
|
|
|
|
|
// This is not a command
|
|
|
|
|
if msg.content.len() == 0 || msg.content.chars().nth(0) != Some('.')
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if server_id == utils::ADMIN_SERVER_ID && msg.channel_id == utils::ADMIN_COMMAND_CHANNEL_ID
|
|
|
|
|
{
|
|
|
|
|
test::parse_command(ctx, msg, server_id).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if server_id == utils::SM_SERVER_ID
|
|
|
|
|
{
|
|
|
|
|
sm_server::parse_command(ctx, msg, server_id).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
utils::Logger::log_message(ctx, &format!("DM Received from {}: {}", msg.author.name, msg.content)).await;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn handle_reaction_add(ctx: Context, add_reaction: Reaction)
|
|
|
|
|
{
|
|
|
|
|
if let Some(server_id) = add_reaction.guild_id
|
|
|
|
|
{
|
|
|
|
|
if server_id == utils::ADMIN_SERVER_ID && add_reaction.channel_id == utils::ADMIN_COMMAND_CHANNEL_ID
|
|
|
|
|
{
|
|
|
|
|
//test::handle_reaction_add(ctx, add_reaction, server_id).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if server_id == utils::SM_SERVER_ID
|
|
|
|
|
{
|
|
|
|
|
sm_server::handle_reaction_add(ctx, add_reaction).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn handle_reaction_remove(ctx: Context, removed_reaction: Reaction)
|
|
|
|
|
{
|
|
|
|
|
if let Some(server_id) = removed_reaction.guild_id
|
|
|
|
|
{
|
|
|
|
|
if server_id == utils::ADMIN_SERVER_ID && removed_reaction.channel_id == utils::ADMIN_COMMAND_CHANNEL_ID
|
|
|
|
|
{
|
|
|
|
|
//test::handle_reaction_remove(ctx, removed_reaction, server_id).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if server_id == utils::SM_SERVER_ID
|
|
|
|
|
{
|
|
|
|
|
sm_server::handle_reaction_remove(ctx, removed_reaction).await;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|