-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPD_Bot.py
247 lines (139 loc) Β· 6.44 KB
/
PD_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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
import requests
from PIL import Image
import discord
import random
from io import BytesIO
from discord.ext import commands
#Files Reading Io
f = open("rules.io","r")
rules = f.readlines()
f.close()
fLink = open("server.io","r")
server_link = fLink.readlines()
fLink.close()
with open("filterWord.io","r") as filterwr:
filteredWords = filterwr.read().split('\n')
filterwr.close()
warningWords = open("warningWord.io","r").read().split('\n')
greetingWords = ["Hey","Hello","Hi"]
#end File Reading
client = commands.Bot(command_prefix="<<")
pyCommand = ["It is in built python command it will print given argument to screen: ```Command : \n print('Hello world') \n Output : \n Hello world ```"]
@client.event
async def on_ready():
print("Bot is ready")
## Rules
@client.command()
async def rule(ctx,*,number=1):
try:
await ctx.send(rules[int(number)-1])
except:
await ctx.send("Program Dream have only 8 rules")
##clear message
@client.command()
@commands.has_permissions(manage_messages = True)
async def clear(ctx,amount=1):
try:
await ctx.channel.purge(limit = amount)
except:
pass
##Invite Link
@client.command()
async def invite_link(ctx,*,number=1):
try:
await ctx.send(server_link[int(number)-1])
except:
await ctx.send("I have only 4 invite link of Program Dream")
##Random Image
@client.command()
async def randomImage(ctx):
try:
response = requests.get('https://source.unsplash.com/random')
img = Image.open(BytesIO(response.content))
img.save('random.jpg')
await ctx.send(file = discord.File("random.jpg"))
except:
await ctx.send("Now, no random Image Present")
@client.command()
async def randomNumber(ctx,*,rang=99999):
try:
randomNumber = random.randint(0,rang)
await ctx.send(f"""Your random number Is : {randomNumber}""")
except:
await ctx.send(f"""Your Command Is Wrong xD""")
#___________________________________Filtered Word_______________________________#
#_______________________________________________________________________________#
@client.event
async def on_message(msg):
try:
for word in filteredWords:
if word in msg.content.lower():
await msg.delete()
id = msg.author.id
await msg.channel.send(f""":five: No racism, xenophobia, homophobia, etc.""")
await msg.channel.send(f"""<@{id}> {warningWords[random.randint(0,len(warningWords)-1)]}""")
except:
pass
if (msg.content[0:5].lower().find("hello") != -1):
await msg.channel.send(f"""<@{msg.author.id}> Hi ππ""")
if (msg.content[0:2].lower().find("hi") != -1):
await msg.channel.send(f"""<@{msg.author.id}> Hello β¨β¨""")
if (msg.content[0:3].find("hey") != -1):
await msg.channel.send(f"""<@{msg.author.id}> What's up Dude ππ""")
if (msg.content[0:4].lower().find("ping") != -1):
await msg.channel.send(f"""<@{msg.author.id}> :regional_indicator_p: :o2: :regional_indicator_n: :regional_indicator_g: β¨π""")
if (msg.content[0:4].lower().find("pong") != -1):
await msg.channel.send(f"""<@{msg.author.id}> :regional_indicator_p: :regional_indicator_i: :regional_indicator_n: :regional_indicator_g: ππ""")
if (msg.content[0:12].find("$sendMessage") != -1):
try:
for i in range(0,int(msg.content[13:14])):
await msg.channel.send(f"""{msg.content[15:len(msg.content)]}""")
except:
await msg.channel.send(f"""{msg.content[15:len(msg.content)]}""")
await client.process_commands(msg)
#___________________________________end filtered________________________________#
#_______________________________________________________________________________#
#___________________________________Welcome_____________________________________#
#_______________________________________________________________________________#
@client.event
async def on_member_join(member):
for channel in member.guild.channels:
if str(channel) == "general": # We check to make sure we are sending the message in the general channel
await channel.send_message(f"""Welcome to the server {member.mention}""")
await client.process_commands(member)
#___________________________________end Welcome_________________________________#
#_______________________________________________________________________________#
#__________________________________python_help__________________________________#
#_______________________________________________________________________________#
@client.command()
async def python(ctx,*,commandLine):
if commandLine == "print()":
await ctx.send(pyCommand[0])
#__________________________________python_help_end______________________________#
#_______________________________________________________________________________#
#__________________________________scripting____________________________________#
#_______________________________________________________________________________#
# @client.command()
# async def var(ctx,*,commandLine):
# symbol = commandLine
# symbolEqu = symbol.find("=")
# varName = symbol[0:symbolEqu]
# fileIo = open((varName+".txt"),"w")
# fileIo.write(symbol[symbolEqu+1:len(symbol)])
# fileIo.close()
# @client.command()
# async def echo(ctx,*,commandLine):
# try:
# fileIo = open((commandLine+".txt"),"r")
# varValue = fileIo.read()
# fileIo.close()
# await ctx.send(varValue)
# except:
# await ctx.send(commandLine)
#__________________________________scripting___end______________________________#
#_______________________________________________________________________________#
#_______________________________________________tic-tac-toe_game__________________________#
#_________________________________________________________________________________________#
#_______________________________________________tic-tac-toe_end___________________________#
#_________________________________________________________________________________________#
client.run("Tokens")