Files
mememan/src/main.py
2023-04-08 00:35:31 +01:00

39 lines
1.0 KiB
Python

import discord
import json
from core.bot import Bot
def main():
try:
with open('config.json', 'rt') as config_file:
config = json.load(config_file)
except OSError as e:
print(f'Could not open config.json! Error: {e.strerror}')
return
except Exception as e:
print(f'Error loading config. Error: {e}')
return
# Load token from token file if not in JSON config
if config['token'] == '':
try:
with open('token.txt', 'rt') as token_file:
config['token'] = token_file.readline()
except OSError as e:
print(f'Could not open token.txt! Error: {e.strerror}')
return
try:
intents = discord.Intents.default()
intents.message_content = True
bot = Bot(intents=intents)
bot.load_config(config)
bot.run(config['token'])
except Exception as e:
print(f'Exception running bot! Error: {e}')
return
if __name__ == '__main__':
main()