diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..02ac270 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.venv +venv +venv1 +venv-linux +.idea +.github +.vscode \ No newline at end of file diff --git a/cogs/__init__.py b/cogs/__init__.py index 959ef03..dbab1de 100644 --- a/cogs/__init__.py +++ b/cogs/__init__.py @@ -79,6 +79,12 @@ async def map_mechanics_autocomplete( return await _autocomplete(current, itx.client.cache.map_mechanics.choices) +async def map_restrictions_autocomplete( + itx: discord.Interaction[core.Genji], current: str +) -> list[app_commands.Choice[str]]: + return await _autocomplete(current, itx.client.cache.map_restrictions.choices) + + async def tags_autocomplete( itx: discord.Interaction[core.Genji], current: str ) -> list[app_commands.Choice[str]]: diff --git a/cogs/maps.py b/cogs/maps.py index 1133f54..14219fb 100644 --- a/cogs/maps.py +++ b/cogs/maps.py @@ -139,6 +139,7 @@ async def random_map( map_type=cogs.map_type_autocomplete, creator=cogs.creator_autocomplete, mechanics=cogs.map_mechanics_autocomplete, + restrictions=cogs.map_restrictions_autocomplete, map_code=cogs.map_codes_autocomplete, ) @app_commands.guilds( @@ -153,6 +154,8 @@ async def map_search( creator: app_commands.Transform[int, utils.CreatorTransformer] | None = None, mechanics: app_commands.Transform[str, utils.MapMechanicsTransformer] | None = None, + restrictions: app_commands.Transform[str, utils.MapRestrictionsTransformer] + | None = None, map_type: app_commands.Transform[str, utils.MapTypeTransformer] | None = None, completed: typing.Literal["All", "Not Completed", "Completed"] = "All", only_playtest: bool = False, @@ -170,6 +173,7 @@ async def map_search( map_code: Specific map code difficulty: Difficulty filter mechanics: Mechanics filter + restrictions: Restrictions filter minimum_rating: Show maps above a specific quality rating completed: Show completed maps, non completed maps or all only_playtest: Show only playtest maps @@ -199,6 +203,7 @@ async def map_search( low_range, high_range, mechanics, + restrictions, int(getattr(minimum_rating, "value", 0)), only_maps_with_medals, only_playtest, @@ -222,6 +227,7 @@ async def _base_map_search( low_range: float | None = None, high_range: float | None = None, mechanics: str | None = None, + restrictions: str | None = None, minimum_rating: int | None = None, only_maps_with_medals: bool = False, only_playtest: bool = False, @@ -261,6 +267,7 @@ async def _base_map_search( AND ($2::text IS NULL OR map_type LIKE $2) AND ($3::text IS NULL OR map_name = $3) AND ($4::text IS NULL OR mechanics LIKE $4) + AND ($13::text IS NULL OR restrictions LIKE $13) AND ($5::numeric(10, 2) IS NULL OR $6::numeric(10, 2) IS NULL OR (difficulty >= $5::numeric(10, 2) AND difficulty < $6::numeric(10, 2))) AND ($7::int IS NULL OR quality >= $7) @@ -289,6 +296,7 @@ async def _base_map_search( itx.user.id, not only_playtest, only_maps_with_medals, + wrap_string_with_percent(restrictions), ): maps.append(_map) return maps diff --git a/cogs/records.py b/cogs/records.py index 99903ad..af10a36 100644 --- a/cogs/records.py +++ b/cogs/records.py @@ -1,5 +1,6 @@ from __future__ import annotations +import os import typing import discord @@ -153,10 +154,8 @@ async def submit_record( ).get("exists", None): is_creator = True - query = "SELECT EXISTS(SELECT restriction FROM map_restrictions WHERE map_code = $1 AND restriction = 'Multi Climb')" - check = await itx.client.database.get_row(query, map_code) - if not check.get("exists", True): - raise utils.TemporaryMultiBan + if int(os.environ["GLOBAL_MULTI_BAN"]) == 1: + await self._check_for_global_multi_ban(itx, map_code) search = [ x @@ -266,6 +265,12 @@ async def submit_record( ) await user_msg.delete() + async def _check_for_global_multi_ban(self, itx, map_code): + query = "SELECT EXISTS(SELECT restriction FROM map_restrictions WHERE map_code = $1 AND restriction = 'Multi Climb')" + check = await itx.client.database.get_row(query, map_code) + if not check.get("exists", True): + raise utils.TemporaryMultiBan + async def check_playtest(self, map_code: str): row = await self.bot.database.get_row( "SELECT official FROM maps WHERE map_code = $1", map_code diff --git a/views/maps.py b/views/maps.py index 4283511..39264cc 100644 --- a/views/maps.py +++ b/views/maps.py @@ -403,10 +403,11 @@ async def check_status(self, itx: discord.Interaction[core.Genji], count: int): ): self.ready_up_button.disabled = False await itx.message.edit(view=self) - await self.data.creator.send( - f"**{self.data.map_code}** has received enough completions and votes. " - f"Go to the thread and *Finalize* the submission!" - ) + if hasattr(self.data.creator, "send"): + await self.data.creator.send( + f"**{self.data.map_code}** has received enough completions and votes. " + f"Go to the thread and *Finalize* the submission!" + ) async def approve_map(self): self.stop()