fix bug in war attack logger
This commit is contained in:
1 parent
b5682d7070
commit
9bf35bef61
2 files changed
+15
-13
No files matched your search
+4
-4
@@ -454,9 +454,9 @@ class WarMonitor(commands.Cog):
|
||||
return msg
|
||||
|
||||
@log_errors
|
||||
async def warattack_logger(self, warattack: pnwkit.WarAttack):
|
||||
async def warattack_logger(self, warattack: pnwkit.data.WarAttack):
|
||||
await self.log_ally_attacks(warattack)
|
||||
if not warattack.war_id in self.monitored_wars:
|
||||
if warattack.war_id not in self.monitored_wars:
|
||||
return
|
||||
war = await get_war(self.kit, warattack.war_id)
|
||||
channel = await self.get_war_channel(war.id)
|
||||
@@ -469,8 +469,8 @@ class WarMonitor(commands.Cog):
|
||||
msg = self.construct_message(warattack, attacker, defender)
|
||||
await channel.send(msg)
|
||||
|
||||
async def log_ally_attacks(self, warattack: pnwkit.WarAttack):
|
||||
if not warattack.att_id in self.allied_nations:
|
||||
async def log_ally_attacks(self, warattack: pnwkit.data.WarAttack):
|
||||
if warattack.att_id not in self.allied_nations:
|
||||
return
|
||||
channel = await self.bot.fetch_channel(ALLIANCE_ATK_CH)
|
||||
attacker, defender = await get_nation(
|
||||
|
||||
+11
-9
@@ -51,8 +51,8 @@ def timeline_button(id: int):
|
||||
|
||||
async def get_nation(
|
||||
kit: pnwkit.QueryKit, id: Union[List[int], int]
|
||||
) -> Union[pnwkit.Nation, List[pnwkit.Nation]]:
|
||||
nation = await kit.query(
|
||||
) -> Union[pnwkit.data.Nation, List[pnwkit.data.Nation]]:
|
||||
query_result = await kit.query(
|
||||
"nations",
|
||||
{"id": id},
|
||||
"nation_name, flag, num_cities, soldiers, tanks, aircraft, ships, missiles, score, nukes, id, alliance {name, id, flag}, discord, vacation_mode_turns, color, alliance_position, leader_name",
|
||||
@@ -60,18 +60,18 @@ async def get_nation(
|
||||
if isinstance(id, list):
|
||||
result = []
|
||||
result.extend(id)
|
||||
for nation in nation.nations:
|
||||
result[result.index(nation.id)] = nation
|
||||
for n in query_result.nations:
|
||||
result[result.index(n.id)] = n
|
||||
return result
|
||||
return nation.nations[0]
|
||||
return query_result.nations[0]
|
||||
|
||||
|
||||
async def get_war(
|
||||
kit: pnwkit.QueryKit, id: Union[int, List[int]]
|
||||
) -> Union[pnwkit.War, List[pnwkit.War]]:
|
||||
kit: pnwkit.QueryKit, id: int | List[int]
|
||||
) -> pnwkit.data.War | List[pnwkit.War] | None:
|
||||
war = await kit.query(
|
||||
"wars",
|
||||
{"id": id},
|
||||
{"id": id, "active": False},
|
||||
"att_alliance_id, def_alliance_id, id, att_id, def_id, turns_left, winner_id, war_type, att_infra_destroyed, att_infra_destroyed_value, def_infra_destroyed, def_infra_destroyed_value, air_superiority, ground_control, naval_blockade, att_points, def_points, att_resistance, def_resistance",
|
||||
)
|
||||
if isinstance(id, list):
|
||||
@@ -80,4 +80,6 @@ async def get_war(
|
||||
for war in war.wars:
|
||||
result[result.index(war.id)] = war
|
||||
return result
|
||||
return war.wars[0]
|
||||
if war.wars:
|
||||
return war.wars[0]
|
||||
return None
|
||||
Reference in new issue
Block a user