Adds test code for reaction roles

main
Joey Pollack 2 years ago
parent a15abd2650
commit 9cd32f5fa9

@ -64,5 +64,18 @@ pub async fn handle_reaction_add(ctx: Context, add_reaction: Reaction)
pub async fn handle_reaction_remove(ctx: Context, removed_reaction: Reaction) 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;
}
}
} }

@ -5,9 +5,14 @@ use serenity::model::channel::Message;
use crate::{utils, Owner}; use crate::{utils, Owner};
const SM_TEST_CHANNEL_ID: u64 = 280548893135994880;
// AUTHORIZED USER IDS:
const BEL_WORK_USER_ID: u64 = 474259726427750420; const BEL_WORK_USER_ID: u64 = 474259726427750420;
// CHANNEL IDS
const SM_TEST_CHANNEL_ID: u64 = 280548893135994880;
const SM_INFO_CHANNEL_ID: u64 = 270628925300801546;
// COLOR ROLE IDS // COLOR ROLE IDS
const ROLE_ID_RED: u64 = 279338933748236289; const ROLE_ID_RED: u64 = 279338933748236289;
const ROLE_ID_GREEN: u64 = 279338847102566400; const ROLE_ID_GREEN: u64 = 279338847102566400;
@ -18,8 +23,12 @@ const ROLE_ID_ORANGE: u64 = 279339077382438912;
const ROLE_ID_PURPLE: u64 = 284310454908747787; const ROLE_ID_PURPLE: u64 = 284310454908747787;
// RACE ROLE IDS // RACE ROLE IDS
const ROLE_ID_ANY_PERCENT: u64 = 313710041641254912;
const ROLE_ID_HUNDO: u64 = 313710205986668546;
const ROLE_ID_RANDOMIZER: u64 = 313710276685856768;
const ROLE_ID_BINGO: u64 = 621128130681110546;
const ROLE_ID_MISC: u64 = 313710318486421505;
const ROLE_ID_PUZZLE: u64 = 405792833820164102;
pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId) pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
{ {
@ -87,9 +96,42 @@ pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
} }
pub async fn handle_reaction_add(ctx: Context, reaction_add: Reaction) pub async fn handle_reaction_add(ctx: Context, reaction: Reaction)
{
if reaction.channel_id == ChannelId::from(SM_TEST_CHANNEL_ID)
&& reaction.message_id == MessageId::from(1245086205381574790 as u64)
{
if reaction.emoji.unicode_eq("👍")
{
utils::add_role(ctx, reaction.user_id.expect("UserId was None in handle_reaction_add"),
RoleId::from(ROLE_ID_ANY_PERCENT),
reaction.guild_id.expect("GuildId was None in handle_reaction_add"))
.await.unwrap();
}
else
{ {
utils::Logger::log_message(ctx, "Reaction was not the thumbs up emoji").await;
}
}
}
pub async fn handle_reaction_remove(ctx: Context, reaction: Reaction)
{
if reaction.channel_id == ChannelId::from(SM_TEST_CHANNEL_ID)
&& reaction.message_id == MessageId::from(1245086205381574790 as u64)
{
if reaction.emoji.unicode_eq("👍")
{
utils::remove_role(ctx, reaction.user_id.expect("UserId was None in handle_reaction_remove"),
RoleId::from(ROLE_ID_ANY_PERCENT),
reaction.guild_id.expect("GuildId was None in handle_reaction_remove"))
.await.unwrap();
}
else
{
utils::Logger::log_message(ctx, "Reaction was not the thumbs up emoji").await;
}
}
} }
///////////////////// HELPERS ///////////////////// HELPERS

Loading…
Cancel
Save