-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
81 lines (65 loc) · 2.55 KB
/
bot.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
69
70
71
72
73
74
75
76
77
78
79
80
81
import os#imports library for os
import discord #imports library for dicord.py
from discord import file
TOKEN={your_bot_token}
GUILD={your_guild_name}
#main loop
client=discord.Client()
@client.event #
async def on_ready():
for guild in client.guilds:
if guild.name == GUILD:
break
print(f'{client.user.name} has connected to Discord!\n'
f'{guild.name}(id: {guild.id})'
)
@client.event
async def on_member_join(member):
await member.create_dm()
await member.dm_channel.send(
f'Hi {member.name}, welcome to ECE23!\n'
f'"Kindly Introduce Yourself!"'
)
channel = discord.utils.get(member.guild.text_channels, name="general")
await channel.send(f'Welcome to the server {member.mention}! \n'
f'Kindly Introduce Yourself here! ')
@client.event
async def on_message(message):
if message.author==client.user:
return
known={"!hi":"Hey, how are you?","!favorite character":"Yamori from TKG.","!whats your age?":"Does it matter.","!who are you?":"Your future master, but rn I'm just a little bot."}
imgList=os.listdir("./images")
imgDir=['201','202','203','204','212','213','214','301','302','303','304','311','312','316']
if str(message.content) in known:
await message.channel.send(
f'{known[message.content]}'
)
elif message.content=="!help":
await message.dm_channel.send(
f'Go to resources!'
)
elif message.content=="!Syl2":
await message.channel.send(
f'Commands for syllabus of second semester:\n'
'!S-201- Engineering Mathematics\n'
'!S-203- Engineering Chemistry\n'
'!S-204- Basic Electronics\n'
'!S-202- Engineering Physics\n'
'!S-214- Basic Electronics Lab\n'
'!S-213- Physics Lab\n'
'!S-212- Chemistry Lab\n'
)
elif message.content=="!Syl3":
await message.channel.send(
f'Commands for syllabus of third semester:\n'
'!S-301- Computer Programming\n'
'!S-302- Electronic Devices and Circuits\n'
'!S-303- Signals and Systems\n'
'!S-304- Electrical Network Theory\n'
'!S-312- Electronic Devices Lab\n'
'!S-316- Circuit Simulation Lab\n'
'!S-311- Computer Programming Lab\n'
)
elif str(str(message.content)[3:]) in imgDir:
await message.channel.send( file=discord.File("./images/"+str(str(message.content)[3:])+".jpg"))
client.run(TOKEN)