register app for some terms
This commit is contained in:
parent
a046ba54a0
commit
6b96771980
1 changed files with 10 additions and 8 deletions
18
bot.py
18
bot.py
|
@ -13,6 +13,9 @@ bot = commands.InteractionBot(
|
||||||
intents=disnake.Intents.default()
|
intents=disnake.Intents.default()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def list_chunk(lst, n):
|
||||||
|
return [lst[i:i+n] for i in range(0, len(lst), n)]
|
||||||
|
|
||||||
async def async_list(values: list) -> Any:
|
async def async_list(values: list) -> Any:
|
||||||
for value in values:
|
for value in values:
|
||||||
yield value
|
yield value
|
||||||
|
@ -26,13 +29,13 @@ async def _addConnection(inter: disnake.ApplicationCommandInteraction):
|
||||||
RoleMetadataRecord(
|
RoleMetadataRecord(
|
||||||
key="complete",
|
key="complete",
|
||||||
name="ALL CLEAR!!",
|
name="ALL CLEAR!!",
|
||||||
description="게임의 모든 도전 과제를 달성했는지 여부입니다.",
|
description="게임의 도전 과제를 모두 달성해야 합니다.",
|
||||||
type=RoleMetadataType.boolean_equal
|
type=RoleMetadataType.boolean_equal
|
||||||
),
|
),
|
||||||
RoleMetadataRecord(
|
RoleMetadataRecord(
|
||||||
key="percentage",
|
key="percentage",
|
||||||
name="Achievement Percentage",
|
name="Achievement Percentage",
|
||||||
description="게임의 도전 과제 달성률입니다.",
|
description="% 이상의 도전 과제를 달성해야 합니다.",
|
||||||
type=RoleMetadataType.interger_greater_than_or_equal
|
type=RoleMetadataType.interger_greater_than_or_equal
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
@ -50,12 +53,11 @@ async def _addConnection(inter: disnake.ApplicationCommandInteraction):
|
||||||
type=RoleMetadataType.boolean_equal
|
type=RoleMetadataType.boolean_equal
|
||||||
))
|
))
|
||||||
|
|
||||||
|
await inter.edit_original_message(content="역할 데이터 등록을 시작합니다!")
|
||||||
async with LinkedRolesOAuth2(client_id=os.getenv("CLIENT_ID"), token=os.getenv("BOT_TOKEN")) as client:
|
async with LinkedRolesOAuth2(client_id=os.getenv("CLIENT_ID"), token=os.getenv("BOT_TOKEN")) as client:
|
||||||
try:
|
async for rec in async_list(list_chunk(records, 4)):
|
||||||
result = await client.register_role_metadata(records=tuple(records), force=True)
|
result = await client.register_role_metadata(records=tuple(rec), force=True)
|
||||||
except Exception as e:
|
await inter.followup.send(result)
|
||||||
await inter.edit_original_message(content=f"연동에 실패했습니다.\n{e}")
|
await asyncio.sleep(5)
|
||||||
else:
|
|
||||||
await inter.edit_original_message(content=str(result))
|
|
||||||
|
|
||||||
bot.run(os.getenv("BOT_TOKEN"))
|
bot.run(os.getenv("BOT_TOKEN"))
|
Reference in a new issue