Fix cooldown, again
All checks were successful
Build and Publish / build_and_publish (push) Successful in 1m14s
All checks were successful
Build and Publish / build_and_publish (push) Successful in 1m14s
This commit is contained in:
parent
495d10c78d
commit
34511e87ea
1 changed files with 7 additions and 4 deletions
|
@ -178,11 +178,14 @@ class ElectionCog(commands.Cog):
|
||||||
async def get_election_results(self, ctx: discord.ApplicationContext):
|
async def get_election_results(self, ctx: discord.ApplicationContext):
|
||||||
"""Gets the current election results"""
|
"""Gets the current election results"""
|
||||||
class RefreshView(discord.ui.View):
|
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")
|
@discord.ui.button(label="Refresh", style=discord.ButtonStyle.primary, emoji="\U0001f501")
|
||||||
async def refresh(_self, _btn, interaction):
|
async def refresh(_self, _btn, interaction):
|
||||||
await interaction.response.defer(invisible=True)
|
await interaction.response.defer(invisible=True)
|
||||||
if interaction.message.edited_at:
|
if (discord.utils.utcnow() - self.last_edit).total_seconds() < 10:
|
||||||
if (discord.utils.utcnow() - interaction.message.edited_at).total_seconds() < 5:
|
|
||||||
return await interaction.followup.send("Slow down.", ephemeral=True)
|
return await interaction.followup.send("Slow down.", ephemeral=True)
|
||||||
try:
|
try:
|
||||||
embed = await self._get_embed()
|
embed = await self._get_embed()
|
||||||
|
|
Loading…
Reference in a new issue