@@ -266,26 +266,26 @@ async def close(self, ctx, *, after: UserFriendlyTime = None):
266
266
@commands .command (aliases = ['alert' ])
267
267
@checks .has_permissions (PermissionLevel .SUPPORTER )
268
268
@checks .thread_only ()
269
- async def notify (self , ctx , * , role : Union [discord .Role , str .lower , None ] = None ):
269
+ async def notify (self , ctx , * , user_or_role : Union [discord .Role , User , str .lower , None ] = None ):
270
270
"""
271
- Notify a role or yourself when the next thread message received.
271
+ Notify a user, role, or yourself when the next thread message received.
272
272
273
- Once a thread message is received, `role ` will only be pinged once.
273
+ Once a thread message is received, `user_or_role ` will only be pinged once.
274
274
275
- Leave `role ` empty to notify yourself.
275
+ Leave `user_or_role ` empty to notify yourself.
276
276
`@here` and `@everyone` can be substituted with `here` and `everyone`.
277
- `role ` may be a role ID, mention, name, "everyone", or "here".
277
+ `user_or_role ` may be a user ID, mention, name. role ID, mention, name, "everyone", or "here".
278
278
"""
279
279
thread = ctx .thread
280
280
281
- if role is None :
281
+ if user_or_role is None :
282
282
mention = ctx .author .mention
283
- elif isinstance ( role , discord . Role ):
284
- mention = role .mention
285
- elif role in {'here' , 'everyone' , '@here' , '@everyone' }:
286
- mention = '@' + role .lstrip ('@' )
283
+ elif hasattr ( user_or_role , 'mention' ):
284
+ mention = user_or_role .mention
285
+ elif user_or_role in {'here' , 'everyone' , '@here' , '@everyone' }:
286
+ mention = '@' + user_or_role .lstrip ('@' )
287
287
else :
288
- raise commands .BadArgument (f'{ role } is not a valid role.' )
288
+ raise commands .BadArgument (f'{ user_or_role } is not a valid role.' )
289
289
290
290
if str (thread .id ) not in self .bot .config ['notification_squad' ]:
291
291
self .bot .config ['notification_squad' ][str (thread .id )] = []
@@ -304,29 +304,68 @@ async def notify(self, ctx, *, role: Union[discord.Role, str.lower, None] = None
304
304
'on the next message received.' )
305
305
return await ctx .send (embed = embed )
306
306
307
+ @commands .command (aliases = ['unalert' ])
308
+ @checks .has_permissions (PermissionLevel .SUPPORTER )
309
+ @checks .thread_only ()
310
+ async def unnotify (self , ctx , * , user_or_role : Union [discord .Role , User , str .lower , None ] = None ):
311
+ """
312
+ Un-notify a user, role, or yourself from a thread.
313
+
314
+ Leave `user_or_role` empty to un-notify yourself.
315
+ `@here` and `@everyone` can be substituted with `here` and `everyone`.
316
+ `user_or_role` may be a user ID, mention, name, role ID, mention, name, "everyone", or "here".
317
+ """
318
+ thread = ctx .thread
319
+
320
+ if user_or_role is None :
321
+ mention = ctx .author .mention
322
+ elif hasattr (user_or_role , 'mention' ):
323
+ mention = user_or_role .mention
324
+ elif user_or_role in {'here' , 'everyone' , '@here' , '@everyone' }:
325
+ mention = '@' + user_or_role .lstrip ('@' )
326
+ else :
327
+ mention = f'`{ user_or_role } `'
328
+
329
+ if str (thread .id ) not in self .bot .config ['notification_squad' ]:
330
+ self .bot .config ['notification_squad' ][str (thread .id )] = []
331
+
332
+ mentions = self .bot .config ['notification_squad' ][str (thread .id )]
333
+
334
+ if mention not in mentions :
335
+ embed = discord .Embed (color = discord .Color .red (),
336
+ description = f'{ mention } does not have a '
337
+ 'pending notification.' )
338
+ else :
339
+ mentions .remove (mention )
340
+ await self .bot .config .update ()
341
+ embed = discord .Embed (color = self .bot .main_color ,
342
+ description = f'{ mention } will no longer '
343
+ 'be notified.' )
344
+ return await ctx .send (embed = embed )
345
+
307
346
@commands .command (aliases = ['sub' ])
308
347
@checks .has_permissions (PermissionLevel .SUPPORTER )
309
348
@checks .thread_only ()
310
- async def subscribe (self , ctx , * , role : Union [discord .Role , str .lower , None ] = None ):
349
+ async def subscribe (self , ctx , * , user_or_role : Union [discord .Role , User , str .lower , None ] = None ):
311
350
"""
312
- Notify a role or yourself for every thread message received.
351
+ Notify a user, role, or yourself for every thread message received.
313
352
314
353
You will be pinged for every thread message received until you unsubscribe.
315
354
316
- Leave `role ` empty to subscribe yourself.
355
+ Leave `user_or_role ` empty to subscribe yourself.
317
356
`@here` and `@everyone` can be substituted with `here` and `everyone`.
318
- `role ` may be a role ID, mention, name, "everyone", or "here".
357
+ `user_or_role ` may be a user ID, mention, name, role ID, mention, name, "everyone", or "here".
319
358
"""
320
359
thread = ctx .thread
321
360
322
- if role is None :
361
+ if user_or_role is None :
323
362
mention = ctx .author .mention
324
- elif isinstance ( role , discord . Role ):
325
- mention = role .mention
326
- elif role in {'here' , 'everyone' , '@here' , '@everyone' }:
327
- mention = '@' + role .lstrip ('@' )
363
+ elif hasattr ( user_or_role , 'mention' ):
364
+ mention = user_or_role .mention
365
+ elif user_or_role in {'here' , 'everyone' , '@here' , '@everyone' }:
366
+ mention = '@' + user_or_role .lstrip ('@' )
328
367
else :
329
- raise commands .BadArgument (f'{ role } is not a valid role.' )
368
+ raise commands .BadArgument (f'{ user_or_role } is not a valid role.' )
330
369
331
370
if str (thread .id ) not in self .bot .config ['subscriptions' ]:
332
371
self .bot .config ['subscriptions' ][str (thread .id )] = []
@@ -350,24 +389,24 @@ async def subscribe(self, ctx, *, role: Union[discord.Role, str.lower, None] = N
350
389
@commands .command (aliases = ['unsub' ])
351
390
@checks .has_permissions (PermissionLevel .SUPPORTER )
352
391
@checks .thread_only ()
353
- async def unsubscribe (self , ctx , * , role = None ):
392
+ async def unsubscribe (self , ctx , * , user_or_role : Union [ discord . Role , User , str . lower , None ] = None ):
354
393
"""
355
- Unsubscribe a role or yourself from a thread.
394
+ Unsubscribe a user, role, or yourself from a thread.
356
395
357
- Leave `role ` empty to unsubscribe yourself.
396
+ Leave `user_or_role ` empty to unsubscribe yourself.
358
397
`@here` and `@everyone` can be substituted with `here` and `everyone`.
359
- `role ` may be a role ID, mention, name, "everyone", or "here".
398
+ `user_or_role ` may be a user ID, mention, name, role ID, mention, name, "everyone", or "here".
360
399
"""
361
400
thread = ctx .thread
362
401
363
- if not role :
402
+ if user_or_role is None :
364
403
mention = ctx .author .mention
365
- elif role .lower () in ('here' , 'everyone' ):
366
- mention = '@' + role
404
+ elif hasattr (user_or_role , 'mention' ):
405
+ mention = user_or_role .mention
406
+ elif user_or_role in {'here' , 'everyone' , '@here' , '@everyone' }:
407
+ mention = '@' + user_or_role .lstrip ('@' )
367
408
else :
368
- converter = commands .RoleConverter ()
369
- role = await converter .convert (ctx , role )
370
- mention = role .mention
409
+ mention = f'`{ user_or_role } `'
371
410
372
411
if str (thread .id ) not in self .bot .config ['subscriptions' ]:
373
412
self .bot .config ['subscriptions' ][str (thread .id )] = []
0 commit comments