From d49f81863795e1ae2e8d4bdffd1e861b7e20c963 Mon Sep 17 00:00:00 2001 From: Vicky Date: Wed, 15 Jan 2025 17:06:54 +0100 Subject: [PATCH] Added barebones reactions proof of concept. --- Cargo.toml | 3 +++ src/watchdog.rs | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2403299..b947c12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "idlefox" version = "0.1.0" edition = "2021" +[features] +custom_emojis = [] + [dependencies] poise = "0.6.1" poise_macros = "0.6.1" diff --git a/src/watchdog.rs b/src/watchdog.rs index 88918cf..02c141d 100644 --- a/src/watchdog.rs +++ b/src/watchdog.rs @@ -15,7 +15,9 @@ use crate::votes::EventHolder; use chrono::{DateTime, Local, NaiveDate}; -use poise::serenity_prelude::{self, CacheHttp, ChannelId, Mention, RoleId}; +use poise::serenity_prelude::{ + self, CacheHttp, ChannelId, CreateMessage, EmojiId, Mention, ReactionType, RoleId, +}; /// The main scheduler waiting and dispatch loop. /// @@ -43,10 +45,16 @@ async fn fk_around(ev_ctx: &EventHolder) { ); if let Some(discord_ctx) = ev_ctx.discord_ctx.lock().await.as_mut() { println!("Full discord ctx : {:#?}", discord_ctx); - let mut m = serenity_prelude::Message::default(); + + let m = CreateMessage::new().content(format!( + "Hello {}", + Mention::from(RoleId::new(1222612097091768371)) + )); + + // let mut m = serenity_prelude::Message::default(); // discord_ctx.http.get_scheduled_event_users(, , , , ) // discord_ctx.http.get_user(UserId::new(1)); - m.content = format!("Hello {}", Mention::from(RoleId::new(1222612097091768371))); + // let m = m // m.content = format!("Hello {}", Mention::from(UserId::new(1))); // m.mentions = vec![User::]; @@ -57,6 +65,33 @@ async fn fk_around(ev_ctx: &EventHolder) { .send_message(ChannelId::new(1300786300143800351), Vec::new(), &m) .await; println!("{:?}", r); + if let Ok(msg) = r { + #[cfg(not(feature = "custom_emojis"))] + let msg_result = discord_ctx + .http() + .create_reaction( + msg.channel_id, + msg.id, + &ReactionType::Unicode("1️⃣".to_string()), + ) + .await; + + #[cfg(feature = "custom_emojis")] + let msg_result = discord_ctx + .http() + .create_reaction( + msg.channel_id, + msg.id, + &ReactionType::Custom { + animated: false, + id: (EmojiId::new(1329095596396642375)), + name: (Some("Foxo".to_string())), + }, + ) + .await; + + println!("{:?}", msg_result); + } } }