This repository has been archived by the owner on Nov 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
62 lines (49 loc) · 1.55 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
from __future__ import annotations
import asyncio
import discord
import logging
import datetime
from dotenv import load_dotenv
from os import environ
from pyfiglet import figlet_format
from discord.ext import commands
from discord.utils import setup_logging
import colorama
from colorama import Fore, Back, Style
from custom.client import MyClient
from custom.database import DatabaseManager
load_dotenv()
colorama.init()
print(Fore.MAGENTA + figlet_format("RPG") + Style.RESET_ALL)
rightNow = datetime.datetime.now()
rightNow = rightNow.strftime(r"%d-%m-%Y_%H-%M-%S")
file_handler: logging.Handler = logging.FileHandler(
filename=f"./logs/log_{rightNow}.log", encoding="utf-8", mode="w"
)
setup_logging(
handler=file_handler,
level=logging.INFO,
)
mg = DatabaseManager(
"./databases/test.db",
database_schema_path="./databases/schemas/schema.sql",
database_backups_path="./databases/backups/",
)
mg.logging_setup( # FIXME I don't know why this creates duplicate log messages
handler=file_handler,
)
client = MyClient(
command_prefix=commands.when_mentioned_or(
"my_message_content_perm_must_be_disabled"
),
intents=discord.Intents.default(),
database_manager=mg,
extensions_folders=["events", "extensions"],
is_testing=True,
test_guild=discord.Object(environ["TEST_GUILD"]),
)
async def main() -> None:
async with client, client.database_manager:
await client.start(environ["TOKEN"])
if __name__ == "__main__":
asyncio.run(main())