def main(): # https://github.com/cheran-senthil/TLE/blob/bae59c2de6a2313be4a6ba4a5a5cbba81352e229/tle/__main__.py BOT_TOKEN = os.environ["JOMD_BOT_TOKEN"] API_TOKEN = os.environ["JOMD_TOKEN"] if not BOT_TOKEN: print('Missing bot token') return intents = discord.Intents.default() # All but the two privileged ones intents.members = True # Subscribe to the Members intent pref = '+' bot = commands.Bot(command_prefix=commands.when_mentioned_or(pref), intents=intents) cogs = [file.stem for file in Path('cogs').glob('*.py')] for extension in cogs: bot.load_extension(f'cogs.{extension}') print(f'Cogs loaded: {", ".join(bot.cogs)}') def no_dm_check(ctx): if ctx.guild is None: raise commands.NoPrivateMessage('Private messages not permitted.') return True # Get preliminary data q = Query() loop = asyncio.get_event_loop() loop.run_until_complete(q.get_problems()) # Restrict bot usage to inside guild channels only. bot.add_check(no_dm_check) bot.run(BOT_TOKEN)
def main(): # https://github.com/cheran-senthil/TLE/blob/bae59c2de6a2313be4a6ba4a5a5cbba81352e229/tle/__main__.py dotenv.load_dotenv() BOT_TOKEN = os.environ.get("JOMD_BOT_TOKEN") if not BOT_TOKEN: logger.critical("Missing bot token") return pref = "+" bot = lightbulb.BotApp(token=BOT_TOKEN, prefix=pref, banner=None, intents=hikari.Intents.ALL) bot.load_extensions_from("./extensions/") # TESTING # extensions = ["admin", "meta", "gitgud", "handles", "user", "plot"] # for extension in extensions: # bot.load_extensions(f"extensions.{extension}") logger.debug("Extensions loaded: %s", ", ".join(bot.extensions)) # Get preliminary data if session.query(Problem_DB).count() == 0: q = Query() loop = asyncio.get_event_loop() loop.run_until_complete(q.get_problems()) # Restrict bot usage to inside guild channels only. bot.check(lightbulb.checks.guild_only) # TODO Make something that will automatically fetch recent contests bot.run()