From 1107e0a24b600ec6ebeeb5204b6b53d467714aad Mon Sep 17 00:00:00 2001 From: bth123 Date: Sat, 7 Sep 2024 12:53:35 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8FFixed=20/file?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cogs/minecraft/file.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/cogs/minecraft/file.py b/cogs/minecraft/file.py index 06d5a28..9bd714c 100644 --- a/cogs/minecraft/file.py +++ b/cogs/minecraft/file.py @@ -17,24 +17,25 @@ files = {} latest_version = "" -@tasks.loop(minutes=3) -async def update_files_list(): - global latest_version, files - if (newer_version:=db.find_one({"_id": "latest_known_snapshot"})["_"]) != latest_version: - latest_version = newer_version - async with ClientSession(headers=GITHUB_HEADERS) as session: - for tree_name in ("data", "assets"): - async with session.get(f"https://api.github.com/repos/misode/mcmeta/git/trees/{tree_name}?recursive=1", - headers={"User-Agent": "AntBot discord bot"}) as response: - tree = await response.json() - tree = tree.get("tree", []) - files.update({"/".join(item["path"].split("/")[-2:]): item["path"] for item in tree if item["type"] == "blob"}) - files.pop(".gitattributes") - class FileCommand(commands.Cog): def __init__(self, bot): self.bot = bot + self.update_files_list.start() + + @tasks.loop(minutes=6) + async def update_files_list(self): + global latest_version, files + if (newer_version:=db.find_one({"_id": "latest_known_snapshot"})["_"]) != latest_version: + latest_version = newer_version + async with ClientSession(headers=GITHUB_HEADERS) as session: + for tree_name in ("data", "assets"): + async with session.get(f"https://api.github.com/repos/misode/mcmeta/git/trees/{tree_name}?recursive=1", + headers={"User-Agent": "AntBot discord bot"}) as response: + tree = await response.json() + tree = tree.get("tree", []) + files.update({"/".join(item["path"].split("/")[-2:]): item["path"] for item in tree if item["type"] == "blob"}) + files.pop(".gitattributes") @commands.hybrid_command(aliases=["f", "asset", "mcasset", "файл", "ашду", "ассет", "эссет", "мсассет", "мсэссэт","фыыуе","ьсфыыуе"], description="Скидывает файл с ванильного датапака/ресурспака.",