diff --git a/bot/libs/tickets/views.py b/bot/libs/tickets/views.py index 12aeb7a..34a7c00 100644 --- a/bot/libs/tickets/views.py +++ b/bot/libs/tickets/views.py @@ -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, @@ -231,7 +243,8 @@ 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( @@ -239,6 +252,22 @@ async def confirm( ) 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(