"""This program runs YorBot, a Discord Bot Application. """ import asyncio import json import os import sys import discord from discord.ext import commands # opens config.json for bot config with open('json_files/config.json', 'r') as f: config = json.load(f) # load bot settings PREFIX = config['prefix'] TOKEN = config['token'] intents = discord.Intents.all() intents.message_content = True intents.members = True client = commands.Bot(command_prefix=PREFIX, intents=intents) client.remove_command('help') async def load_cogs() -> None: """Loads all Cog extensions.""" for file in os.listdir('cogs'): # skip non-python files if not file.endswith('.py'): continue ext = f'cogs.{os.path.splitext(file)[0]}' await client.load_extension(ext) @client.event async def on_ready() -> None: """YorBot start up message.""" print('\n[STATUS] ✦ ✦ YorBot is online! ✦ ✦\n') def clean_up() -> None: """Performs a clean up process on KeyboardInterrupt.""" print('\n[STATUS] ✦ ✦ YorBot is offline. ✦ ✦\n') async def main(): print('[STATUS] YorBot is starting.') async with client: await load_cogs() await client.start(TOKEN) if __name__ == '__main__': try: asyncio.run(main()) raise KeyboardInterrupt except KeyboardInterrupt: clean_up() sys.exit(0)