diff --git a/wulkabot/cogs/development.py b/wulkabot/cogs/development.py index 73a13d4..1e69541 100644 --- a/wulkabot/cogs/development.py +++ b/wulkabot/cogs/development.py @@ -16,7 +16,7 @@ class Development(commands.Cog): self.bot = bot @app_commands.command() - async def sync(self, interaction: discord.Interaction, current_guild: bool = True): + async def sync(self, interaction: discord.Interaction, current_guild: bool = False): """Synchronizuje komendy bota""" # temporary check, needs refactoring if not await self.bot.is_owner(interaction.user): diff --git a/wulkabot/cogs/wulkanowy.py b/wulkabot/cogs/wulkanowy.py index a8b124e..5aa80a8 100644 --- a/wulkabot/cogs/wulkanowy.py +++ b/wulkabot/cogs/wulkanowy.py @@ -12,6 +12,7 @@ from discord.ext import commands from .. import bot from ..utils import github, wulkanowy_manager +from ..utils.wulkanowy_manager import WulkanowyBuild, WulkanowyManagerException class Wulkanowy(commands.Cog): @@ -28,10 +29,19 @@ class Wulkanowy(commands.Cog): @app_commands.command() async def pobierz(self, interaction: discord.Interaction): branches = await self.github.fetch_branches("wulkanowy", "wulkanowy") - builds = await asyncio.gather( + builds: list[WulkanowyBuild | WulkanowyManagerException] = await asyncio.gather( *(map(self.wulkanowy_manager.fetch_branch_build, branches)), return_exceptions=True ) - await interaction.response.send_message("\n".join(map(str, builds)), suppress_embeds=True) + text = [] + for branch, build in zip(branches, builds, strict=True): + if isinstance(build, WulkanowyBuild): + text.append(f"{branch}: [pobierz]({build.download_url})") + else: + text.append(f"{branch}: brak") + embed = discord.Embed( + title="Pobierz najnowsze wersje testowe!", description="\n".join(text) + ) + await interaction.response.send_message(embed=embed) async def setup(bot: bot.Wulkabot): diff --git a/wulkabot/utils/wulkanowy_manager.py b/wulkabot/utils/wulkanowy_manager.py index 912f8a2..032e41b 100644 --- a/wulkabot/utils/wulkanowy_manager.py +++ b/wulkabot/utils/wulkanowy_manager.py @@ -21,9 +21,6 @@ class WulkanowyBuild: def download_url(self) -> str: return f"{BASE_URL}/v1/download/app/{WULKANOWY_HASH}/build/{self.build_slug}/artifact/{self.artifact_slug}" - def __str__(self) -> str: - return self.download_url - class WulkanowyManagerException(Exception): pass @@ -35,7 +32,6 @@ class WulkanowyManager: async def fetch_branch_build(self, branch: str) -> WulkanowyBuild: response = await self._http.get(f"/v1/build/app/{WULKANOWY_HASH}/branch/{branch}") - response.raise_for_status() json = await response.json() if not json["success"]: raise WulkanowyManagerException(json["error"])