Discord/main.py

41 lines
861 B
Python
Raw Normal View History

2023-05-02 16:46:15 +03:00
import asyncio
import logging
from discord import Activity, ActivityType
from modules.scheduled import scheduler
from modules.client import client
from modules.utils import config_get
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():
try:
scheduler.start()
client.run(asyncio.run(config_get("token")))
except KeyboardInterrupt:
scheduler.shutdown()
exit()
if __name__ == "__main__":
main()