-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.py
177 lines (155 loc) · 7.59 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
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
#!/usr/bin/env/python3
import os
import topgg
import aiosqlite
from disnake import Intents
from disnake.ext import commands
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv("TOKEN")
dbl_token = os.getenv("TOP_GG_TOKEN")
PREFIX = "!"
class MyBot(commands.Bot):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.role_emojis = {
'top': "<:TOP:1066065292691779637>",
'jungle': "<:JGL:1066065288107397200>",
'mid': "<:MID:1066065288862380033>",
'support': "<:SUP:1066065290540093450>",
'adc': "<:BOT:1066065285938946078>",
'controller': "<:Controller:1078086238961156197>",
'duelist': "<:Duelist:1078086241221877941>",
'initiator': "<:Initiator:1078086242677305426>",
'sentinel': "<:Sentinel:1078086244371808267>",
'flex': "❓",
'flex - controller': "<:Controller:1078086238961156197>",
'flex - duelist': "<:Duelist:1078086241221877941>",
'flex - initiator': "<:Initiator:1078086242677305426>",
'flex - sentinel': "<:Sentinel:1078086244371808267>",
'tank': "<:Tank:1078082570039873668>",
'dps 1': "<:Damage:1078082164949786725>",
'dps 2': "<:Damage:1078082164949786725>",
'support 1': "<:Support:1078082833198878852>",
'support 2': "<:Support:1078082833198878852>",
'role 1': "1️⃣",
'role 2': "2️⃣",
'role 3': "3️⃣",
'role 4': "4️⃣",
'role 5': "5️⃣"
}
self.valorant_maps = [
{'Haven': 'https://media.valorant-api.com/maps/2bee0dc9-4ffe-519b-1cbd-7fbe763a6047/splash.png'},
{'Split': 'https://media.valorant-api.com/maps/d960549e-485c-e861-8d71-aa9d1aed12a2/splash.png'},
{'Ascent': 'https://media.valorant-api.com/maps/7eaecc1b-4337-bbf6-6ab9-04b8f06b3319/splash.png'},
{'Icebox': 'https://media.valorant-api.com/maps/e2ad5c54-4114-a870-9641-8ea21279579a/splash.png'},
{'Fracture': 'https://media.valorant-api.com/maps/b529448b-4d60-346e-e89e-00a4c527a405/splash.png'},
{'Pearl': 'https://media.valorant-api.com/maps/fd267378-4d1d-484f-ff52-77821ed10dc2/splash.png'},
{'Lotus': 'https://media.valorant-api.com/maps/2fe4ed3a-450a-948b-6d6b-e89a78e680a9/splash.png'},
{'Bind': 'https://media.valorant-api.com/maps/2c9d57ec-4431-9c5e-2939-8f9ef6dd5cba/splash.png'},
{'Breeze': 'https://media.valorant-api.com/maps/2fb9a4fd-47b8-4e7d-a969-74b4046ebd53/splash.png'},
]
self.overwatch = [
{ 'Control': [
{'Busan': 'https://overfast-api.tekrop.fr/static/maps/busan.jpg'},
{'Ilios': 'https://overfast-api.tekrop.fr/static/maps/ilios.jpg'},
{'Lijiang Tower': 'https://overfast-api.tekrop.fr/static/maps/lijiang.jpg'},
{'Nepal': 'https://overfast-api.tekrop.fr/static/maps/nepal.jpg'},
{'Oasis': 'https://overfast-api.tekrop.fr/static/maps/oasis.jpg'},
] },
{ 'Escort': [
{'Dorado': 'https://overfast-api.tekrop.fr/static/maps/dorado.jpg'},
{'Junkertown': 'https://overfast-api.tekrop.fr/static/maps/junkertown.jpg'},
{'Circuit Royal': 'https://overfast-api.tekrop.fr/static/maps/circuit_royal.jpg'},
{'Rialto': 'https://overfast-api.tekrop.fr/static/maps/rialto.jpg'},
{'Route 66': 'https://overfast-api.tekrop.fr/static/maps/route_66.jpg'},
{'Shambali Monastery (new)': 'https://overfast-api.tekrop.fr/static/maps/shambali.jpg'},
{'Watchpoint Gibratar': 'https://overfast-api.tekrop.fr/static/maps/gibraltar.jpg'},
]
},
{ 'Hybrid':[
{'Blizzard World': 'https://overfast-api.tekrop.fr/static/maps/blizzard_world.jpg'},
{'Eichenwalde': 'https://overfast-api.tekrop.fr/static/maps/eichenwalde.jpg'},
{'King’s Row': 'https://overfast-api.tekrop.fr/static/maps/kings_row.jpg'},
{'Midtown': 'https://overfast-api.tekrop.fr/static/maps/midtown.jpg'},
{'Paraíso': 'https://overfast-api.tekrop.fr/static/maps/paraiso.jpg'},
{'Numbani': 'https://overfast-api.tekrop.fr/static/maps/numbani.jpg'},
{'Hollywood': 'https://overfast-api.tekrop.fr/static/maps/hollywood.jpg'},
]
},
{ 'Push':[
{'Colosseo': 'https://overfast-api.tekrop.fr/static/maps/colosseo.jpg'},
{'New Queen Street': 'https://overfast-api.tekrop.fr/static/maps/new_queen_street.jpg'},
{'Esperança': 'https://overfast-api.tekrop.fr/static/maps/esperanca.jpg'},
]
}
]
async def commit(self):
async with aiosqlite.connect("db/main.sqlite") as db:
await db.commit()
async def execute(self, query, *values):
async with aiosqlite.connect("db/main.sqlite") as db:
async with db.cursor() as cur:
await cur.execute(query, tuple(values))
await db.commit()
async def executemany(self, query, values):
async with aiosqlite.connect("db/main.sqlite") as db:
async with db.cursor() as cur:
await cur.executemany(query, values)
await db.commit()
async def fetchval(self, query, *values):
async with aiosqlite.connect("db/main.sqlite") as db:
async with db.cursor() as cur:
exe = await cur.execute(query, tuple(values))
val = await exe.fetchone()
return val[0] if val else None
async def fetchrow(self, query, *values):
async with aiosqlite.connect("db/main.sqlite") as db:
async with db.cursor() as cur:
exe = await cur.execute(query, tuple(values))
row = await exe.fetchmany(size=1)
if len(row) > 0:
row = [r for r in row[0]]
else:
row = None
return row
async def fetchmany(self, query, size, *values):
async with aiosqlite.connect("db/main.sqlite") as db:
async with db.cursor() as cur:
exe = await cur.execute(query, tuple(values))
many = await exe.fetchmany(size)
return many
async def fetch(self, query, *values):
async with aiosqlite.connect("db/main.sqlite") as db:
async with db.cursor() as cur:
exe = await cur.execute(query, tuple(values))
all = await exe.fetchall()
return all
async def check_testmode(self, guild_id):
data = await self.fetchrow(f"SELECT * FROM testmode WHERE guild_id = {guild_id}")
if data:
return True
return False
# Enabling message content intent for the bot to support prefix commands.
intents = Intents.default()
intents.message_content = True
intents.members = True
bot = MyBot(intents=intents, command_prefix=PREFIX)
bot.remove_command("help")
if dbl_token:
bot.topggpy = topgg.DBLClient(bot, dbl_token, autopost=True)
@bot.event
async def on_autopost_success():
print(
f"Posted server count ({bot.topggpy.guild_count}), shard count ({bot.shard_count})"
)
@bot.before_slash_command_invoke
async def before_invoke_slash(inter):
if not inter.response.is_done():
await inter.response.defer()
# Load all cogs
for filename in os.listdir("./cogs"):
if filename.endswith(".py"):
bot.load_extension(f"cogs.{filename[:-3]}")
# Run the client
bot.run(TOKEN)