mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-23 04:26: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
|
def handle_event({:READY, _data, _ws_state}) do
|
||||||
Api.create_global_application_command(@global_application_commands)
|
Api.create_global_application_command(@global_application_commands)
|
||||||
# TODO fix, not working
|
|
||||||
Api.update_status(:online, %{name: "Guess the Plant | /help", type: 0})
|
Api.update_status(:online, %{name: "Guess the Plant | /help", type: 0})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -39,21 +39,34 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
|
|||||||
|
|
||||||
attachment_urls = get_attachment_urls(interaction)
|
attachment_urls = get_attachment_urls(interaction)
|
||||||
original_images = get_original_images(attachment_urls)
|
original_images = get_original_images(attachment_urls)
|
||||||
saved_images = File.download_and_save_files!(attachment_urls)
|
|
||||||
|
|
||||||
try do
|
saved_images =
|
||||||
prepare_images(saved_images)
|
try do
|
||||||
|> build_query_uri()
|
File.download_and_save_files!(attachment_urls)
|
||||||
|> get_response(interaction, original_images)
|
rescue
|
||||||
rescue
|
e in ArgumentError ->
|
||||||
e ->
|
Api.create_followup_message(interaction.application_id, interaction.token, %{
|
||||||
Logger.error(Exception.format(:error, e, __STACKTRACE__))
|
content: e.message
|
||||||
|
})
|
||||||
|
|
||||||
Api.create_followup_message(interaction.application_id, interaction.token, %{
|
nil
|
||||||
content: "An error occurred. This error has been logged."
|
end
|
||||||
})
|
|
||||||
after
|
if saved_images do
|
||||||
cleanup_saved_images(saved_images)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user