File tree Expand file tree Collapse file tree
BF2WebAdmin.Common/Entities/Game Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public class Player : Entity
2323 // Custom/Aggregate properties from modules
2424 public IDictionary < int , int > PingHistory { get ; } = new Dictionary < int , int > ( ) ;
2525 public DateTime LastLeaveNotification { get ; set ; }
26+ public DateTime LastAdminCall { get ; set ; }
2627
2728 public string DisplayName => Name ? . Trim ( ) ;
2829 public string ShortName
Original file line number Diff line number Diff line change @@ -8,4 +8,10 @@ namespace BF2WebAdmin.Server.Commands.BF2;
88public class LeaveCommand : BaseCommand
99{
1010 public int Minutes { get ; set ; }
11- }
11+ }
12+
13+ [ Command ( "calladmin <Reason>" , Auth . All ) ]
14+ public class CallAdminCommand : BaseCommand
15+ {
16+ public string Reason { get ; set ; }
17+ }
Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ public class DiscordModule : BaseModule,
3030 IHandleEventAsync < GameStreamStartedEvent > ,
3131 IHandleEventAsync < GameStreamStoppedEvent > ,
3232 IHandleCommandAsync < LeaveCommand > ,
33+ IHandleCommandAsync < CallAdminCommand > ,
3334 IHandleCommandAsync < StartStreamCommand > ,
3435 IHandleCommandAsync < StopStreamCommand >
3536{
@@ -643,4 +644,16 @@ private async Task StopStreamAsync()
643644 {
644645 await _gameStreamService . StopGameStreamAsync ( GameServer . IpAddress . ToString ( ) , GameServer . GamePort ) ;
645646 }
646- }
647+
648+ public async ValueTask HandleAsync ( CallAdminCommand command )
649+ {
650+ var isCommandCooldown = DateTime . UtcNow - command . Message . Player . LastAdminCall < TimeSpan . FromMinutes ( 30 ) ;
651+ if ( isCommandCooldown )
652+ return ;
653+
654+ command . Message . Player . LastAdminCall = DateTime . UtcNow ;
655+
656+ await SendTextMessageToChannelsAsync ( $ "@everyone Admin requested by { Sanitize ( command . Message . Player . Name ) } : { Sanitize ( command . Reason ) } ") ;
657+ _game . GameWriter . SendText ( $ "{ command . Message . Player . Name } called an admin") ;
658+ }
659+ }
You can’t perform that action at this time.
0 commit comments