-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (46 loc) · 1.35 KB
/
main.py
File metadata and controls
58 lines (46 loc) · 1.35 KB
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
import os
import dotenv
import asyncio
import discord
dotenv.load_dotenv(override = True)
from bot.cogs.matchmaking import Matchmaking
from bot.cogs.minimap import MiniMap
from bot.cogs.teams import Teams
from bot.cogs.units import Units
async def main():
# On initialise le bot
intents = discord.Intents.all()
bot = discord.Bot(intents = intents)
# On charge les cogs
bot.add_cog(Matchmaking(bot))
bot.add_cog(MiniMap(bot))
bot.add_cog(Teams(bot))
bot.add_cog(Units(bot))
# Et c'est parti
@bot.event
async def on_ready():
print(f"\033[32mConnecté en tant que \033[1m{bot.user.display_name}\033[0m", flush = True)
@bot.event
async def on_message(message: discord.Message) -> None:
if message.author.bot:
return
if ' ' in message.content:
cmd = message.content.split(' ')
else:
cmd = [ message.content ]
if cmd[0] in ('move', 'mv') and len(cmd) == 4:
try:
cmd[1:] = map(int, cmd[1:])
if len(cmd) == 4:
await Units(bot).move_units(message, cmd[1], cmd[2], cmd[3])
elif len(cmd) == 3:
await Units(bot).move_units(message, cmd[1], cmd[2])
else:
await message.reply(':x:')
except FileExistsError:
await message.reply("Mauvais arguments passés.")
elif cmd[0] in ('fmap',):
await MiniMap(bot).display_fastmap(message)
await bot.start(os.getenv('TOKEN'))
if __name__ == '__main__':
asyncio.run(main())