Fix cooldown, again
All checks were successful
Build and Publish / build_and_publish (push) Successful in 1m14s

This commit is contained in:
Nexus 2024-07-05 01:03:33 +01:00
parent 495d10c78d
commit 34511e87ea

View file

@ -166,7 +166,7 @@ class ElectionCog(commands.Cog):
symbol = "+" if net > 0 else ''
description_parts.append(
f"**{party_name}**: {symbol}{net:,} ({councillors:,} total, "
f"{last_election:,} predicted by exit poll)"
f"{last_election:,} predicted by exit poll)"
)
top_party = list(sorted(colour_scores.keys(), key=lambda k: colour_scores[k], reverse=True))[0]
@ -178,12 +178,15 @@ class ElectionCog(commands.Cog):
async def get_election_results(self, ctx: discord.ApplicationContext):
"""Gets the current election results"""
class RefreshView(discord.ui.View):
def __init__(**kwargs):
super().__init__(**kwargs)
self.last_edit = discord.utils.utcnow()
@discord.ui.button(label="Refresh", style=discord.ButtonStyle.primary, emoji="\U0001f501")
async def refresh(_self, _btn, interaction):
await interaction.response.defer(invisible=True)
if interaction.message.edited_at:
if (discord.utils.utcnow() - interaction.message.edited_at).total_seconds() < 5:
return await interaction.followup.send("Slow down.", ephemeral=True)
if (discord.utils.utcnow() - self.last_edit).total_seconds() < 10:
return await interaction.followup.send("Slow down.", ephemeral=True)
try:
embed = await self._get_embed()
except Exception as e: