@@ -34,6 +34,29 @@ def wii(cls):
3434 def legacy (cls ):
3535 return cls (0x707070 )
3636
37+ PUBLIC_CHAN_IDS = [
38+ 196635695958196224 , # 3ds 1
39+ 247557068490276864 , # 3ds 2
40+ 279783073497874442 , # wiiu
41+ 439933093118476289 , # switch 1
42+ 655681905907466250 , # switch 2
43+ 1159223824676565114 , # wii-vwii
44+ 196635745551646720 , # modding gen
45+ 770582653132734464 , # tt
46+ 314582689829355521 , # legacy
47+ 196635781798952960 , # dev
48+ 233002779717795850 , # hardware
49+ 270890866820775946 , # appeals
50+ 872309776233684992 , # meta
51+ 918315061003579482 , # kurisu-dev
52+ 1159936589997281390 , # guide meta
53+ 1022667983081967636 , # wiki discussion
54+ 1364102432790941776 , # hw wiki discussion
55+ 314856589716750346 , # off topic
56+ 300388576451887104 , # nintendo discussion
57+ 485138525885431808 , # elsewhere (just in case)
58+ ]
59+
3760
3861async def send_dm_message (member : discord .Member , message : str , ctx : Optional [commands .Context ] = None , ** kwargs ) -> bool :
3962 """A helper method for sending a message to a member's DMs.
@@ -195,3 +218,45 @@ async def simple_embed(ctx: commands.Context, text: str, *, title: str = "", col
195218 embed = discord .Embed (title = title , color = color )
196219 embed .description = cleandoc (text )
197220 await ctx .send (embed = embed , reference = ctx .message .reference , mention_author = mention_author )
221+
222+ async def scam_purge (
223+ guild : discord .Guild ,
224+ target_id : int ,
225+ * ,
226+ reason : str ,
227+ limit : int = 50 ,
228+ ) -> tuple [int , list [str ]]:
229+ """
230+ Purge messages by a user from PUBLIC_CHAN_IDS in the last 24 hours.
231+ """
232+ after = discord .utils .utcnow () - datetime .timedelta (days = 1 )
233+
234+ deleted_count = 0
235+ failures : list [str ] = []
236+
237+ for channel_id in PUBLIC_CHAN_IDS :
238+ channel = guild .get_channel (channel_id )
239+
240+ if channel is None or not isinstance (channel , discord .TextChannel ):
241+ failures .append (f"{ channel_id } : not found or not text" )
242+ continue
243+
244+ try :
245+ deleted = await channel .purge (
246+ limit = limit ,
247+ after = after ,
248+ oldest_first = False ,
249+ check = lambda m , tid = target_id : m .author .id == tid ,
250+ reason = reason ,
251+ bulk = True ,
252+ )
253+ deleted_count += len (deleted )
254+
255+ except (discord .Forbidden , discord .HTTPException ) as e :
256+ status = getattr (e , "status" , None )
257+ code = getattr (e , "code" , None )
258+ failures .append (
259+ f"#{ channel .name } : { type (e ).__name__ } (status={ status } , code={ code } )"
260+ )
261+
262+ return deleted_count , failures
0 commit comments