File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use std::time::SystemTime;
44
55use clap:: Parser ;
66use serenity:: async_trait;
7+ use serenity:: builder:: CreateMessage ;
78use serenity:: futures:: StreamExt ;
89use serenity:: model:: channel:: Message ;
910use serenity:: model:: gateway:: Ready ;
@@ -59,6 +60,30 @@ impl EventHandler for Handler {
5960
6061 tracing:: warn!( "{warn_msg}" ) ;
6162
63+ if let Some ( message) = & server_config. moderation_message {
64+ match msg. author . create_dm_channel ( & ctx. http ) . await {
65+ Ok ( channel) => {
66+ if let Err ( e) = channel
67+ . send_message ( & ctx. http , CreateMessage :: new ( ) . content ( message) )
68+ . await
69+ {
70+ tracing:: warn!(
71+ "Failed to send DM channel to {} - {}: {e}" ,
72+ msg. author. name,
73+ msg. author. id
74+ ) ;
75+ }
76+ }
77+ Err ( e) => {
78+ tracing:: warn!(
79+ "Failed to create DM channel to {} - {}: {e}" ,
80+ msg. author. name,
81+ msg. author. id
82+ ) ;
83+ }
84+ }
85+ }
86+
6287 match server_config. moderation {
6388 Moderation :: Disabled => tracing:: info!( "Do nothing" ) ,
6489 Moderation :: Kick => {
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ pub struct ServerConfig {
4343 pub traps : Vec < u64 > ,
4444 pub whitelist : Vec < u64 > ,
4545
46+ pub moderation_message : Option < String > ,
47+
4648 #[ serde( default = "default_moderation" ) ]
4749 pub moderation : Moderation ,
4850}
You can’t perform that action at this time.
0 commit comments