Fixed exception on empty search result
This commit is contained in:
parent
f27d195964
commit
c672d6a049
|
@ -25,6 +25,13 @@ class Search(commands.Cog):
|
||||||
self.latestMessage = 0
|
self.latestMessage = 0
|
||||||
|
|
||||||
async def createEmbed(self):
|
async def createEmbed(self):
|
||||||
|
if self.activeObject.total_pages == 0:
|
||||||
|
embed = discord.Embed(
|
||||||
|
title = "No search results",
|
||||||
|
description = "The search returned nothing. Did you make a typo?",
|
||||||
|
colour = 0x56d926
|
||||||
|
)
|
||||||
|
else:
|
||||||
response = self.activeObject.response
|
response = self.activeObject.response
|
||||||
node = response.nodes[self.activeObject.page]
|
node = response.nodes[self.activeObject.page]
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
|
@ -87,6 +94,7 @@ class Search(commands.Cog):
|
||||||
embed = await self.createEmbed()
|
embed = await self.createEmbed()
|
||||||
message = await ctx.send(embed=embed)
|
message = await ctx.send(embed=embed)
|
||||||
self.latestMessage = message.id
|
self.latestMessage = message.id
|
||||||
|
if self.activeObject.total_pages > 0:
|
||||||
await message.add_reaction("⬅️")
|
await message.add_reaction("⬅️")
|
||||||
await message.add_reaction("➡️")
|
await message.add_reaction("➡️")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue