11from discord .ext import commands
2+ import os
3+ from dotenv import load_dotenv
24
35class Moderation (commands .Cog ):
46
57 def __init__ (self , client ):
68 self .bot = client
9+ member = os .getenv ("MEMBER_ROLE" )
10+ moderator = os .getenv ("MODERATOR_ROLE" )
711
812
913 @commands .command (aliases = ['Lock' , 'LOCK' ])
@@ -31,6 +35,7 @@ async def nick(self, ctx, member: discord.Member, name):
3135 @commands .has_permissions (manage_messages = True )
3236 async def clear (self , ctx , amount : int ):
3337 await ctx .message .delete ()
38+ await ctx .send ("Clearing messages, this may take a while.." , delete_after = 10 )
3439 await ctx .channel .purge (limit = amount )
3540 await ctx .send (f'{ amount } messages has been cleared' , delete_after = 5 )
3641
@@ -57,9 +62,13 @@ async def slowmode(self, ctx, time: int):
5762 embed = discord .Embed (title = 'Slowmode turned off' )
5863 await ctx .send (embed = embed )
5964 await ctx .channel .edit (slowmode_delay = 0 )
65+ if time == "off" :
66+ embed = discord .Embed (title = 'Slowmode turned off' )
67+ await ctx .send (embed = embed )
68+ await ctx .channel .edit (slowmode_delay = 0 )
6069 elif time > 21600 :
6170 embed = discord .Embed (
62- title = 'You cannot have a slowmode above 6hrs .' )
71+ title = 'You cannot have a slowmode above 6 hours. .' )
6372 await ctx .send (embed = embed )
6473 else :
6574 await ctx .channel .edit (slowmode_delay = time )
@@ -75,37 +84,6 @@ async def softban(self, ctx, member: discord.Member, *, reason='No reason provid
7584 embed = discord .Embed (title = f'Successfully softbanned { member } ' )
7685 await ctx .send (embed = embed )
7786
78- @commands .command (aliases = ['Tempban' , 'TempBan' , 'TEMPBAN' ])
79- async def tempban (self , ctx , member : discord .Member , time , * , reason = 'No Reason Provided' ):
80- with open ('guild.json' , 'r' ) as f :
81- channels = json .load (f )
82- indicator = time [- 1 ]
83- if indicator == "m" or indicator == "s" or indicator == 'h' or indicator == 'd' :
84- pass
85- else :
86- await ctx .send ('Incorrect Time Format.' )
87- embed = discord .Embed (
88- title = f'{ member } has been temp banned for { time } .' )
89- await ctx .send (embed = embed )
90- await member .ban (reason = reason )
91- chanid = channels [str (ctx .guild .id )]['admin' ][0 ]['adid' ]
92- channel = self .bot .get_channel (chanid )
93- embed = discord .Embed (title = 'Member Tempbanned!' ,
94- color = discord .Colour .red ())
95- embed .add_field (
96- name = f'{ member } was tempbanned({ time } ) from { ctx .guild .name } for: ' , value = f'{ reason } ' )
97- await channel .send (embed = embed )
98- time = time [:- 1 ]
99- if indicator == 'm' :
100- await asyncio .sleep (int (time ) * 60 )
101- elif indicator == 'h' :
102- await asyncio .sleep (int (time ) * 3600 )
103- elif indicator == 's' :
104- await asyncio .sleep (int (time ))
105- elif indicator == 'd' :
106- await asyncio .sleep (int (time ) * 86400 )
107- await member .unban (reason = 'Timer has expired.' )
108-
10987 @commands .command (aliases = ['Ban' , 'BAN' ])
11088 @commands .has_permissions (ban_members = True )
11189 async def ban (self , ctx , member : discord .Member = None , * , reason = None ):
@@ -148,7 +126,7 @@ async def kick(self, ctx, member: discord.Member = None, *, reason='No reason pr
148126 em = discord .Embed (title = f'You kicked { member } ' )
149127 await ctx .send (embed = em )
150128 embed = discord .Embed (
151- title = 'You have been kicked from The Coding Community ' , description = f'Kicked by { member } ' )
129+ title = f 'You have been kicked from { ctx . guild . name } ' , description = f'Kicked by { member } ' )
152130 embed .add_field (name = 'Reason:' , value = f'{ reason } ' )
153131 await member .send (embed = embed )
154132
0 commit comments