@@ -30,8 +30,8 @@ async def setup(self, ctx):
3030 await categ .edit (position = 0 )
3131
3232 c = await self .bot .modmail_guild .create_text_channel (name = 'bot-logs' , category = categ )
33- await c .edit (topic = 'Manually add user id \' s to block users. \n \n '
34- 'Blocked \n ------- \n \n ' )
33+ await c .edit (topic = 'You can delete this channel if you set up your own log channel.' )
34+ await c . send ( 'Use the `config set log_channel_id` command to set up a custom log channel. ' )
3535
3636 await ctx .send ('Successfully set up server.' )
3737
@@ -150,6 +150,9 @@ async def _close(self, ctx):
150150 }
151151 })
152152
153+ if isinstance (log_data , str ):
154+ print (log_data ) # error
155+
153156 log_url = f"https://logs.modmail.tk/{ log_data ['user_id' ]} /{ log_data ['key' ]} "
154157
155158 user = thread .recipient .mention if thread .recipient else f'`{ thread .id } `'
@@ -299,19 +302,19 @@ async def blocked(self, ctx):
299302 users = []
300303 not_reachable = []
301304
302- for id in self .bot .blocked_users :
303- user = self .bot .get_user (id )
305+ for id , reason in self .bot .blocked_users . items () :
306+ user = self .bot .get_user (int ( id ) )
304307 if user :
305- users .append (user )
308+ users .append (( user , reason ) )
306309 else :
307- not_reachable .append (id )
310+ not_reachable .append (( id , reason ) )
308311
309312 em .description = 'Here is a list of blocked users.'
310313
311314 if users :
312- em .add_field (name = 'Currently Known' , value = ' ' .join (u .mention for u in users ))
315+ em .add_field (name = 'Currently Known' , value = '\n ' .join (u .mention + ( f' - ` { r } `' if r else '' ) for u , r in users ))
313316 if not_reachable :
314- em .add_field (name = 'Unknown' , value = '\n ' .join (f'`{ i } `' for i in not_reachable ), inline = False )
317+ em .add_field (name = 'Unknown' , value = '\n ' .join (f'`{ i } `' + ( f' - ` { r } `' if r else '' ) for i , r in not_reachable ), inline = False )
315318
316319 if not users and not not_reachable :
317320 em .description = 'Currently there are no blocked users'
@@ -321,7 +324,7 @@ async def blocked(self, ctx):
321324 @commands .command ()
322325 @trigger_typing
323326 @commands .has_permissions (manage_channels = True )
324- async def block (self , ctx , * , user : Union [discord .Member , discord .User , obj ]= None ):
327+ async def block (self , ctx , user : Union [discord .Member , discord .User , obj ]= None , * , reason = None ):
325328 """Block a user from using modmail."""
326329
327330 if user is None :
@@ -331,21 +334,18 @@ async def block(self, ctx, *, user: Union[discord.Member, discord.User, obj]=Non
331334 else :
332335 raise commands .UserInputError
333336
334- categ = self .bot .main_category
335- top_chan = categ .channels [0 ] # bot-info
336- topic = str (top_chan .topic )
337- topic += '\n ' + str (user .id )
338-
337+
339338 mention = user .mention if hasattr (user , 'mention' ) else f'`{ user .id } `'
340339
341340 em = discord .Embed ()
342341 em .color = discord .Color .green ()
343342
344- if str (user .id ) not in top_chan .topic :
345- await top_chan .edit (topic = topic )
343+ if str (user .id ) not in self .bot .blocked_users :
344+ self .bot .config .blocked [str (user .id )] = reason
345+ await self .bot .config .update ()
346346
347347 em .title = 'Success'
348- em .description = f'{ mention } is now blocked'
348+ em .description = f'{ mention } is now blocked ' + f'for ` { reason } `' if reason else ' '
349349
350350 await ctx .send (embed = em )
351351 else :
@@ -368,18 +368,14 @@ async def unblock(self, ctx, *, user: Union[discord.Member, discord.User, obj]=N
368368 else :
369369 raise commands .UserInputError
370370
371- categ = self .bot .main_category
372- top_chan = categ .channels [0 ] # thread-logs
373- topic = str (top_chan .topic )
374- topic = topic .replace ('\n ' + str (user .id ), '' )
375-
376371 mention = user .mention if hasattr (user , 'mention' ) else f'`{ user .id } `'
377372
378373 em = discord .Embed ()
379374 em .color = discord .Color .green ()
380375
381- if str (user .id ) in top_chan .topic :
382- await top_chan .edit (topic = topic )
376+ if str (user .id ) in self .bot .blocked_users :
377+ del self .bot .config .blocked [str (user .id )]
378+ await self .bot .config .update ()
383379
384380 em .title = 'Success'
385381 em .description = f'{ mention } is no longer blocked'
0 commit comments