Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -221,20 +221,21 @@ async def on_member_join(member):
|
|
221 |
@bot.command()
|
222 |
async def search(ctx, *, query: str):
|
223 |
"""Search for a bible verse."""
|
224 |
-
bible_api_url = f"
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
228 |
verses = response.json()
|
229 |
if verses:
|
230 |
# If verses are found, concatenate them into a single message
|
231 |
-
passage = "\n".join(
|
232 |
passage = truncate_response(passage)
|
233 |
embed = discord.Embed(title=f"Search Results for '{query}'", description=passage, color=discord.Color.blue())
|
234 |
else:
|
235 |
embed = discord.Embed(title="Search Results", description="No results found.", color=discord.Color.red())
|
236 |
-
|
237 |
-
embed = discord.Embed(title="Search Results", description="
|
238 |
|
239 |
embed.set_footer(text="Created by Cosmos")
|
240 |
await ctx.reply(embed=embed)
|
|
|
221 |
@bot.command()
|
222 |
async def search(ctx, *, query: str):
|
223 |
"""Search for a bible verse."""
|
224 |
+
bible_api_url = f"http://labs.bible.org/api/?passage={query}&formatting=plain&type=json"
|
225 |
+
try:
|
226 |
+
response = requests.get(bible_api_url)
|
227 |
+
response.raise_for_status()
|
228 |
+
|
229 |
verses = response.json()
|
230 |
if verses:
|
231 |
# If verses are found, concatenate them into a single message
|
232 |
+
passage = "\n".join(verses)
|
233 |
passage = truncate_response(passage)
|
234 |
embed = discord.Embed(title=f"Search Results for '{query}'", description=passage, color=discord.Color.blue())
|
235 |
else:
|
236 |
embed = discord.Embed(title="Search Results", description="No results found.", color=discord.Color.red())
|
237 |
+
except requests.RequestException as e:
|
238 |
+
embed = discord.Embed(title="Search Results", description=f"Error: {e}", color=discord.Color.red())
|
239 |
|
240 |
embed.set_footer(text="Created by Cosmos")
|
241 |
await ctx.reply(embed=embed)
|