Beispiel #1
0
async def on_ready():
    app_info = await bot.application_info()
    bot.owner = app_info.owner

    permissions = Permissions()
    permissions.update(send_messages=True,
                       embed_links=True,
                       add_reactions=True,
                       manage_messages=True,
                       manage_roles=True,
                       manage_channels=True,
                       use_application_commands=True)

    # Add the ErrorLog object if the channel is specified
    if bot.config["error_log_channel"]:
        error_channel = await bot.fetch_channel(bot.config["error_log_channel"]
                                                )
        bot.errorlog = ErrorLog(bot, error_channel)

    print("\n"
          "#-------------------------------#\n"
          "| Loading initial cogs...\n"
          "#-------------------------------#")

    for cog in INIT_EXTENSIONS:
        try:
            await bot.load_extension(f"cogs.{cog}")
            print(f"| Loaded initial cog {cog}")
        except ExtensionAlreadyLoaded:
            continue

        except Exception as e:
            if hasattr(e, "original"):
                print(
                    f"| Failed to load extension {cog}\n|   {type(e.original).__name__}: {e.original}"
                )
            else:
                print(
                    f"| Failed to load extension {cog}\n|   {type(e).__name__}: {e}"
                )

            error = exc_info()
            await bot.errorlog.send(error, event="Load Initial Cog")

    print(f"| Syncing commands...", end="\r")
    await bot.tree.sync()
    await bot.tree.sync(guild=await bot.fetch_guild(699399549218717707))
    print(f"| Commands synced    ")

    print(f"#-------------------------------#\n"
          f"| Successfully logged in.\n"
          f"#-------------------------------#\n"
          f"| User:      {bot.user}\n"
          f"| User ID:   {bot.user.id}\n"
          f"| Owner:     {bot.owner}\n"
          f"| Guilds:    {len(bot.guilds)}\n"
          f"| OAuth URL: {oauth_url(app_info.id, permissions=permissions)}\n"
          f"#------------------------------#\n")
Beispiel #2
0
async def on_ready():
    await bot.connect_dbl(autopost=True)

    app_info = await bot.application_info()
    bot.owner = bot.get_user(app_info.owner.id)

    permissions = Permissions()
    permissions.update(send_messages=True,
                       embed_links=True,
                       manage_messages=True,
                       manage_webhooks=True,
                       add_reactions=True,
                       attach_files=True)

    print(f"\n"
          f"#-------------------------------#\n"
          f"| Loading initial cogs...\n"
          f"#-------------------------------#")

    for cog in INIT_EXTENSIONS:
        try:
            bot.load_extension(f"cogs.{cog}")
            print(f"| Loaded initial cog {cog}")
        except Exception as e:
            print(
                f"| Failed to load extension {cog}\n|   {type(e).__name__}: {e}"
            )

    print(f"#-------------------------------#\n"
          f"| Successfully logged in.\n"
          f"#-------------------------------#\n"
          f"| User:      {bot.user}\n"
          f"| User ID:   {bot.user.id}\n"
          f"| Owner:     {bot.owner}\n"
          f"| Guilds:    {len(bot.guilds)}\n"
          f"| Users:     {len(list(bot.get_all_members()))}\n"
          f"| OAuth URL: {oauth_url(app_info.id, permissions)}\n"
          f"#------------------------------#\n"
          f"| {choice(LOADING_CHOICES)}\n"
          f"#-------------------------------#\n")