forked from AyushSehrawat/eco-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
87 lines (66 loc) · 2.17 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
from datetime import datetime, timedelta
from os import listdir, system
import aiohttp
import discord
import json
from discord.ext import commands
from pretty_help import PrettyHelp
class Echo(commands.Bot):
def __init__(self):
self.description = """Echo - A Economy Bot"""
super().__init__(
command_prefix={"."},
owner_ids={727365670395838626},
intents=discord.Intents.all(),
help_command=PrettyHelp(),
description=self.description,
case_insensitive=True,
start_time=datetime.utcnow(),
)
async def on_connnect(self):
self.session = aiohttp.ClientSession(loop=self.loop)
cT = datetime.now() + timedelta(
hours=5, minutes=30
) # GMT+05:30 is Our TimeZone So.
print(
f"[ Log ] {self.user} Connected at {cT.hour}:{cT.minute}:{cT.second} / {cT.day}-{cT.month}-{cT.year}"
)
async def on_ready(self):
cT = datetime.now() + timedelta(
hours=5, minutes=30
) # GMT+05:30 is Our TimeZone So.
print(
f"[ Log ] {self.user} Ready at {cT.hour}:{cT.minute}:{cT.second} / {cT.day}-{cT.month}-{cT.year}"
)
print(f"[ Log ] GateWay WebSocket Latency: {self.latency*1000:.1f} ms")
with open('./data.json') as f:
d1 = json.load(f)
with open('./market.json') as f:
d2 = json.load(f)
def bot_info():
return d1
def market_info():
return d2
TOKEN = d1['token']
bot = Echo()
@bot.command(hidden=True)
@commands.is_owner()
async def load(ctx, extension):
bot.load_extension(f"cogs.{extension}")
await ctx.send("Done")
@bot.command(hidden=True)
@commands.is_owner()
async def unload(ctx, extension):
bot.unload_extension(f"cogs.{extension}")
await ctx.send("Done")
@bot.command(hidden=True)
@commands.is_owner()
async def reload(ctx, extension):
bot.unload_extension(f"cogs.{extension}")
bot.load_extension(f"cogs.{extension}")
await ctx.send("Done")
for filename in listdir("./cogs"):
if filename.endswith(".py"):
bot.load_extension(f"cogs.{filename[:-3]}")
bot.load_extension("jishaku")
bot.loop.run_until_complete(bot.run(TOKEN))