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,8 +39,20 @@ 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)
|
|
||||||
|
|
||||||
|
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
|
||||||
|
})
|
||||||
|
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if saved_images do
|
||||||
try do
|
try do
|
||||||
prepare_images(saved_images)
|
prepare_images(saved_images)
|
||||||
|> build_query_uri()
|
|> build_query_uri()
|
||||||
@@ -56,6 +68,7 @@ defmodule PlantIdDiscordBot.Cog.PlantNet do
|
|||||||
cleanup_saved_images(saved_images)
|
cleanup_saved_images(saved_images)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp get_attachment_urls(interaction) do
|
defp get_attachment_urls(interaction) do
|
||||||
interaction.data.resolved.attachments
|
interaction.data.resolved.attachments
|
||||||
|
|||||||
Reference in New Issue
Block a user