File tree 1 file changed +21
-1
lines changed
1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1
1
2
- from redbot .core import commands
2
+ from datetime import datetime , timedelta
3
+
4
+ from redbot .core import checks , commands
3
5
4
6
5
7
class Ktbpa (commands .Cog ):
@@ -31,5 +33,23 @@ async def whoami(self, ctx):
31
33
else :
32
34
return await ctx .send ("%s. Role: %s." % (who .display_name , role .name ))
33
35
36
+ @commands .command ()
37
+ @commands .guild_only ()
38
+ @checks .mod_or_permissions (ban_members = True )
39
+ @checks .bot_has_permissions (ban_members = True )
40
+ async def loadban (self , ctx , period : commands .converter .TimedeltaConverter ):
41
+ """Bans everyone who joined the guild in the given time before now."""
42
+ limiter = timedelta (hours = 12 )
43
+ if period > limiter :
44
+ await ctx .send (f"Error: Loadban can only be used for up to { limiter .seconds / 3600 } hours." )
45
+ else :
46
+ banned = []
47
+ async for member in ctx .guild .fetch_members (after = (datetime .now () - period )):
48
+ if len ([role for role in member .roles if role != ctx .guild .default_role ]) == 0 :
49
+ banned .append (str (member .id ))
50
+ await member .ban (reason = "Loadban" , delete_message_days = 1 )
51
+
52
+ await ctx .send (f"Banned { len (banned )} users: { ', ' .join (banned )} " )
53
+
34
54
def cog_unload (self ):
35
55
self .bot .remove_listener (self .on_message , 'on_message' )
You can’t perform that action at this time.
0 commit comments