no accepted image type error return

This commit is contained in:
Owen
2024-12-22 21:17:21 +01:00
parent 593704cb15
commit b8f7dab8f4
2 changed files with 26 additions and 14 deletions
-1
View File
@@ -11,7 +11,6 @@ defmodule PlantIdDiscordBot.Consumer do
def handle_event({:READY, _data, _ws_state}) do
Api.create_global_application_command(@global_application_commands)
# TODO fix, not working
Api.update_status(:online, %{name: "Guess the Plant | /help", type: 0})
end
+26 -13
View File
@@ -39,21 +39,34 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
attachment_urls = get_attachment_urls(interaction)
original_images = get_original_images(attachment_urls)
saved_images = File.download_and_save_files!(attachment_urls)
try do
prepare_images(saved_images)
|> build_query_uri()
|> get_response(interaction, original_images)
rescue
e ->
Logger.error(Exception.format(:error, e, __STACKTRACE__))
saved_images =
try do
File.download_and_save_files!(attachment_urls)
rescue
e in ArgumentError ->
Api.create_followup_message(interaction.application_id, interaction.token, %{
content: e.message
})
Api.create_followup_message(interaction.application_id, interaction.token, %{
content: "An error occurred. This error has been logged."
})
after
cleanup_saved_images(saved_images)
nil
end
if saved_images do
try do
prepare_images(saved_images)
|> build_query_uri()
|> get_response(interaction, original_images)
rescue
e ->
Logger.error(Exception.format(:error, e, __STACKTRACE__))
Api.create_followup_message(interaction.application_id, interaction.token, %{
content: "An error occurred. This error has been logged."
})
after
cleanup_saved_images(saved_images)
end
end
end