From dd4b7e7d49bb68ea778329802859afe3f56fb09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=95=98=EB=88=84?= Date: Wed, 22 Mar 2023 14:06:29 +0000 Subject: [PATCH] fix: have perfect achievements only --- app.py | 6 ++++++ bot.py | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 3f18807..c457c05 100644 --- a/app.py +++ b/app.py @@ -118,8 +118,14 @@ async def update_metadata(response: Response, code: str, steam_id: str = Cookie( role = RoleConnection(platform_name=f"Steam - {data['gameName']}", platform_username=abc["response"]["players"][0]["personaname"]) success = 0 total = len(data["achievements"]) + role.add_or_edit_metadata(key="tutorial", value=False) + role.add_or_edit_metadata(key="allperfetct", value=False) async for achieve in async_list(data["achievements"]): if achieve["achieved"] == 1: + if achieve["apiname"] == "honor_roll": + role.add_or_edit_metadata(key="tutorial", value=True) + if achieve["apiname"] == "go_to_bed": + role.add_or_edit_metadata(key="allperfetct", value=True) success += 1 percentage = (success / total) * 100 role.add_or_edit_metadata(key="percentage", value=percentage) diff --git a/bot.py b/bot.py index a0e1427..4b43588 100644 --- a/bot.py +++ b/bot.py @@ -25,6 +25,18 @@ async def async_list(values: list) -> Any: async def _addConnection(inter: disnake.ApplicationCommandInteraction): await inter.response.defer(ephemeral=True) records = [ + RoleMetadataRecord( + key="tutorial", + name="Honor roll", + description="튜토리얼 스테이지를 퍼펙트로 클리어해야 합니다.", + type=RoleMetadataType.boolean_equal + ), + RoleMetadataRecord( + key="allperfect", + name="Go to bed", + description="모든 스테이지를 퍼펙트로 클리어해야 합니다.", + type=RoleMetadataType.boolean_equal + ), RoleMetadataRecord( key="complete", name="ALL CLEAR!!", @@ -36,7 +48,7 @@ async def _addConnection(inter: disnake.ApplicationCommandInteraction): name="Achievement Percentage", description="% 이상의 도전 과제를 달성해야 합니다.", type=RoleMetadataType.interger_greater_than_or_equal - ) + ), ] async with LinkedRolesOAuth2(client_id=os.getenv("CLIENT_ID"), token=os.getenv("BOT_TOKEN")) as client: try: