Code refactored
This commit is contained in:
parent
b80e4f7745
commit
d5b3436aec
3 changed files with 247 additions and 213 deletions
29
bot.py
29
bot.py
|
|
@ -1,29 +0,0 @@
|
|||
from argparse import ArgumentParser
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from breadtube_bot.manager import DiscordManager
|
||||
|
||||
|
||||
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 = DiscordManager(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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue