2020-06-03 01:07:43 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from discord.ext import commands
|
|
|
|
from . import Config
|
|
|
|
|
|
|
|
|
|
|
|
__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
|
|
|
|
self._shutdown_mode = 1
|
|
|
|
self._cli_flags = cli_flags
|
|
|
|
self._last_exception = None
|
|
|
|
|
2020-06-03 01:07:43 +02:00
|
|
|
self._config = Config.register_core(
|
2020-06-03 19:41:30 +02:00
|
|
|
identifier=self._cli_flags.instance_name
|
2020-06-03 01:07:43 +02:00
|
|
|
)
|
|
|
|
self._config.register_global(
|
|
|
|
token=None,
|
|
|
|
prefix=[],
|
|
|
|
owner=None,
|
|
|
|
whitelist=[],
|
|
|
|
blacklist=[],
|
|
|
|
locale="en-US",
|
|
|
|
embeds=True,
|
|
|
|
color=0x6E83D1,
|
|
|
|
disabled_commands=[]
|
|
|
|
)
|
|
|
|
self._config.register_guild(
|
|
|
|
prefix=[],
|
|
|
|
whitelist=[],
|
|
|
|
blacklist=[],
|
|
|
|
locale="en-US",
|
|
|
|
admin_role=[],
|
|
|
|
mod_role=[],
|
|
|
|
embeds=None,
|
|
|
|
ignored=False,
|
|
|
|
disabled_commands=[]
|
|
|
|
)
|
|
|
|
self._config.register_channel(
|
|
|
|
ignored=False
|
2020-06-03 19:41:30 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if "owner_ids" in kwargs:
|
|
|
|
kwargs["owner_ids"] = set(kwargs["owner_ids"])
|
|
|
|
else:
|
|
|
|
kwargs["owner_ids"] = self._config.owner_ids()
|
|
|
|
|
|
|
|
message_cache_size = 100_000
|
|
|
|
kwargs["max_messages"] = message_cache_size
|
|
|
|
self._max_messages = message_cache_size
|
|
|
|
|
|
|
|
self._uptime = None
|
|
|
|
self._main_dir = bot_dir
|
|
|
|
|
|
|
|
super().__init__(*args, help_command=None, **kwargs)
|