57
57
3 : "muted" ,
58
58
4 : "unbanned" ,
59
59
5 : "helpblocked" ,
60
+ 6 : "generalblocked" ,
61
+ 7 : "unmuted" ,
62
+ 8 : "un-generalblocked" ,
63
+ 9 : "un-helpblocked" ,
60
64
}
61
65
62
66
@@ -77,18 +81,24 @@ class GithubError(commands.CommandError):
77
81
class ModerationRespostView (discord .ui .View ):
78
82
message : discord .Message | discord .WebhookMessage
79
83
80
- def __init__ (self , * , timeout : float | None = 180 , target_id : int , target_reason : str ) -> None :
84
+ def __init__ (
85
+ self , * , timeout : float | None = 180 , event_type : core .DiscordPyModerationEvent , target_id : int , target_reason : str
86
+ ) -> None :
81
87
super ().__init__ (timeout = timeout )
88
+ self .event_type : core .DiscordPyModerationEvent = event_type
82
89
self .target : discord .Object = discord .Object (id = target_id , type = discord .Member )
83
90
self .target_reason : str = target_reason
84
91
85
- def _disable_all_buttons (self ) -> None :
92
+ if self .event_type .value in (4 , 7 , 8 , 9 ):
93
+ self ._disable_all_components ()
94
+
95
+ def _disable_all_components (self ) -> None :
86
96
for item in self .children :
87
97
if isinstance (item , (discord .ui .Button , discord .ui .Select )):
88
98
item .disabled = True
89
99
90
100
async def on_timeout (self ) -> None :
91
- self ._disable_all_buttons ()
101
+ self ._disable_all_components ()
92
102
await self .message .edit (view = self )
93
103
94
104
@discord .ui .button (label = "Ban" , emoji = "\U0001f528 " )
@@ -103,7 +113,7 @@ async def ban_button(self, interaction: Interaction, button: discord.ui.Button[S
103
113
)
104
114
await interaction .followup .send ("Banned." )
105
115
106
- self ._disable_all_buttons ()
116
+ self ._disable_all_components ()
107
117
await self .message .edit (view = self )
108
118
109
119
@discord .ui .button (label = "Kick" , emoji = "\U0001f462 " )
@@ -118,7 +128,7 @@ async def kick_button(self, interaction: Interaction, button: discord.ui.Button[
118
128
)
119
129
await interaction .followup .send ("Kicked." )
120
130
121
- self ._disable_all_buttons ()
131
+ self ._disable_all_components ()
122
132
await self .message .edit (view = self )
123
133
124
134
@@ -310,7 +320,12 @@ async def on_papi_dpy_modlog(self, payload: ModLogPayload, /) -> None:
310
320
channel = guild .get_channel (Channels .DPY_MOD_LOGS )
311
321
assert isinstance (channel , discord .TextChannel ) # This is static
312
322
313
- view = ModerationRespostView (timeout = 60 * 60 , target_id = target_id , target_reason = moderation_reason )
323
+ view = ModerationRespostView (
324
+ timeout = 60 * 60 ,
325
+ event_type = moderation_event ,
326
+ target_id = target_id ,
327
+ target_reason = moderation_reason ,
328
+ )
314
329
view .message = await channel .send (embed = embed , view = view )
315
330
316
331
0 commit comments