Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
don't notify users if they added a reaction
Browse files Browse the repository at this point in the history
Don't notify users of a keyword appearance if they added a reaction in
the same channel within 2 minutes.

Closes #17.
  • Loading branch information
ThatsNoMoon committed Dec 16, 2020
1 parent 939cac4 commit 5f25096
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/highlighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
Error,
};
use indoc::indoc;
use tokio::time::delay_for;
use tokio::{select, time::delay_for};

pub async fn should_notify_keyword(
ctx: &Context,
Expand Down Expand Up @@ -76,12 +76,22 @@ pub async fn notify_keyword(
let channel_id = message.channel_id;
let guild_id = message.guild_id.unwrap();

let new_message = message
let reply_or_reaction;

let reply = message
.channel_id
.await_reply(&ctx)
.author_id(user_id)
.timeout(PATIENCE_DURATION);
if new_message.await.is_none() {

let reaction = message.channel_id.await_reaction(&ctx).author_id(user_id);

select! {
reaction = reaction => reply_or_reaction = reaction.map(|_| ()),
reply = reply => reply_or_reaction = reply.map(|_| ()),
}

if reply_or_reaction.is_none() {
let result: Result<(), Error> = async {
let message = match ctx
.http
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ async fn main() {
.event_handler(Handler)
.intents(
GatewayIntents::DIRECT_MESSAGES
| GatewayIntents::GUILD_MESSAGE_REACTIONS
| GatewayIntents::GUILD_MESSAGES
| GatewayIntents::GUILDS
| GatewayIntents::GUILD_MEMBERS,
Expand Down

0 comments on commit 5f25096

Please sign in to comment.