2020-06-03 01:07:43 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from discord.ext import commands
|
|
|
|
from . import Config
|
2020-06-04 00:14:50 +02:00
|
|
|
from . import data_manager
|
2020-06-03 01:07:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
__all__ = ["Tux"]
|
|
|
|
|
|
|
|
|
|
|
|
class Tux(commands.AutoShardedBot):
|
2020-06-03 19:41:30 +02:00
|
|
|
def __init__(self, *args, cli_flags=None, bot_dir: Path = Path.cwd(), **kwargs):
|
|
|
|
# by default, if the bot shutdown without any intervention,
|
|
|
|
# it's a crash
|
2020-06-04 00:14:50 +02:00
|
|
|
self.shutdown_code = 1
|
|
|
|
self.cli_flags = cli_flags
|
|
|
|
self.instance_name = self.cli_flags.instance_name
|
|
|
|
self.last_exception = None
|
2020-06-03 19:41:30 +02:00
|
|
|
|
2020-06-04 00:14:50 +02:00
|
|
|
self.config = Config(
|
2020-06-04 16:36:22 +02:00
|
|
|
data_manager.data_path(self.instance_name)
|
2020-06-03 01:07:43 +02:00
|
|
|
)
|
2020-06-04 00:14:50 +02:00
|
|
|
self.config.register_global(
|
2020-06-03 01:07:43 +02:00
|
|
|
token=None,
|
|
|
|
prefix=[],
|
|
|
|
owner=None,
|
|
|
|
whitelist=[],
|
|
|
|
blacklist=[],
|
|
|
|
locale="en-US",
|
|
|
|
embeds=True,
|
|
|
|
color=0x6E83D1,
|
|
|
|
disabled_commands=[]
|
|
|
|
)
|
2020-06-04 00:14:50 +02:00
|
|
|
self.config.register_guild(
|
2020-06-03 01:07:43 +02:00
|
|
|
prefix=[],
|
|
|
|
whitelist=[],
|
|
|
|
blacklist=[],
|
|
|
|
locale="en-US",
|
|
|
|
admin_role=[],
|
|
|
|
mod_role=[],
|
|
|
|
embeds=None,
|
|
|
|
ignored=False,
|
|
|
|
disabled_commands=[]
|
|
|
|
)
|
2020-06-04 00:14:50 +02:00
|
|
|
self.config.register_channel(
|
2020-06-03 01:07:43 +02:00
|
|
|
ignored=False
|
2020-06-03 19:41:30 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if "owner_ids" in kwargs:
|
|
|
|
kwargs["owner_ids"] = set(kwargs["owner_ids"])
|
|
|
|
else:
|
2020-06-04 00:14:50 +02:00
|
|
|
kwargs["owner_ids"] = self.config.owner_ids()
|
2020-06-03 19:41:30 +02:00
|
|
|
|
|
|
|
message_cache_size = 100_000
|
|
|
|
kwargs["max_messages"] = message_cache_size
|
2020-06-04 00:14:50 +02:00
|
|
|
self.max_messages = message_cache_size
|
2020-06-03 19:41:30 +02:00
|
|
|
|
2020-06-04 00:14:50 +02:00
|
|
|
self.uptime = None
|
|
|
|
self.main_dir = bot_dir
|
|
|
|
|
|
|
|
print(str(self.cli_flags), self.instance_name, self.config, self.owner_ids, self.main_dir)
|
|
|
|
|
|
|
|
exit()
|
2020-06-03 19:41:30 +02:00
|
|
|
|
|
|
|
super().__init__(*args, help_command=None, **kwargs)
|