1
1
import asyncio
2
- from asyncio import tasks
3
2
import re
4
3
from datetime import datetime
5
4
from itertools import zip_longest
@@ -739,7 +738,7 @@ async def adduser(self, ctx, *users_arg: Union[discord.Member, discord.Role, str
739
738
ctx .command .reset_cooldown (ctx )
740
739
return
741
740
742
- tasks = []
741
+ to_exec = []
743
742
if not silent :
744
743
description = self .bot .formatter .format (
745
744
self .bot .config ["private_added_to_group_response" ], moderator = ctx .author
@@ -753,7 +752,7 @@ async def adduser(self, ctx, *users_arg: Union[discord.Member, discord.Role, str
753
752
em .timestamp = discord .utils .utcnow ()
754
753
em .set_footer (text = str (ctx .author ), icon_url = ctx .author .display_avatar .url )
755
754
for u in users :
756
- tasks .append (u .send (embed = em ))
755
+ to_exec .append (u .send (embed = em ))
757
756
758
757
description = self .bot .formatter .format (
759
758
self .bot .config ["public_added_to_group_response" ],
@@ -771,11 +770,11 @@ async def adduser(self, ctx, *users_arg: Union[discord.Member, discord.Role, str
771
770
772
771
for i in ctx .thread .recipients :
773
772
if i not in users :
774
- tasks .append (i .send (embed = em ))
773
+ to_exec .append (i .send (embed = em ))
775
774
776
775
await ctx .thread .add_users (users )
777
- if tasks :
778
- await asyncio .gather (* tasks )
776
+ if to_exec :
777
+ await asyncio .gather (* to_exec )
779
778
780
779
sent_emoji , _ = await self .bot .retrieve_emoji ()
781
780
await self .bot .add_reaction (ctx .message , sent_emoji )
@@ -832,7 +831,7 @@ async def removeuser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
832
831
ctx .command .reset_cooldown (ctx )
833
832
return
834
833
835
- tasks = []
834
+ to_exec = []
836
835
if not silent :
837
836
description = self .bot .formatter .format (
838
837
self .bot .config ["private_removed_from_group_response" ], moderator = ctx .author
@@ -846,7 +845,7 @@ async def removeuser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
846
845
em .timestamp = discord .utils .utcnow ()
847
846
em .set_footer (text = str (ctx .author ), icon_url = ctx .author .display_avatar .url )
848
847
for u in users :
849
- tasks .append (u .send (embed = em ))
848
+ to_exec .append (u .send (embed = em ))
850
849
851
850
description = self .bot .formatter .format (
852
851
self .bot .config ["public_removed_from_group_response" ],
@@ -864,11 +863,11 @@ async def removeuser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
864
863
865
864
for i in ctx .thread .recipients :
866
865
if i not in users :
867
- tasks .append (i .send (embed = em ))
866
+ to_exec .append (i .send (embed = em ))
868
867
869
868
await ctx .thread .remove_users (users )
870
- if tasks :
871
- await asyncio .gather (* tasks )
869
+ if to_exec :
870
+ await asyncio .gather (* to_exec )
872
871
873
872
sent_emoji , _ = await self .bot .retrieve_emoji ()
874
873
await self .bot .add_reaction (ctx .message , sent_emoji )
@@ -919,7 +918,7 @@ async def anonadduser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
919
918
ctx .command .reset_cooldown (ctx )
920
919
return
921
920
922
- tasks = []
921
+ to_exec = []
923
922
if not silent :
924
923
em = discord .Embed (
925
924
title = self .bot .config ["private_added_to_group_title" ],
@@ -941,7 +940,7 @@ async def anonadduser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
941
940
em .set_footer (text = name , icon_url = avatar_url )
942
941
943
942
for u in users :
944
- tasks .append (u .send (embed = em ))
943
+ to_exec .append (u .send (embed = em ))
945
944
946
945
description = self .bot .formatter .format (
947
946
self .bot .config ["public_added_to_group_description_anon" ],
@@ -958,11 +957,11 @@ async def anonadduser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
958
957
959
958
for i in ctx .thread .recipients :
960
959
if i not in users :
961
- tasks .append (i .send (embed = em ))
960
+ to_exec .append (i .send (embed = em ))
962
961
963
962
await ctx .thread .add_users (users )
964
- if tasks :
965
- await asyncio .gather (* tasks )
963
+ if to_exec :
964
+ await asyncio .gather (* to_exec )
966
965
967
966
sent_emoji , _ = await self .bot .retrieve_emoji ()
968
967
await self .bot .add_reaction (ctx .message , sent_emoji )
@@ -1008,7 +1007,7 @@ async def anonremoveuser(self, ctx, *users_arg: Union[discord.Member, discord.Ro
1008
1007
ctx .command .reset_cooldown (ctx )
1009
1008
return
1010
1009
1011
- tasks = []
1010
+ to_exec = []
1012
1011
if not silent :
1013
1012
em = discord .Embed (
1014
1013
title = self .bot .config ["private_removed_from_group_title" ],
@@ -1030,7 +1029,7 @@ async def anonremoveuser(self, ctx, *users_arg: Union[discord.Member, discord.Ro
1030
1029
em .set_footer (text = name , icon_url = avatar_url )
1031
1030
1032
1031
for u in users :
1033
- tasks .append (u .send (embed = em ))
1032
+ to_exec .append (u .send (embed = em ))
1034
1033
1035
1034
description = self .bot .formatter .format (
1036
1035
self .bot .config ["public_removed_from_group_description_anon" ],
@@ -1047,11 +1046,11 @@ async def anonremoveuser(self, ctx, *users_arg: Union[discord.Member, discord.Ro
1047
1046
1048
1047
for i in ctx .thread .recipients :
1049
1048
if i not in users :
1050
- tasks .append (i .send (embed = em ))
1049
+ to_exec .append (i .send (embed = em ))
1051
1050
1052
1051
await ctx .thread .remove_users (users )
1053
- if tasks :
1054
- await asyncio .gather (* tasks )
1052
+ if to_exec :
1053
+ await asyncio .gather (* to_exec )
1055
1054
1056
1055
sent_emoji , _ = await self .bot .retrieve_emoji ()
1057
1056
await self .bot .add_reaction (ctx .message , sent_emoji )
@@ -1253,6 +1252,50 @@ async def fareply(self, ctx, *, msg: str = ""):
1253
1252
async with ctx .typing ():
1254
1253
await ctx .thread .reply (ctx .message , anonymous = True )
1255
1254
1255
+ @commands .command (aliases = ["formatplainreply" ])
1256
+ @checks .has_permissions (PermissionLevel .SUPPORTER )
1257
+ @checks .thread_only ()
1258
+ async def fpreply (self , ctx , * , msg : str = "" ):
1259
+ """
1260
+ Reply to a Modmail thread with variables and a plain message.
1261
+
1262
+ Works just like `{prefix}areply`, however with the addition of three variables:
1263
+ - `{{channel}}` - the `discord.TextChannel` object
1264
+ - `{{recipient}}` - the `discord.User` object of the recipient
1265
+ - `{{author}}` - the `discord.User` object of the author
1266
+
1267
+ Supports attachments and images as well as
1268
+ automatically embedding image URLs.
1269
+ """
1270
+ msg = self .bot .formatter .format (
1271
+ msg , channel = ctx .channel , recipient = ctx .thread .recipient , author = ctx .message .author
1272
+ )
1273
+ ctx .message .content = msg
1274
+ async with ctx .typing ():
1275
+ await ctx .thread .reply (ctx .message , plain = True )
1276
+
1277
+ @commands .command (aliases = ["formatplainanonreply" ])
1278
+ @checks .has_permissions (PermissionLevel .SUPPORTER )
1279
+ @checks .thread_only ()
1280
+ async def fpareply (self , ctx , * , msg : str = "" ):
1281
+ """
1282
+ Anonymously reply to a Modmail thread with variables and a plain message.
1283
+
1284
+ Works just like `{prefix}areply`, however with the addition of three variables:
1285
+ - `{{channel}}` - the `discord.TextChannel` object
1286
+ - `{{recipient}}` - the `discord.User` object of the recipient
1287
+ - `{{author}}` - the `discord.User` object of the author
1288
+
1289
+ Supports attachments and images as well as
1290
+ automatically embedding image URLs.
1291
+ """
1292
+ msg = self .bot .formatter .format (
1293
+ msg , channel = ctx .channel , recipient = ctx .thread .recipient , author = ctx .message .author
1294
+ )
1295
+ ctx .message .content = msg
1296
+ async with ctx .typing ():
1297
+ await ctx .thread .reply (ctx .message , anonymous = True , plain = True )
1298
+
1256
1299
@commands .command (aliases = ["anonreply" , "anonymousreply" ])
1257
1300
@checks .has_permissions (PermissionLevel .SUPPORTER )
1258
1301
@checks .thread_only ()
0 commit comments