-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
362 lines (229 loc) · 10.5 KB
/
app.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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
import requests
import os
import discord
from plugin import quote
from cloud import alive
from menu import menus
from update import reloads
import config
from plugin import random_img
from plugin import color
from plugin import google
from plugin import cmd
from plugin import status
from plugin import textsty
from plugin import spam
from plugin import youtube
from plugin import tagall
if config.config['Local_Run'] == False:
_BotName = os.environ['Bot_Name']
_ChannelId = os.environ['Channel_ID']
_AliveMsg = os.environ['Alive_msg']
_MenuName = os.environ['Menu_Name']
_Tkey = os.environ['TOKEN']
_AliveImg = os.environ['pic_url']
else:
_BotName = config.config['bot_name']
_ChannelId = config.config['channel_id']
_AliveMsg = config.config['alive_msg']
_MenuName = config.config['menu_name']
_Tkey = config.config['TOKEN']
_AliveImg = config.config['pic_url']
# config names
_google = cmd.cmd['google']
_quote = cmd.cmd['quote']
_alive = cmd.cmd['alive']
_list = cmd.cmd['list']
_restart = cmd.cmd['restart']
_pic = cmd.cmd['ran_pic']
_clear = cmd.cmd['clear']
_error = cmd.msgs['error']
_errorMsg = cmd.msgs['error_msg']
_active = cmd.msgs['active']
_dev = cmd.msgs['dev']
#intents = discord.Intents(messages=True, guilds=True)
intents = discord.Intents.default()
intents.message_content = True
intents.members = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
color.printbanner()
print(f'We have logged in as {client.user}')
print(_active)
print(_dev)
try:
channel_id = int(_ChannelId)
channel = client.get_channel(channel_id)
embed = discord.Embed(title="Online", description='Bot is online', color=color.emcolor())
if isinstance(channel, discord.TextChannel) or isinstance(channel, discord.DMChannel):
await channel.send(embed=embed)
else:
print("The channel is not a TextChannel or DMChannel")
except:
print('Enter Channel id')
application = await client.application_info()
owner = application.owner
embed = discord.Embed(title="Online", description='Bot is online', color=color.emcolor())
await owner.send(embed=embed)
embed = discord.Embed(title=_MenuName, description=menus(), color=color.emcolor())
await owner.send(embed=embed)
@client.event
async def on_message(message):
if message.author == client.user:
return
# random quote generate
if message.content.startswith(_quote):
try:
embed = discord.Embed(title="Quote", description=quote.quote(), color=color.emcolor())
imgs = random_img.random_img()
embed.set_image(url=imgs)
await message.channel.send(embed=embed)
except:
embed = discord.Embed(title= _error, description= _errorMsg, color=color.emcolor())
await message.channel.send(embed=embed)
# alive message
if message.content.startswith(_alive):
embed = discord.Embed(title=_AliveMsg, description=_BotName, color=color.emcolor())
imgs = _AliveImg
embed.set_image(url=imgs)
await message.channel.send(embed=embed)
#list
if message.content.startswith(_list):
try:
embed = discord.Embed(title=_MenuName, description=menus(), color=color.emcolor())
await message.channel.send(embed=embed)
except:
embed = discord.Embed(title= _error, description= _errorMsg, color=color.emcolor())
await message.channel.send(embed=embed)
#restart
if message.content.startswith(_restart):
try:
embed = discord.Embed(title="Update....", description='Restarting....♻', color=color.emcolor())
await message.channel.send(embed=embed)
await reloads(message)
except:
embed = discord.Embed(title= _error, description= _errorMsg, color=color.emcolor())
await message.channel.send(embed=embed)
#down server
if message.content.startswith('.logout'):
embed = discord.Embed(title="Shutdown", description='Have a nice day', color=color.emcolor())
await message.channel.send(embed=embed)
await client.close()
# random picture generate
if message.content.startswith(_pic):
try:
url = random_img.random_img()
embed = discord.Embed()
embed.set_image(url=url)
embed.description = f'Random Picture by {_BotName}'
await message.channel.send(embed=embed)
except:
embed = discord.Embed(title= _error, description= _errorMsg, color=color.emcolor())
await message.channel.send(embed=embed)
#google serch engine
if message.content.startswith(_google):
try:
url_str = google.google(message)
embed = discord.Embed(title=f"{_BotName} Search Engine", description=url_str, color=color.emcolor())
await message.channel.send(embed=embed)
except:
embed = discord.Embed(title= _error, description= _errorMsg, color=color.emcolor())
await message.channel.send(embed=embed)
#chat clear
if message.content == _clear:
try:
if message.author.guild_permissions.manage_messages:
deleted = await message.channel.purge(limit=10)
embed = discord.Embed(title=f"{_BotName} Clear", description=f'Deleted {len(deleted)} messages.', color=color.emcolor())
await message.channel.send(embed=embed)
else:
embed = discord.Embed(title=_error, description='You do not have permission to use this command.', color=color.emcolor())
await message.channel.send(embed=embed)
except Exception as e:
embed = discord.Embed(title= _error, description='This command work only in the channel', color=color.emcolor())
await message.channel.send(embed=embed)
#server status
if message.content == '.status':
try:
await message.channel.send(embed=status.status(message))
except:
embed = discord.Embed(title= _error, description= 'This command work only in the channel', color=color.emcolor())
await message.channel.send(embed=embed)
#developer info
if message.content == '.dev':
try:
url = cmd.dev['img_url']
embed = discord.Embed()
embed.set_image(url=url)
embed.title = 'Developer Info'
embed.description = f'**Name: **Sahan Sandaruwan \n **Web: ** https://sahansandaruwan.pages.dev \n **GitHub URL: ** https://github.com/sahansandaruwan \n **Repo URL: **https://github.com/sahansandaruwan/bigboss'
await message.channel.send(embed=embed)
except:
embed = discord.Embed(title= _error, description= _errorMsg, color=color.emcolor())
await message.channel.send(embed=embed)
#spam message
if message.content.startswith('.textspam'):
try:
num = spam.textspam(message)
for i in range(num):
await message.channel.send(f'spam number {i}')
except:
embed = discord.Embed(title= _error, description= _errorMsg, color=color.emcolor())
await message.channel.send(embed=embed)
#text markup menu
if message.content == '.textmark':
try:
embed = discord.Embed(title=f"{_BotName} Discord Text Markdown", description=textsty.textstylemenu(), color=color.emcolor())
await message.channel.send(embed=embed)
except:
embed = discord.Embed(title= _error, description= _errorMsg, color=color.emcolor())
await message.channel.send(embed=embed)
#text markup engin
if message.content.startswith('.bold'):
textbold = textsty.textbold(message)
embed = discord.Embed(title=f"{_BotName} Text Bold", description=textbold, color=color.emcolor())
await message.channel.send(embed=embed)
if message.content.startswith('.italic'):
TextItalic = textsty.TextItalics(message)
embed = discord.Embed(title=f"{_BotName} Text Italics", description=TextItalic, color=color.emcolor())
await message.channel.send(embed=embed)
if message.content.startswith('.botalic'):
BoldItalic = textsty.BoldItalics(message)
embed = discord.Embed(title=f"{_BotName} Bold Italics", description=BoldItalic, color=color.emcolor())
await message.channel.send(embed=embed)
if message.content.startswith('.underline'):
TextUnderlin = textsty.TextUnderline(message)
embed = discord.Embed(title=f"{_BotName} Text Underline", description=TextUnderlin, color=color.emcolor())
await message.channel.send(embed=embed)
if message.content.startswith('.codeblock'):
CodeBloc = textsty.CodeBlocks(message)
embed = discord.Embed(title=f"{_BotName} Code Blocks", description=CodeBloc, color=color.emcolor())
await message.channel.send(embed=embed)
if message.content.startswith('.strike'):
Strikethroug = textsty.Strikethrough(message)
embed = discord.Embed(title=f"{_BotName} Strikethrough", description=Strikethroug, color=color.emcolor())
await message.channel.send(embed=embed)
if message.content.startswith('.unbolic'):
UnderlineBoldItalic = textsty.UnderlineBoldItalics(message)
embed = discord.Embed(title=f"{_BotName} Underline Bold Italics", description=UnderlineBoldItalic, color=color.emcolor())
await message.channel.send(embed=embed)
if message.content.startswith('.blockquote'):
BlockQuote = textsty.BlockQuotes(message)
embed = discord.Embed(title=f"{_BotName} Block Quotes", description=BlockQuote, color=color.emcolor())
await message.channel.send(embed=embed)
#youtube search engin
if message.content.startswith('.yt'):
try:
msg = youtube.ytsearch(message)
embed = discord.Embed(title=f"{_BotName} Youtube Search Engine", description=msg, color=color.emcolor())
await message.channel.send(embed=embed)
except:
embed = discord.Embed(title= _error, description= _errorMsg, color=color.emcolor())
await message.channel.send(embed=embed)
if message.content.startswith('.tagall'):
tag = tagall.tagall(message)
embed = discord.Embed(title=f"{_BotName} Tag", description=tag, color=color.emcolor())
await message.channel.send(embed=embed)
alive()
client.run(_Tkey)