@@ -30,8 +30,8 @@ async def setup(self, ctx):
30
30
await categ .edit (position = 0 )
31
31
32
32
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. ' )
35
35
36
36
await ctx .send ('Successfully set up server.' )
37
37
@@ -150,6 +150,9 @@ async def _close(self, ctx):
150
150
}
151
151
})
152
152
153
+ if isinstance (log_data , str ):
154
+ print (log_data ) # error
155
+
153
156
log_url = f"https://logs.modmail.tk/{ log_data ['user_id' ]} /{ log_data ['key' ]} "
154
157
155
158
user = thread .recipient .mention if thread .recipient else f'`{ thread .id } `'
@@ -299,19 +302,19 @@ async def blocked(self, ctx):
299
302
users = []
300
303
not_reachable = []
301
304
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 ) )
304
307
if user :
305
- users .append (user )
308
+ users .append (( user , reason ) )
306
309
else :
307
- not_reachable .append (id )
310
+ not_reachable .append (( id , reason ) )
308
311
309
312
em .description = 'Here is a list of blocked users.'
310
313
311
314
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 ))
313
316
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 )
315
318
316
319
if not users and not not_reachable :
317
320
em .description = 'Currently there are no blocked users'
@@ -321,7 +324,7 @@ async def blocked(self, ctx):
321
324
@commands .command ()
322
325
@trigger_typing
323
326
@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 ):
325
328
"""Block a user from using modmail."""
326
329
327
330
if user is None :
@@ -331,21 +334,18 @@ async def block(self, ctx, *, user: Union[discord.Member, discord.User, obj]=Non
331
334
else :
332
335
raise commands .UserInputError
333
336
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
+
339
338
mention = user .mention if hasattr (user , 'mention' ) else f'`{ user .id } `'
340
339
341
340
em = discord .Embed ()
342
341
em .color = discord .Color .green ()
343
342
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 ()
346
346
347
347
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 ' '
349
349
350
350
await ctx .send (embed = em )
351
351
else :
@@ -368,18 +368,14 @@ async def unblock(self, ctx, *, user: Union[discord.Member, discord.User, obj]=N
368
368
else :
369
369
raise commands .UserInputError
370
370
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
-
376
371
mention = user .mention if hasattr (user , 'mention' ) else f'`{ user .id } `'
377
372
378
373
em = discord .Embed ()
379
374
em .color = discord .Color .green ()
380
375
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 ()
383
379
384
380
em .title = 'Success'
385
381
em .description = f'{ mention } is no longer blocked'
0 commit comments