wOxlf/src/game/listener/host_snooper.rs

30 lines
847 B
Rust

use crate::game::listener::{EventStatus, Listener, ListenerContext, Priority};
use crate::game::message_router::{send_to_host_channel, WoxlfMessage};
use serenity::async_trait;
use serenity::model::prelude::GuildId;
use std::fmt::Debug;
#[derive(Debug)]
pub struct HostSnooper {}
#[async_trait]
impl Listener for HostSnooper {
fn get_priority(&self) -> Priority {
Priority::Logging
}
async fn on_chat(
&mut self,
ctx: &mut ListenerContext,
msg: &WoxlfMessage,
) -> crate::error::Result<EventStatus> {
let guild_id = ctx.data.cfg.discord_config.guild_id;
let guild = GuildId::from(guild_id)
.to_guild_cached(&ctx.ctx.cache)
.unwrap();
send_to_host_channel(&ctx.ctx.http, &guild, ctx.data, msg.clone()).await?;
Ok(EventStatus::Okay)
}
}