@@ -49,9 +49,6 @@ async def punish(self, server: Server, ucid: str, punishment: dict, reason: str,
4949 member = utils .escape_string (member .display_name ),
5050 banned_by = utils .escape_string (self .bot .member .name ),
5151 reason = reason )
52- if admin_channel :
53- await admin_channel .send (message )
54- await self .bot .audit (message )
5552 with suppress (Exception ):
5653 guild = self .bot .guilds [0 ]
5754 channel = await member .create_dm ()
@@ -62,38 +59,33 @@ async def punish(self, server: Server, ucid: str, punishment: dict, reason: str,
6259 elif player :
6360 message = _ ("Player {player} (ucid={ucid}) banned by {banned_by} for {reason}." ).format (
6461 player = player .display_name , ucid = player .ucid , banned_by = self .bot .member .name , reason = reason )
65- if admin_channel :
66- await admin_channel .send (message )
67- await self .bot .audit (message )
6862 else :
6963 message = _ ("Player with ucid {ucid} banned by {banned_by} for {reason}." ).format (
7064 ucid = ucid , banned_by = self .bot .member .name , reason = reason )
71- if admin_channel :
72- await admin_channel .send (message )
73- await self .bot .audit (message )
65+ # audit
66+ if admin_channel :
67+ await admin_channel .send ("```" + message + "```" )
68+ await self .bot .audit (message )
7469
7570 # everything after that point can only be executed if players are active
7671 if not player :
7772 return
7873
74+ message = None
7975 if punishment ['action' ] == 'kick' and player .active :
8076 # we must not punish for reslots here
8177 self .eventlistener .pending_kill .pop (ucid , None )
8278 await server .kick (player , reason )
83- if admin_channel :
84- await admin_channel .send (
85- _ ("Player {player} (ucid={ucid}) kicked by {kicked_by} for {reason}." ).format (
86- player = player .display_name , ucid = player .ucid , kicked_by = self .bot .member .name , reason = reason ))
79+ message = _ ("Player {player} (ucid={ucid}) kicked by {kicked_by} for {reason}." ).format (
80+ player = player .display_name , ucid = player .ucid , kicked_by = self .bot .member .name , reason = reason )
8781
8882 elif punishment ['action' ] == 'move_to_spec' :
8983 # we must not punish for reslots here
9084 self .eventlistener .pending_kill .pop (ucid , None )
9185 await server .move_to_spectators (player )
9286 await player .sendUserMessage (_ ("You've been kicked back to spectators because of: {}." ).format (reason ))
93- if admin_channel :
94- await admin_channel .send (
95- _ ("Player {player} (ucid={ucid}) moved to spectators by {spec_by} for {reason}." ).format (
96- player = player .display_name , ucid = player .ucid , spec_by = self .bot .member .name , reason = reason ))
87+ message = _ ("Player {player} (ucid={ucid}) moved to spectators by {spec_by} for {reason}." ).format (
88+ player = player .display_name , ucid = player .ucid , spec_by = self .bot .member .name , reason = reason )
9789
9890 elif punishment ['action' ] == 'credits' and type (player ).__name__ == 'CreditPlayer' :
9991 player : CreditPlayer = cast (CreditPlayer , player )
@@ -104,10 +96,8 @@ async def punish(self, server: Server, ucid: str, punishment: dict, reason: str,
10496 _ ("{name}, you have been punished for: {reason}!\n "
10597 "Your current credit points are: {points}" ).format (
10698 name = player .name , reason = reason , points = player .points ))
107- if admin_channel :
108- await admin_channel .send (
109- _ ("Player {player} (ucid={ucid}) punished with credits by {punished_by} for {reason}." ).format (
110- player = player .display_name , ucid = player .ucid , punished_by = self .bot .member .name , reason = reason ))
99+ message = _ ("Player {player} (ucid={ucid}) punished with credits by {punished_by} for {reason}." ).format (
100+ player = player .display_name , ucid = player .ucid , punished_by = self .bot .member .name , reason = reason )
111101
112102 elif punishment ['action' ] == 'warn' :
113103 await player .sendUserMessage (_ ("{name}, you have been punished for: {reason}!" ).format (name = player .name ,
@@ -119,6 +109,11 @@ async def punish(self, server: Server, ucid: str, punishment: dict, reason: str,
119109 if points :
120110 await player .sendUserMessage (_ ("{name}, you have {points} punishment points." ).format (name = player .name ,
121111 points = points ))
112+ if message :
113+ # audit
114+ if admin_channel :
115+ await admin_channel .send ("```" + message + "```" )
116+ await self .bot .audit (message )
122117
123118 # TODO: change to pubsub
124119 @tasks .loop (minutes = 1.0 )
0 commit comments