This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
main.py
84 lines (62 loc) · 2.06 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
from datetime import datetime, timedelta
from os import listdir
import os
import aiohttp
import discord
import json
from dotenv import load_dotenv
from discord.ext import commands
# Load environment variables from .env file
load_dotenv()
class Echo(commands.Bot):
def __init__(self):
self.description = """Echo - An Economy Bot"""
super().__init__(
command_prefix={"."},
intents=discord.Intents.all(),
description=self.description,
case_insensitive=True,
)
async def on_connect(self):
self.session = aiohttp.ClientSession(loop=self.loop)
cT = datetime.now() + timedelta(hours=5, minutes=30)
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)
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("./market.json") as f:
d2 = json.load(f)
def market_info():
return d2
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")
# Fetch token from environment variable
token = os.getenv("TOKEN")
if token:
bot.loop.run_until_complete(bot.run(token))
else:
print("Error: Discord token not found in environment variable TOKEN")