Skip to content

Commit

Permalink
Apply guild and account age into ticket checks
Browse files Browse the repository at this point in the history
  • Loading branch information
No767 committed Jul 17, 2024
1 parent ec5e656 commit 16c9c1c
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion bot/libs/tickets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ async def delete_response(self, interaction: discord.Interaction):

self.stop()

async def get_or_fetch_member(self, member_id: int) -> Optional[discord.Member]:
member = self.guild.get_member(member_id)
if member is not None:
return member

members = await self.guild.query_members(
limit=1, user_ids=[member_id], cache=True
)
if not members:
return None
return members[0]

@discord.ui.button(
label="Checklist",
style=discord.ButtonStyle.primary,
Expand Down Expand Up @@ -231,14 +243,31 @@ async def confirm(

applied_tags = [k for k, v in tags.items() if v is True]

guild_settings = await self.config_cog.get_partial_guild_settings(self.guild.id)
guild_settings = await self.config_cog.get_guild_settings(self.guild.id)
potential_member = await self.get_or_fetch_member(author.id)

if not guild_settings:
await interaction.response.send_message(
"Unable to find guild settings", ephemeral=True
)
return

if (self.guild.created_at - interaction.created_at) < guild_settings.guild_age:
await interaction.response.send_message(
"The guild is too young in order to utilize Rodhaj.", ephemeral=True
)
return
elif (
potential_member
): # Since we are checking join times, if we don't have the proper member, we can only skip it.
joined_at = potential_member.joined_at or discord.utils.utcnow()
if (joined_at - interaction.created_at) < guild_settings.account_age:
await interaction.response.send_message(
"This account joined the server too soon in order to utilize Rodhaj.",
ephemeral=True,
)
return

if not status.title.is_set() or not status.tags.is_set():
dict_status = {"title": status.title, "tags": status.tags}
formatted_status = "\n".join(
Expand Down

0 comments on commit 16c9c1c

Please sign in to comment.