@@ -671,39 +671,60 @@ async def title(self, ctx, *, name: str):
671
671
await ctx .message .pin ()
672
672
await self .bot .add_reaction (ctx .message , sent_emoji )
673
673
674
- @commands .command (usage = "<users > [options]" , cooldown_after_parsing = True )
674
+ @commands .command (usage = "<users_or_roles... > [options]" , cooldown_after_parsing = True )
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 , * users : Union [discord .Member , str ]):
678
+ async def adduser (self , ctx , * users_arg : Union [discord .Member , discord . Role , str ]):
679
679
"""Adds a user to a modmail thread
680
680
681
681
`options` can be `silent` or `silently`.
682
682
"""
683
683
silent = False
684
- for u in users :
684
+ users = []
685
+ for u in users_arg :
685
686
if isinstance (u , str ):
686
687
if "silent" in u or "silently" in u :
687
688
silent = True
688
- users .remove (u ) # remove all strings so users is a List[Member]
689
- else :
690
- # u is a discord.Member
691
- curr_thread = await self .bot .threads .find (recipient = u )
692
- if curr_thread :
693
- em = discord .Embed (
694
- title = "Error" ,
695
- description = f"{ u .mention } is already in a thread: { curr_thread .channel .mention } ." ,
696
- color = self .bot .error_color ,
697
- )
698
- await ctx .send (embed = em )
699
- ctx .command .reset_cooldown (ctx )
700
- return
689
+ elif isinstance (u , discord .Role ):
690
+ users += u .members
691
+ elif isinstance (u , discord .Member ):
692
+ users .append (u )
693
+
694
+ for u in users :
695
+ # u is a discord.Member
696
+ curr_thread = await self .bot .threads .find (recipient = u )
697
+ if curr_thread == ctx .thread :
698
+ users .remove (u )
699
+ continue
700
+
701
+ if curr_thread :
702
+ em = discord .Embed (
703
+ title = "Error" ,
704
+ description = f"{ u .mention } is already in a thread: { curr_thread .channel .mention } ." ,
705
+ color = self .bot .error_color ,
706
+ )
707
+ await ctx .send (embed = em )
708
+ ctx .command .reset_cooldown (ctx )
709
+ return
710
+
711
+ if not users :
712
+ em = discord .Embed (
713
+ title = "Error" ,
714
+ description = "All users are already in the thread." ,
715
+ color = self .bot .error_color ,
716
+ )
717
+ await ctx .send (embed = em )
718
+ ctx .command .reset_cooldown (ctx )
719
+ return
720
+
701
721
if not silent :
722
+ description = self .bot .formatter .format (
723
+ self .bot .config ["private_added_to_group_description" ], moderator = ctx .author
724
+ )
702
725
em = discord .Embed (
703
726
title = self .bot .config ["private_added_to_group_title" ],
704
- description = self .bot .config ["private_added_to_group_description" ].format (
705
- moderator = ctx .author
706
- ),
727
+ description = description ,
707
728
color = self .bot .main_color ,
708
729
)
709
730
if self .bot .config ["show_timestamp" ]:
@@ -712,11 +733,14 @@ async def adduser(self, ctx, *users: Union[discord.Member, str]):
712
733
for u in users :
713
734
await u .send (embed = em )
714
735
736
+ description = self .bot .formatter .format (
737
+ self .bot .config ["public_added_to_group_description" ],
738
+ moderator = ctx .author ,
739
+ users = ", " .join (u .name for u in users ),
740
+ )
715
741
em = discord .Embed (
716
742
title = self .bot .config ["public_added_to_group_title" ],
717
- description = self .bot .config ["private_added_to_group_description" ].format (
718
- moderator = ctx .author , users = ", " .join (u .name for u in users )
719
- ),
743
+ description = description ,
720
744
color = self .bot .main_color ,
721
745
)
722
746
if self .bot .config ["show_timestamp" ]:
@@ -731,49 +755,55 @@ async def adduser(self, ctx, *users: Union[discord.Member, str]):
731
755
sent_emoji , _ = await self .bot .retrieve_emoji ()
732
756
await self .bot .add_reaction (ctx .message , sent_emoji )
733
757
734
- @commands .command (usage = "<users ...> [options]" , cooldown_after_parsing = True )
758
+ @commands .command (usage = "<users_or_roles ...> [options]" , cooldown_after_parsing = True )
735
759
@checks .has_permissions (PermissionLevel .SUPPORTER )
736
760
@checks .thread_only ()
737
761
@commands .cooldown (1 , 600 , BucketType .channel )
738
- async def removeuser (self , ctx , * users : Union [discord .Member , str ]):
762
+ async def removeuser (self , ctx , * users_arg : Union [discord .Member , discord . Role , str ]):
739
763
"""Removes a user from a modmail thread
740
764
741
765
`options` can be `silent` or `silently`.
742
766
"""
743
767
silent = False
744
- for u in users :
768
+ users = []
769
+ for u in users_arg :
745
770
if isinstance (u , str ):
746
771
if "silent" in u or "silently" in u :
747
772
silent = True
748
- users .remove (u ) # remove all strings so users is a List[Member]
749
- else :
750
- # u is a discord.Member
751
- curr_thread = await self .bot .threads .find (recipient = u )
752
- if ctx .thread != curr_thread :
753
- em = discord .Embed (
754
- title = "Error" ,
755
- description = f"{ u .mention } is not in this thread." ,
756
- color = self .bot .error_color ,
757
- )
758
- await ctx .send (embed = em )
759
- ctx .command .reset_cooldown (ctx )
760
- return
761
- elif ctx .thread .recipient == u :
762
- em = discord .Embed (
763
- title = "Error" ,
764
- description = f"{ u .mention } is the main recipient of the thread and cannot be removed." ,
765
- color = self .bot .error_color ,
766
- )
767
- await ctx .send (embed = em )
768
- ctx .command .reset_cooldown (ctx )
769
- return
773
+ elif isinstance (u , discord .Role ):
774
+ users += u .members
775
+ elif isinstance (u , discord .Member ):
776
+ users .append (u )
777
+
778
+ for u in users :
779
+ # u is a discord.Member
780
+ curr_thread = await self .bot .threads .find (recipient = u )
781
+ if ctx .thread != curr_thread :
782
+ em = discord .Embed (
783
+ title = "Error" ,
784
+ description = f"{ u .mention } is not in this thread." ,
785
+ color = self .bot .error_color ,
786
+ )
787
+ await ctx .send (embed = em )
788
+ ctx .command .reset_cooldown (ctx )
789
+ return
790
+ elif ctx .thread .recipient == u :
791
+ em = discord .Embed (
792
+ title = "Error" ,
793
+ description = f"{ u .mention } is the main recipient of the thread and cannot be removed." ,
794
+ color = self .bot .error_color ,
795
+ )
796
+ await ctx .send (embed = em )
797
+ ctx .command .reset_cooldown (ctx )
798
+ return
770
799
771
800
if not silent :
801
+ description = self .bot .formatter .format (
802
+ self .bot .config ["private_removed_from_group_description" ], moderator = ctx .author
803
+ )
772
804
em = discord .Embed (
773
805
title = self .bot .config ["private_removed_from_group_title" ],
774
- description = self .bot .config ["private_removed_from_group_description" ].format (
775
- moderator = ctx .author
776
- ),
806
+ description = description ,
777
807
color = self .bot .main_color ,
778
808
)
779
809
if self .bot .config ["show_timestamp" ]:
@@ -782,11 +812,14 @@ async def removeuser(self, ctx, *users: Union[discord.Member, str]):
782
812
for u in users :
783
813
await u .send (embed = em )
784
814
815
+ description = self .bot .formatter .format (
816
+ self .bot .config ["public_removed_from_group_description" ],
817
+ moderator = ctx .author ,
818
+ users = ", " .join (u .name for u in users ),
819
+ )
785
820
em = discord .Embed (
786
821
title = self .bot .config ["public_removed_from_group_title" ],
787
- description = self .bot .config ["private_removed_from_group_description" ].format (
788
- moderator = ctx .author , users = ", " .join (u .name for u in users )
789
- ),
822
+ description = description ,
790
823
color = self .bot .main_color ,
791
824
)
792
825
if self .bot .config ["show_timestamp" ]:
@@ -801,33 +834,52 @@ async def removeuser(self, ctx, *users: Union[discord.Member, str]):
801
834
sent_emoji , _ = await self .bot .retrieve_emoji ()
802
835
await self .bot .add_reaction (ctx .message , sent_emoji )
803
836
804
- @commands .command (usage = "<users ...> [options]" , cooldown_after_parsing = True )
837
+ @commands .command (usage = "<users_or_roles ...> [options]" , cooldown_after_parsing = True )
805
838
@checks .has_permissions (PermissionLevel .SUPPORTER )
806
839
@checks .thread_only ()
807
840
@commands .cooldown (1 , 600 , BucketType .channel )
808
- async def anonadduser (self , ctx , * users : Union [discord .Member , str ]):
841
+ async def anonadduser (self , ctx , * users_arg : Union [discord .Member , discord . Role , str ]):
809
842
"""Adds a user to a modmail thread anonymously
810
843
811
844
`options` can be `silent` or `silently`.
812
845
"""
813
846
silent = False
814
- for u in users :
847
+ users = []
848
+ for u in users_arg :
815
849
if isinstance (u , str ):
816
850
if "silent" in u or "silently" in u :
817
851
silent = True
818
- users .remove (u ) # remove all strings so users is a List[Member]
819
- else :
820
- # u is a discord.Member
821
- curr_thread = await self .bot .threads .find (recipient = u )
822
- if curr_thread :
823
- em = discord .Embed (
824
- title = "Error" ,
825
- description = f"{ u .mention } is already in a thread: { curr_thread .channel .mention } ." ,
826
- color = self .bot .error_color ,
827
- )
828
- await ctx .send (embed = em )
829
- ctx .command .reset_cooldown (ctx )
830
- return
852
+ elif isinstance (u , discord .Role ):
853
+ users += u .members
854
+ elif isinstance (u , discord .Member ):
855
+ users .append (u )
856
+
857
+ for u in users :
858
+ curr_thread = await self .bot .threads .find (recipient = u )
859
+ if curr_thread == ctx .thread :
860
+ users .remove (u )
861
+ continue
862
+
863
+ if curr_thread :
864
+ em = discord .Embed (
865
+ title = "Error" ,
866
+ description = f"{ u .mention } is already in a thread: { curr_thread .channel .mention } ." ,
867
+ color = self .bot .error_color ,
868
+ )
869
+ await ctx .send (embed = em )
870
+ ctx .command .reset_cooldown (ctx )
871
+ return
872
+
873
+ if not users :
874
+ em = discord .Embed (
875
+ title = "Error" ,
876
+ description = "All users are already in the thread." ,
877
+ color = self .bot .error_color ,
878
+ )
879
+ await ctx .send (embed = em )
880
+ ctx .command .reset_cooldown (ctx )
881
+ return
882
+
831
883
if not silent :
832
884
em = discord .Embed (
833
885
title = self .bot .config ["private_added_to_group_title" ],
@@ -851,11 +903,13 @@ async def anonadduser(self, ctx, *users: Union[discord.Member, str]):
851
903
for u in users :
852
904
await u .send (embed = em )
853
905
906
+ description = self .bot .formatter .format (
907
+ self .bot .config ["public_added_to_group_description_anon" ],
908
+ users = ", " .join (u .name for u in users ),
909
+ )
854
910
em = discord .Embed (
855
911
title = self .bot .config ["public_added_to_group_title" ],
856
- description = self .bot .config ["private_added_to_group_description_anon" ].format (
857
- moderator = ctx .author , users = ", " .join (u .name for u in users )
858
- ),
912
+ description = description ,
859
913
color = self .bot .main_color ,
860
914
)
861
915
if self .bot .config ["show_timestamp" ]:
@@ -870,49 +924,51 @@ async def anonadduser(self, ctx, *users: Union[discord.Member, str]):
870
924
sent_emoji , _ = await self .bot .retrieve_emoji ()
871
925
await self .bot .add_reaction (ctx .message , sent_emoji )
872
926
873
- @commands .command (usage = "<users ...> [options]" , cooldown_after_parsing = True )
927
+ @commands .command (usage = "<users_or_roles ...> [options]" , cooldown_after_parsing = True )
874
928
@checks .has_permissions (PermissionLevel .SUPPORTER )
875
929
@checks .thread_only ()
876
930
@commands .cooldown (1 , 600 , BucketType .channel )
877
- async def anonremoveuser (self , ctx , * users : Union [discord .Member , str ]):
931
+ async def anonremoveuser (self , ctx , * users_arg : Union [discord .Member , discord . Role , str ]):
878
932
"""Removes a user from a modmail thread anonymously
879
933
880
934
`options` can be `silent` or `silently`.
881
935
"""
882
936
silent = False
883
- for u in users :
937
+ users = []
938
+ for u in users_arg :
884
939
if isinstance (u , str ):
885
940
if "silent" in u or "silently" in u :
886
941
silent = True
887
- users .remove (u ) # remove all strings so users is a List[Member]
888
- else :
889
- # u is a discord.Member
890
- curr_thread = await self .bot .threads .find (recipient = u )
891
- if ctx .thread != curr_thread :
892
- em = discord .Embed (
893
- title = "Error" ,
894
- description = f"{ u .mention } is not in this thread." ,
895
- color = self .bot .error_color ,
896
- )
897
- await ctx .send (embed = em )
898
- ctx .command .reset_cooldown (ctx )
899
- return
900
- elif ctx .thread .recipient == u :
901
- em = discord .Embed (
902
- title = "Error" ,
903
- description = f"{ u .mention } is the main recipient of the thread and cannot be removed." ,
904
- color = self .bot .error_color ,
905
- )
906
- await ctx .send (embed = em )
907
- ctx .command .reset_cooldown (ctx )
908
- return
942
+ elif isinstance (u , discord .Role ):
943
+ users += u .members
944
+ elif isinstance (u , discord .Member ):
945
+ users .append (u )
946
+
947
+ for u in users :
948
+ curr_thread = await self .bot .threads .find (recipient = u )
949
+ if ctx .thread != curr_thread :
950
+ em = discord .Embed (
951
+ title = "Error" ,
952
+ description = f"{ u .mention } is not in this thread." ,
953
+ color = self .bot .error_color ,
954
+ )
955
+ await ctx .send (embed = em )
956
+ ctx .command .reset_cooldown (ctx )
957
+ return
958
+ elif ctx .thread .recipient == u :
959
+ em = discord .Embed (
960
+ title = "Error" ,
961
+ description = f"{ u .mention } is the main recipient of the thread and cannot be removed." ,
962
+ color = self .bot .error_color ,
963
+ )
964
+ await ctx .send (embed = em )
965
+ ctx .command .reset_cooldown (ctx )
966
+ return
909
967
910
968
if not silent :
911
969
em = discord .Embed (
912
970
title = self .bot .config ["private_removed_from_group_title" ],
913
- description = self .bot .config ["private_removed_from_group_description_anon" ].format (
914
- moderator = ctx .author
915
- ),
971
+ description = self .bot .config ["private_removed_from_group_description_anon" ],
916
972
color = self .bot .main_color ,
917
973
)
918
974
if self .bot .config ["show_timestamp" ]:
@@ -932,11 +988,13 @@ async def anonremoveuser(self, ctx, *users: Union[discord.Member, str]):
932
988
for u in users :
933
989
await u .send (embed = em )
934
990
991
+ description = self .bot .formatter .format (
992
+ self .bot .config ["public_removed_from_group_description_anon" ],
993
+ users = ", " .join (u .name for u in users ),
994
+ )
935
995
em = discord .Embed (
936
996
title = self .bot .config ["public_removed_from_group_title" ],
937
- description = self .bot .config ["private_removed_from_group_description" ].format (
938
- moderator = ctx .author , users = ", " .join (u .name for u in users )
939
- ),
997
+ description = description ,
940
998
color = self .bot .main_color ,
941
999
)
942
1000
if self .bot .config ["show_timestamp" ]:
0 commit comments