Code refactored

This commit is contained in:
BreadTube 2025-09-29 18:49:49 +09:00 committed by Corentin
commit d5b3436aec
3 changed files with 247 additions and 213 deletions

29
start.py Normal file
View file

@ -0,0 +1,29 @@
from argparse import ArgumentParser
import logging
from pathlib import Path
from breadtube_bot.bot import Bot
def main():
parser = ArgumentParser('BreadTube-bot')
parser.add_argument('--guild', type=int, default=1306964577812086824, help='Guild id to manage')
parser.add_argument('--debug', action='store_true', default=False, help='Run in debug mode (for logs)')
arguments = parser.parse_args()
debug_mode: bool = arguments.debug
guild_id: int = arguments.guild
del arguments
bot_token = Path('data/discord_bot_token.txt').read_text(encoding='utf-8').strip()
yt_api_key = Path('data/google_api_key.txt').read_text(encoding='utf-8').strip()
manager = Bot(bot_token=bot_token, guild_id=guild_id, yt_api_key=yt_api_key,
log_level=logging.DEBUG if debug_mode else logging.INFO)
try:
manager.run()
except KeyboardInterrupt:
print('\r ') # noqa: T201
if __name__ == '__main__':
main()