Skip to content

Commit

Permalink
⚙️Fixed /file
Browse files Browse the repository at this point in the history
  • Loading branch information
bth123 committed Sep 7, 2024
1 parent b598c1c commit 1107e0a
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions cogs/minecraft/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="Скидывает файл с ванильного датапака/ресурспака.",
Expand Down

0 comments on commit 1107e0a

Please sign in to comment.