Adds first 3 race roles, still using private test message

main
Joey Pollack 2 years ago
parent dff54a4b41
commit 8714012462

@ -34,6 +34,12 @@ const ROLE_ID_BINGO: u64 = 621128130681110546;
const ROLE_ID_MISC: u64 = 313710318486421505; const ROLE_ID_MISC: u64 = 313710318486421505;
const ROLE_ID_PUZZLE: u64 = 405792833820164102; const ROLE_ID_PUZZLE: u64 = 405792833820164102;
// ROLE EMOJIS:
const EMOJI_SM_ID: u64 = 245980377867485184;
const EMOJI_HUNDO_ID: u64 = 1023763860680876132;
const EMOJI_CROCZ_ID: u64 = 243881344910753794;
pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId) pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
{ {
@ -59,7 +65,7 @@ pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
command_start == Some(".dorolesmsg") command_start == Some(".dorolesmsg")
{ {
if let Some(msg) = utils::send_msg(ctx.clone(), if let Some(msg) = utils::send_msg(ctx.clone(),
ChannelId::from(SM_TEST_CHANNEL_ID), "Test message!").await ChannelId::from(SM_TEST_CHANNEL_ID), "Test message! :CrocZ:").await
{ {
println!("Test message id is: {:#?}", msg.id) println!("Test message id is: {:#?}", msg.id)
} }
@ -110,15 +116,46 @@ pub async fn handle_reaction_add(ctx: Context, reaction: Reaction)
if reaction.channel_id == ChannelId::from(SM_TEST_CHANNEL_ID) if reaction.channel_id == ChannelId::from(SM_TEST_CHANNEL_ID)
&& reaction.message_id == MessageId::from(1245086205381574790 as u64) && reaction.message_id == MessageId::from(1245086205381574790 as u64)
{ {
if reaction.emoji.unicode_eq("👍") if let ReactionType::Custom{ animated: _, id, name: _ } = reaction.clone().emoji
{ {
let user_name = reaction.user(ctx.clone()).await.unwrap().name; match id
{
EmojiId(EMOJI_SM_ID) => {
utils::add_role(ctx.clone(), reaction.user_id.expect("UserId was None in handle_reaction_add"), utils::add_role(ctx.clone(), reaction.user_id.expect("UserId was None in handle_reaction_add"),
RoleId::from(ROLE_ID_ANY_PERCENT), RoleId::from(ROLE_ID_ANY_PERCENT),
reaction.guild_id.expect("GuildId was None in handle_reaction_add")) reaction.guild_id.expect("GuildId was None in handle_reaction_add"))
.await.unwrap(); .await.unwrap();
let user_name = reaction.user(ctx.clone()).await.unwrap().name;
utils::Logger::log_message(ctx.clone(), &format!("Added any% role for {}", user_name)).await; utils::Logger::log_message(ctx.clone(), &format!("Added any% role for {}", user_name)).await;
},
EmojiId(EMOJI_HUNDO_ID) => {
utils::add_role(ctx.clone(), reaction.user_id.expect("UserId was None in handle_reaction_add"),
RoleId::from(ROLE_ID_HUNDO),
reaction.guild_id.expect("GuildId was None in handle_reaction_add"))
.await.unwrap();
let user_name = reaction.user(ctx.clone()).await.unwrap().name;
utils::Logger::log_message(ctx.clone(), &format!("Added hundo role for {}", user_name)).await;
},
EmojiId(EMOJI_CROCZ_ID) => {
utils::add_role(ctx.clone(), reaction.user_id.expect("UserId was None in handle_reaction_add"),
RoleId::from(ROLE_ID_RANDOMIZER),
reaction.guild_id.expect("GuildId was None in handle_reaction_add"))
.await.unwrap();
let user_name = reaction.user(ctx.clone()).await.unwrap().name;
utils::Logger::log_message(ctx.clone(), &format!("Added randomizer role for {}", user_name)).await;
},
// COLORS
_ => (), // TODO: Maybe give (or log) an error?
}
} }
// else // else
// { // {
@ -133,16 +170,48 @@ pub async fn handle_reaction_remove(ctx: Context, reaction: Reaction)
if reaction.channel_id == ChannelId::from(SM_TEST_CHANNEL_ID) if reaction.channel_id == ChannelId::from(SM_TEST_CHANNEL_ID)
&& reaction.message_id == MessageId::from(1245086205381574790 as u64) && reaction.message_id == MessageId::from(1245086205381574790 as u64)
{ {
if reaction.emoji.unicode_eq("👍") if let ReactionType::Custom{ animated: _, id, name: _ } = reaction.clone().emoji
{
match id
{ {
utils::remove_role(ctx.clone(), reaction.user_id.expect("UserId was None in handle_reaction_remove"), EmojiId(EMOJI_SM_ID) => {
utils::remove_role(ctx.clone(), reaction.user_id.expect("UserId was None in handle_reaction_add"),
RoleId::from(ROLE_ID_ANY_PERCENT), RoleId::from(ROLE_ID_ANY_PERCENT),
reaction.guild_id.expect("GuildId was None in handle_reaction_remove")) reaction.guild_id.expect("GuildId was None in handle_reaction_add"))
.await.unwrap(); .await.unwrap();
let user_name = reaction.user(ctx.clone()).await.unwrap().name; let user_name = reaction.user(ctx.clone()).await.unwrap().name;
utils::Logger::log_message(ctx.clone(), &format!("Removed any% role for {}", user_name)).await; utils::Logger::log_message(ctx.clone(), &format!("Removed any% role for {}", user_name)).await;
},
EmojiId(EMOJI_HUNDO_ID) => {
utils::remove_role(ctx.clone(), reaction.user_id.expect("UserId was None in handle_reaction_add"),
RoleId::from(ROLE_ID_HUNDO),
reaction.guild_id.expect("GuildId was None in handle_reaction_add"))
.await.unwrap();
let user_name = reaction.user(ctx.clone()).await.unwrap().name;
utils::Logger::log_message(ctx.clone(), &format!("Removed hundo role for {}", user_name)).await;
},
EmojiId(EMOJI_CROCZ_ID) => {
utils::remove_role(ctx.clone(), reaction.user_id.expect("UserId was None in handle_reaction_add"),
RoleId::from(ROLE_ID_RANDOMIZER),
reaction.guild_id.expect("GuildId was None in handle_reaction_add"))
.await.unwrap();
let user_name = reaction.user(ctx.clone()).await.unwrap().name;
utils::Logger::log_message(ctx.clone(), &format!("Removed randomizer role for {}", user_name)).await;
},
// COLORS
_ => (), // TODO: Maybe give (or log) an error?
}
} }
else else
{ {

@ -47,7 +47,7 @@ impl EventHandler for Handler
async fn reaction_add(&self, ctx: Context, add_reaction: Reaction) async fn reaction_add(&self, ctx: Context, add_reaction: Reaction)
{ {
// println!("reaction_add event"); // println!("reaction_add event");
utils::Logger::log_message(ctx.clone(), &format!("reaction add event: {:#?}", add_reaction)).await; utils::Logger::log_message(ctx.clone(), &format!("reaction add event, emoji: {:#?}", add_reaction.emoji)).await;
// todo!() // todo!()
commands::handle_reaction_add(ctx, add_reaction).await; commands::handle_reaction_add(ctx, add_reaction).await;

Loading…
Cancel
Save