import os import time import bot from BotResources import check_if_config_exists, write_config_file, read_config_file # Jorn #token = 'OTE1MDY0OTk2OTk0NjMzNzI5.YaWKsA.Y9yaCGg_VXRL_qQVbs05vo7gSAc' # Greada #token = 'NzU2MzI3MjcxNTk3NDczODYz.X2QOqQ.LVLj2b-RXQzPmhNuBC1eGFMcYls' #name = "VoiceMeeter Output" class BotDeviceNotFound(Exception): def __init__(self, device): print(f"Unable to find the device: {device}") try: os.remove('./config.ini') except OSError: print("Config file not found, restarting.") #os.execv(__file__, sys.argv) def main(): print('Checking config file...') if not check_if_config_exists(): print("No config file exists, please enter this information now") write_config_file(init=True) config = read_config_file() print('Starting Bot...') discord_bot_client = bot.Bot(Token=config['Bot Token'], Device_ID=config['Device ID'], Device_Name=config['Device Name'], Mention_Group=config['Mention Group'], Channel_ID=config['Channel ID']) print(f"Verifying audio device:\t{config['Device Name']}") if not discord_bot_client.check_device(): raise BotDeviceNotFound(config['Device Name']) print("Bot started!") discord_bot_client.start_bot() if __name__ == '__main__': try: print('Starting...') while True: try: main() except BotDeviceNotFound: print("Restarting...") time.sleep(2) except KeyboardInterrupt: print("Exiting...")