breadtube-bot/start.py
BreadTube 8d76596ebf Add README
* Optional `--guild-id` is now positional (thus mandatory) and no longer
  have a default id set to the breadtube discord server
2026-01-21 22:46:13 +09:00

29 lines
961 B
Python

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, help='Guild id (discord server) 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()