34 lines
920 B
Rust
34 lines
920 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 name(&self) -> String {
|
|
"Host Snooper".to_string()
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|