1
0

fix: have perfect achievements only

This commit is contained in:
オスカー、 2023-03-22 14:06:29 +00:00 committed by GitHub
parent 60ce37f101
commit dd4b7e7d49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

6
app.py
View File

@ -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)

14
bot.py
View File

@ -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: