def wiki(self, ctx, *, search_query):
logger.info('!wiki ' + search_query + ' - User: ' + str(ctx.message.author))
data = self.utils.search_wiki(search_query)
if len(data) == 1:
result_id = 0
else:
if 1 < len(data) <= 10:
# Display all results then await choice
i = 1
text = ''
for entry in data:
text += str(i) + ') **' + entry[1] + '** - *Category: ' + str(entry[2]) + '*\n'
i += 1
em = discord.Embed(title='Please enter the number of the targeted wiki entry',
description=text,
colour=0x3D9900)
await self.bot.send_message(ctx.message.channel, '', embed=em)
msg = await self.bot.wait_for_message(author=ctx.message.author)
if int(msg.content) >= i or int(msg.content) < 1:
await self.bot.say('Invalid choice')
return
result_id = int(msg.content) - 1
else:
await self.bot.send_message(ctx.message.channel, 'No matching entry found.')
return
temp = json.JSONDecoder().decode(data[result_id][3])
tempembed = discord.Embed().from_data(temp)
await self.bot.send_message(ctx.message.channel, '', embed=tempembed)
评论列表
文章目录