Completes testing for reaction roles, just need to setup the real thing

main
Joey Pollack 2 years ago
parent d527020d3d
commit 29bafbecc1

@ -10,7 +10,7 @@ pub mod sm_server;
use crate::utils; use crate::utils;
pub async fn initialize(ctx: Context) -> Result<(), String> pub async fn initialize(_ctx: Context) -> Result<(), String>
{ {
Ok(()) Ok(())

@ -1,10 +1,14 @@
#![allow(dead_code)]
use serenity::prelude::*; use serenity::prelude::*;
use serenity::model::prelude::*; use serenity::model::prelude::*;
use serenity::model::channel::Message; use serenity::model::channel::Message;
use crate::{utils, Owner}; use crate::{utils, Owner};
// TODO: ADD REACTION ROLE MESSAGE IDS HERE
// AUTHORIZED USER IDS: // AUTHORIZED USER IDS:
const BEL_WORK_USER_ID: u64 = 474259726427750420; const BEL_WORK_USER_ID: u64 = 474259726427750420;
@ -49,6 +53,7 @@ pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
None => { utils::Logger::log_error(ctx.clone(), &format!("Couldn't get bot owner id")).await; return; } None => { utils::Logger::log_error(ctx.clone(), &format!("Couldn't get bot owner id")).await; return; }
}; };
// TODO: Modify this to post the real Reaction Roles message
if (UserId::from(owner_id) == msg.author.id || UserId::from(BEL_WORK_USER_ID) == msg.author.id) && command_start == Some(".dotestmsg") if (UserId::from(owner_id) == msg.author.id || UserId::from(BEL_WORK_USER_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 if let Some(msg) = utils::send_msg(ctx.clone(), ChannelId::from(SM_TEST_CHANNEL_ID), "Test message!").await
@ -98,6 +103,7 @@ pub async fn parse_command(ctx: Context, msg: Message, server_id: GuildId)
pub async fn handle_reaction_add(ctx: Context, reaction: Reaction) pub async fn handle_reaction_add(ctx: Context, reaction: Reaction)
{ {
// TODO: Modify to handle the real reaction roles message for all race roles
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)
{ {
@ -111,24 +117,29 @@ pub async fn handle_reaction_add(ctx: Context, reaction: Reaction)
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;
} }
else // else
{ // {
utils::Logger::log_message(ctx.clone(), "Reaction was not the thumbs up emoji").await; // utils::Logger::log_message(ctx.clone(), "Reaction was not the thumbs up emoji").await;
} // }
} }
} }
pub async fn handle_reaction_remove(ctx: Context, reaction: Reaction) pub async fn handle_reaction_remove(ctx: Context, reaction: Reaction)
{ {
// TODO: Modify to handle the real reaction roles message for all race roles
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 reaction.emoji.unicode_eq("👍")
{ {
utils::remove_role(ctx, reaction.user_id.expect("UserId was None in handle_reaction_remove"), utils::remove_role(ctx.clone(), reaction.user_id.expect("UserId was None in handle_reaction_remove"),
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_remove"))
.await.unwrap(); .await.unwrap();
let user_name = reaction.user(ctx.clone()).await.unwrap().name;
utils::Logger::log_message(ctx.clone(), &format!("Removed any% role for {}", user_name)).await;
} }
else else
{ {

@ -4,7 +4,7 @@ mod data_loader;
mod utils; mod utils;
mod racetime; mod racetime;
use racetime::{race::Races}; use racetime::race::Races;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
@ -15,7 +15,7 @@ use std::time::Duration;
use serenity::async_trait; use serenity::async_trait;
use serenity::prelude::*; use serenity::prelude::*;
use serenity::model::channel::{Message, Reaction}; use serenity::model::channel::{Message, Reaction};
use serenity::model::gateway::{Gateway, Ready}; use serenity::model::gateway::Ready;
use serenity::model::id::GuildId; use serenity::model::id::GuildId;
use serenity::http::Http; use serenity::http::Http;
@ -57,6 +57,8 @@ impl EventHandler for Handler
{ {
println!("reaction_remove event"); println!("reaction_remove event");
//utils::Logger::log_message(ctx, &format!("reaction removed event: {:#?}", removed_reaction)).await; //utils::Logger::log_message(ctx, &format!("reaction removed event: {:#?}", removed_reaction)).await;
commands::handle_reaction_remove(ctx, removed_reaction).await;
} }
// Set a handler to be called on the `ready` event. This is called when a // Set a handler to be called on the `ready` event. This is called when a

Loading…
Cancel
Save