-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
110 lines (103 loc) · 6.94 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
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
import discord, aiohttp, asyncio, aiosqlite, traceback
from discord.ext.commands import Bot
from discord.ext import commands
from discord import *
bot_prefix = "mb!"
client = commands.Bot(command_prefix=bot_prefix)
client.remove_command('help')
@client.event
async def on_ready():
print("Bot Online")
print("Name: {}".format(client.user.name))
print("ID: {}".format(client.user.id))
@client.event
async def on_message(message):
if(message.author.bot):
return
async with aiosqlite.connect('./Resources/Interactive/Prefixes.db') as conn:
c = await conn.execute("SELECT * FROM Prefixes")
buffer = await c.fetchall()
await c.close()
await conn.close()
user_id = message.author.id
data = [i[0] for i in buffer]
async with aiosqlite.connect("./Resources/Interactive/ServerPrefixes.db") as conn:
c2 = await conn.execute("SELECT * FROM Prefixes")
buffer2 = await c2.fetchall()
await c2.close()
await conn.close()
server_id = message.guild.id
data2 = [i[0] for i in buffer2]
if(user_id in data):
cprefix = buffer[data.index(user_id)][-1]
if(message.content.startswith(cprefix)):
message.content = "mb!" + message.content[len(cprefix):].split()[0].lower() + ' ' + ' '.join(message.content[len(cprefix):].split()[1:]) if len(message.content[len(cprefix):].split()) != 1 else "mb!" + message.content[len(cprefix):].split()[0].lower()
game = discord.Game('for mb!help | Currently in ' + str(len(client.guilds)) + ' servers!', type=discord.ActivityType.watching)
await client.change_presence(activity=game)
payload = {"server_count": str(len(client.guilds))}
x = 0
for server in client.guilds:
for user in server.members:
if(not user.bot):
x += 1
async with aiohttp.ClientSession() as aioclient:
await aioclient.post('https://botsfordiscord.com/api/bot/' + str(client.user.id), data=payload, headers={"Authorization": open('C:/TOKENS/BFD.txt').read()})
await aioclient.post("https://discordbots.org/api/bots/" + str(client.user.id) + "/stats", data=payload, headers={"Authorization": open("C:/TOKENS/DBL.txt").read()})
await aioclient.post("https://discordbotlist.com/api/bots/" + str(client.user.id) + "/stats", data={"guilds": len(client.guilds), "users": x}, headers={"Authorization": open("C:/TOKENS/DBL2.txt").read()})
await aioclient.post("https://discord.bots.gg/api/v1/bots/" + str(client.user.id) + "/stats", data={"guildCount": len(client.guilds)}, headers={"Authorization": open("C:/TOKENS/DBGG.txt").read()})
await client.process_commands(message)
elif(server_id in data2):
cprefix = buffer2[data2.index(server_id)][-1]
if(message.content.startswith(cprefix)):
message.content = "mb!" + message.content[len(cprefix):].split()[0].lower() + ' ' + ' '.join(message.content[len(cprefix):].split()[1:]) if len(message.content[len(cprefix):].split()) != 1 else "mb!" + message.content[len(cprefix):].split()[0].lower()
game = discord.Game('for mb!help | Currently in ' + str(len(client.guilds)) + ' servers!', type=discord.ActivityType.watching)
await client.change_presence(activity=game)
payload = {"server_count": str(len(client.guilds))}
x = 0
for server in client.guilds:
for user in server.members:
if(not user.bot):
x += 1
async with aiohttp.ClientSession() as aioclient:
await aioclient.post('https://botsfordiscord.com/api/bot/' + str(client.user.id), data=payload, headers={"Authorization": open('C:/TOKENS/BFD.txt').read()})
await aioclient.post("https://discordbots.org/api/bots/" + str(client.user.id) + "/stats", data=payload, headers={"Authorization": open("C:/TOKENS/DBL.txt").read()})
await aioclient.post("https://discordbotlist.com/api/bots/" + str(client.user.id) + "/stats", data={"guilds": len(client.guilds), "users": x}, headers={"Authorization": open("C:/TOKENS/DBL2.txt").read()})
await aioclient.post("https://discord.bots.gg/api/v1/bots/" + str(client.user.id) + "/stats", data={"guildCount": len(client.guilds)}, headers={"Authorization": open("C:/TOKENS/DBGG.txt").read()})
await client.process_commands(message)
else:
if(message.content.startswith("mb!")):
game = discord.Game('for mb!help | Currently in ' + str(len(client.guilds)) + ' servers!', type=discord.ActivityType.watching)
await client.change_presence(activity=game)
payload = {"server_count": str(len(client.guilds))}
x = 0
for server in client.guilds:
for user in server.members:
if(not user.bot):
x += 1
async with aiohttp.ClientSession() as aioclient:
await aioclient.post('https://botsfordiscord.com/api/bot/' + str(client.user.id), data=payload, headers={"Authorization": open('C:/TOKENS/BFD.txt').read()})
await aioclient.post("https://discordbots.org/api/bots/" + str(client.user.id) + "/stats", data=payload, headers={"Authorization": open("C:/TOKENS/DBL.txt").read()})
await aioclient.post("https://discordbotlist.com/api/bots/" + str(client.user.id) + "/stats", data={"guilds": len(client.guilds), "users": x}, headers={"Authorization": open("C:/TOKENS/DBL2.txt").read()})
await aioclient.post("https://discord.bots.gg/api/v1/bots/" + str(client.user.id) + "/stats", data={"guildCount": len(client.guilds)}, headers={"Authorization": open("C:/TOKENS/DBGG.txt").read()})
await client.process_commands(message)
@client.event
async def on_command_error(ctx, error):
x = traceback.format_exception_only(type(error), error)[0]
y = traceback.format_exception(type(error), error, error.__traceback__)
if(isinstance(error, commands.CommandNotFound)):
pass
elif(isinstance(error, discord.ext.commands.errors.MissingRequiredArgument)):
await ctx.send("It seems that you have not put in all the required arguments!")
else:
await ctx.send("It seems an error has occured. I'll be sure to fix it as soon as I can!")
venom = client.get_user(190804082032640000)
emb = (discord.Embed(color=0xff0000))
print(''.join(y))
emb.set_author(name="ERROR")
emb.add_field(name="Command", value=ctx.message.content)
emb.add_field(name="Traceback", value='```' + ''.join(y).split('The above exception was the direct cause')[0][-1000:] + '```')
await venom.send(embed=emb)
extensions = ["Resources.Modules.Fun", "Resources.Modules.Encryption", "Resources.Modules.Money", "Resources.Modules.Info", "Resources.Modules.Mod"]
for i in extensions:
client.load_extension(i)
client.run(open("C:/TOKENS/TOKEN.txt").read())