coc.py: IndexError

ERROR:root:Events had an error!
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/coc/events.py", line 1067, in _run_war_update
    war = await meth(clan_tag, cls=self.war_cls, round=cwl_round)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/coc/client.py", line 1143, in get_current_war
    async for war in self.get_league_wars(league_group.rounds[-1], cls=cls, **kwargs):
                                          ~~~~~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range

this is what occurs if you have a clan_tag that is in league and a clan_tag that isnt in the league, is there any way to get around this?

functions used:

@coc.WarEvents.war_attack(tags=clan_tags)
    async def _current_war_stats(attack, war):
        log.info("Event triggered")
        clan_tag = war.clan.tag
        embed = create_embed(
            f"{escape_markdown(war.clan.name)}: War attack",
            f"Attack number {attack.order}\n({attack.attacker.map_position}). `{escape_markdown(attack.attacker.name)}` of {escape_markdown(attack.attacker.clan.name)} attacked ({attack.defender.map_position}). `{escape_markdown(attack.defender.name)}` of {escape_markdown(attack.defender.clan.name)}",
            discord.Colour.green(),
            "",
            "",
        )

        await send_embed_to_webhook(clan_tag, embed)

    @coc.WarEvents.new_war(tags=clan_tags)
    async def _new_war(war):
        log.info("Event triggered")
        clan_tag = war.clan.tag
        embed = create_embed(
            f"{escape_markdown(war.clan.name)}: War",
            f"New war against {escape_markdown(war.opponent.name)} initiated",
            discord.Colour.green(),
            "",
            "",
        )

        await send_embed_to_webhook(clan_tag, embed)

coc.py==2.4.1

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

@doluk

I have managed to update! Thanks for this great resource!

No, the important changes are:

  • renaming versus to builder_base
  • renaming warlog and raidlog to war_log and raid_log
  • the login shortcuts coc.login and coc.login_with_keys got removed