def jeopardy_start(self, ctx):
if self.jeopardy_active:
await self.bot.embed_reply(":no_entry: There's already a jeopardy game in progress")
return
self.jeopardy_active = True
categories = []
category_titles = []
self.jeopardy_board_output = ""
url = "http://jservice.io/api/random"
for i in range(6):
async with clients.aiohttp_session.get(url) as resp:
data = await resp.json()
categories.append(data[0]["category_id"])
for category in categories:
url = "http://jservice.io/api/category?id=" + str(category)
async with clients.aiohttp_session.get(url) as resp:
data = await resp.json()
category_titles.append(string.capwords(data["title"]))
self.jeopardy_board.append([category, False, False, False, False, False])
self.jeopardy_max_width = max(len(category_title) for category_title in category_titles)
for category_title in category_titles:
self.jeopardy_board_output += category_title.ljust(self.jeopardy_max_width) + " 200 400 600 800 1000\n"
await self.bot.embed_say(clients.code_block.format(self.jeopardy_board_output))
评论列表
文章目录