summaryrefslogtreecommitdiff
path: root/src/handler/events.rs
blob: d971b25d61534e03556cc0192fc0e2787a4d2093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::handler::Handler;
use log::*;
use poise::async_trait;
use poise::serenity_prelude::{ChannelPinsUpdateEvent, Context, EventHandler, Message};

#[async_trait]
impl EventHandler for Handler {
	async fn message(&self, ctx: Context, msg: Message) {
		if self.should_echo(&msg) {
			let send = msg.reply(&ctx, &msg.content);
			if let Err(why) = send.await {
				error!("error when replying to {:?}: {:?}", msg.content, why);
			}
		}
	}

	async fn channel_pins_update(&self, ctx: Context, pin: ChannelPinsUpdateEvent) {
		let Some(pin_board) = &self.data.pin_board else {
			return;
		};

		pin_board.handle_pin(&ctx, &pin).await;
	}
}