-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
68 lines (53 loc) · 2.12 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from discord.ext import commands
import config
from discord import Member
from discord.ext.commands import has_permissions, MissingPermissions
import asyncio
from datetime import datetime , timedelta
os.chdir('C:/Users/abe/Desktop')
words=['damn','green']
intents = discord.Intents.default()
intent = discord.Intents(messages=True, message_content=True, guilds=True)
bot = commands.Bot(intents=intents,command_prefix='.')
class Greetings(commands.Cog):
def __init__(self, bot):
self.bot = bot
self._last_member = None
@commands.Cog.listener()
async def on_member_join(self, member):
channel = member.guild.system_channel
if channel is not None:
await channel.send(f'Welcome {member.mention}.')
bot.add_cog(Greetings(bot))
@bot.event
async def on_ready():
print(f'We have logged in as {bot.user}')
count=0
@bot.event
async def on_message(msg):
for word in words:
if word in msg.content.lower():
await msg.delete()
global count
count+=1
print(count)
if count==3:
# await msg.channel.set_permissions(msg.author, read_messages=True,send_messages=False)
await msg.author.send("Please don't swear")
now=datetime.now().astimezone()
later=now+timedelta(minutes=2)
await msg.channel.send(f':white_check_mark: **User <@{msg.author}> time out until {later}')
if count==5:
await msg.channel.send(f':white_check_mark: **User <@{msg.author}> was muted!**')
now=datetime.now().astimezone()
later=now+timedelta(minutes=59)
await msg.author.timeout(later, reason=None)
print(f'User {msg.author} was muted!')
await msg.author.send("you will be kicked ")
elif count == 10:
await msg.author.send("last warning")
elif count==11:
await msg.guild.ban(msg.author, reason="spam")
await msg.channel.send(f'{msg.author} banned' )
await bot.process_commands(msg)
bot.run(TOKEN)