Skip to content

Commit

Permalink
cooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
Selyss committed Dec 5, 2023
1 parent 829baa6 commit 7691347
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cogs/inquiry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
from nextcord import slash_command
from nextcord.ext.commands import Bot, Cog
from nextcord.ext import commands
import nextcord


Expand Down Expand Up @@ -29,13 +30,23 @@ def get_time() -> str:
class TicketView(nextcord.ui.View):
def __init__(self) -> None:
super().__init__(timeout=None)
self.cooldown = commands.CooldownMapping.from_cooldown(
1, 60 * 1440, commands.BucketType.member # 1 request per day
)

@nextcord.ui.button(
label="📝 Open Inquiry",
style=nextcord.ButtonStyle.blurple,
custom_id="ticket:inquiry",
)
async def open_inquiry(self, btn: nextcord.ui.Button, inter: nextcord.Interaction):
inter.message.author = inter.user
bucket = self.cooldown.get_bucket(inter.message)
retry = bucket.update_rate_limit()
if retry:
return await inter.response.send_message(
f"Slow down! Try again in {round(retry, 1)} seconds.", ephemeral=True
)
await inter.response.send_modal(QuestionForm())

@nextcord.ui.button(
Expand All @@ -44,6 +55,13 @@ async def open_inquiry(self, btn: nextcord.ui.Button, inter: nextcord.Interactio
custom_id="ticket:advertisement",
)
async def advertisement(self, btn: nextcord.ui.Button, inter: nextcord.Interaction):
inter.message.author = inter.user
bucket = self.cooldown.get_bucket(inter.message)
retry = bucket.update_rate_limit()
if retry:
return await inter.response.send_message(
f"Slow down! Try again in {round(retry, 1)} seconds.", ephemeral=True
)
await inter.response.send_modal(AdForm())


Expand Down

0 comments on commit 7691347

Please sign in to comment.