@@ -675,8 +675,11 @@ async def title(self, ctx, *, name: str):
675
675
@checks .has_permissions (PermissionLevel .SUPPORTER )
676
676
@checks .thread_only ()
677
677
@commands .cooldown (1 , 600 , BucketType .channel )
678
- async def adduser (self , ctx , * , user : discord .Member ):
679
- """Adds a user to a modmail thread"""
678
+ async def adduser (self , ctx , user : discord .Member , * , options : str .lower = "" ):
679
+ """Adds a user to a modmail thread
680
+
681
+ `options` can be `silent` or `silently`.
682
+ """
680
683
681
684
curr_thread = await self .bot .threads .find (recipient = user )
682
685
if curr_thread :
@@ -686,30 +689,88 @@ async def adduser(self, ctx, *, user: discord.Member):
686
689
color = self .bot .error_color ,
687
690
)
688
691
await ctx .send (embed = em )
692
+ ctx .command .reset_cooldown (ctx )
689
693
else :
694
+ if 'silent' not in options and 'silently' not in options :
695
+ em = discord .Embed (
696
+ title = "New Thread (Group)" ,
697
+ description = f"{ ctx .author .name } has added you to a Modmail thread." ,
698
+ color = self .bot .main_color ,
699
+ )
700
+ if self .bot .config ["show_timestamp" ]:
701
+ em .timestamp = datetime .utcnow ()
702
+ em .set_footer (text = f"{ ctx .author } " , icon_url = ctx .author .avatar_url )
703
+ await user .send (embed = em )
704
+
705
+ em = discord .Embed (
706
+ title = "New User" ,
707
+ description = f"{ ctx .author .name } has added { user .name } to the Modmail thread." ,
708
+ color = self .bot .main_color ,
709
+ )
710
+ if self .bot .config ["show_timestamp" ]:
711
+ em .timestamp = datetime .utcnow ()
712
+ em .set_footer (text = f"{ user } " , icon_url = user .avatar_url )
713
+
714
+ for i in ctx .thread .recipients :
715
+ if i != user :
716
+ await i .send (embed = em )
717
+
718
+ await ctx .thread .add_user (user )
719
+ sent_emoji , _ = await self .bot .retrieve_emoji ()
720
+ await self .bot .add_reaction (ctx .message , sent_emoji )
721
+
722
+ @commands .command (cooldown_after_parsing = True )
723
+ @checks .has_permissions (PermissionLevel .SUPPORTER )
724
+ @checks .thread_only ()
725
+ @commands .cooldown (1 , 600 , BucketType .channel )
726
+ async def removeuser (self , ctx , user : discord .Member , * , options : str .lower = "" ):
727
+ """Removes a user from a modmail thread
728
+
729
+ `options` can be `silent` or `silently`.
730
+ """
731
+
732
+ curr_thread = await self .bot .threads .find (recipient = user )
733
+ if ctx .thread != curr_thread :
690
734
em = discord .Embed (
691
- title = "New Thread (Group) " ,
692
- description = f" { ctx . author . name } has added you to a Modmail thread." ,
693
- color = self .bot .main_color ,
735
+ title = "Error " ,
736
+ description = "User is not in this thread." ,
737
+ color = self .bot .error_color ,
694
738
)
695
- if self .bot .config ["show_timestamp" ]:
696
- em .timestamp = datetime .utcnow ()
697
- em .set_footer (text = f"{ ctx .author } " , icon_url = ctx .author .avatar_url )
698
- await user .send (embed = em )
699
-
739
+ await ctx .send (embed = em )
740
+ ctx .command .reset_cooldown (ctx )
741
+ elif ctx .thread .recipient == user :
700
742
em = discord .Embed (
701
- title = "New User " ,
702
- description = f" { ctx . author . name } has added { user . name } to the Modmail thread." ,
703
- color = self .bot .main_color ,
743
+ title = "Error " ,
744
+ description = "User is the main recipient of the thread and cannot be removed ." ,
745
+ color = self .bot .error_color ,
704
746
)
705
- if self .bot .config ["show_timestamp" ]:
706
- em .timestamp = datetime .utcnow ()
707
- em .set_footer (text = f"{ user } " , icon_url = user .avatar_url )
747
+ await ctx .send (embed = em )
748
+ ctx .command .reset_cooldown (ctx )
749
+ else :
750
+ if 'silent' not in options and 'silently' not in options :
751
+ em = discord .Embed (
752
+ title = "Removed From Thread (Group)" ,
753
+ description = f"{ ctx .author .name } has been removed from the Modmail thread." ,
754
+ color = self .bot .main_color ,
755
+ )
756
+ if self .bot .config ["show_timestamp" ]:
757
+ em .timestamp = datetime .utcnow ()
758
+ em .set_footer (text = f"{ ctx .author } " , icon_url = ctx .author .avatar_url )
759
+ await user .send (embed = em )
708
760
709
- for i in ctx .thread .recipients :
710
- await i .send (embed = em )
761
+ em = discord .Embed (
762
+ title = "User Removed" ,
763
+ description = f"{ ctx .author .name } has removed { user .name } from the Modmail thread." ,
764
+ color = self .bot .main_color ,
765
+ )
766
+ if self .bot .config ["show_timestamp" ]:
767
+ em .timestamp = datetime .utcnow ()
768
+ em .set_footer (text = f"{ user } " , icon_url = user .avatar_url )
711
769
712
- await ctx .thread .add_user (user )
770
+ for i in ctx .thread .recipients :
771
+ await i .send (embed = em )
772
+
773
+ await ctx .thread .remove_user (user )
713
774
sent_emoji , _ = await self .bot .retrieve_emoji ()
714
775
await self .bot .add_reaction (ctx .message , sent_emoji )
715
776
0 commit comments