Discord/main.py

56 lines
1.2 KiB
Python

import logging
from discord import Activity, ActivityType
from cogs.admin import Admin
from cogs.analytics import Analytics
from cogs.custom_channels import CustomChannels
from cogs.data import Data
from cogs.logger import Logger
from modules.client import client
from modules.scheduled import scheduler
from modules.utils import config_get
from modules.utils_sync import config_get_sync
logging.basicConfig(
level=logging.INFO,
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
datefmt="[%X]",
)
logger = logging.getLogger(__name__)
try:
import uvloop # type: ignore
uvloop.install()
except ImportError:
pass
@client.event
async def on_ready():
logger.info(f"Logged in as {client.user}")
await client.change_presence(
activity=Activity(type=ActivityType.listening, name=await config_get("status"))
)
def main():
client.add_cog(Admin(client))
client.add_cog(Analytics(client))
client.add_cog(CustomChannels(client))
client.add_cog(Data(client))
client.add_cog(Logger(client))
try:
scheduler.start()
client.run(config_get_sync("token"))
except KeyboardInterrupt:
scheduler.shutdown()
exit()
if __name__ == "__main__":
main()