Skip to content

Commit

Permalink
fix button click
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicTheDev committed Dec 17, 2024
1 parent f6b1350 commit 6bbf5e7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions background/logs/war.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,14 @@ async def on_button_click(self, ctx: disnake.MessageInteraction):
await ctx.response.defer(ephemeral=True)
war_id = (str(ctx.data.custom_id).split('_'))[-1]
clan_tag = (str(ctx.data.custom_id).split('_'))[1]
war_data = await self.bot.clan_wars.find_one({'war_id': war_id})
war_data = await self.bot.clan_wars.find_one({"$and" : [{'war_id': war_id}, {"data" : {"$ne" : None}}]})
war = None
if war_data is not None:
war = coc.ClanWar(data=war_data['data'], client=self.bot.coc_client, clan_tag=clan_tag)
if war is None:
war = await self.bot.get_clanwar(clanTag=clan_tag)
if war_id != f'{war.clan.tag}v{war.opponent.tag}-{int(war.preparation_start_time.time.timestamp())}':
war = None
if war is None:
return await ctx.send(content='No War Found', ephemeral=True)
attack_embed: disnake.Embed = await attacks_embed(bot=self.bot, war=war)
Expand All @@ -262,12 +264,14 @@ async def on_button_click(self, ctx: disnake.MessageInteraction):
await ctx.response.defer(ephemeral=True)
war_id = (str(ctx.data.custom_id).split('_'))[-1]
clan_tag = (str(ctx.data.custom_id).split('_'))[1]
war_data = await self.bot.clan_wars.find_one({'war_id': war_id})
war_data = await self.bot.clan_wars.find_one({"$and" : [{'war_id': war_id}, {"data" : {"$ne" : None}}]})
war = None
if war_data is not None:
war = coc.ClanWar(data=war_data['data'], client=self.bot.coc_client, clan_tag=clan_tag)
if war is None:
war = await self.bot.get_clanwar(clanTag=clan_tag)
if war_id != f'{war.clan.tag}v{war.opponent.tag}-{int(war.preparation_start_time.time.timestamp())}':
war = None
if war is None:
return await ctx.send(content='No War Found', ephemeral=True)
attack_embed = await defenses_embed(bot=self.bot, war=war)
Expand All @@ -277,12 +281,14 @@ async def on_button_click(self, ctx: disnake.MessageInteraction):
await ctx.response.defer()
war_id = (str(ctx.data.custom_id).split('_'))[-1]
clan_tag = (str(ctx.data.custom_id).split('_'))[1]
war_data = await self.bot.clan_wars.find_one({'war_id': war_id})
war_data = await self.bot.clan_wars.find_one({"$and" : [{'war_id': war_id}, {"data" : {"$ne" : None}}]})
war = None
if war_data is not None:
war = coc.ClanWar(data=war_data['data'], client=self.bot.coc_client, clan_tag=clan_tag)
if war is None:
war = await self.bot.get_clanwar(clanTag=clan_tag)
if war_id != f'{war.clan.tag}v{war.opponent.tag}-{int(war.preparation_start_time.time.timestamp())}':
war = None
if war is None:
return await ctx.send(content='No War Found', ephemeral=True)
embed = await main_war_page(bot=self.bot, war=war)
Expand All @@ -293,12 +299,14 @@ async def on_button_click(self, ctx: disnake.MessageInteraction):
await ctx.response.defer(ephemeral=True)
war_id = (str(ctx.data.custom_id).split('_'))[-1]
clan_tag = (str(ctx.data.custom_id).split('_'))[1]
war_data = await self.bot.clan_wars.find_one({'war_id': war_id})
war_data = await self.bot.clan_wars.find_one({"$and" : [{'war_id': war_id}, {"data" : {"$ne" : None}}]})
war = None
if war_data is not None:
war = coc.ClanWar(data=war_data['data'], client=self.bot.coc_client, clan_tag=clan_tag)
if war is None:
war = await self.bot.get_clanwar(clanTag=clan_tag)
if war_id != f'{war.clan.tag}v{war.opponent.tag}-{int(war.preparation_start_time.time.timestamp())}':
war = None
if war is None:
return await ctx.send(content='No War Found', ephemeral=True)

Expand Down

0 comments on commit 6bbf5e7

Please sign in to comment.