mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-22 20:16:57 +00:00
no accepted image type error return
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user