mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-23 04:26:57 +00:00
reworked aliases
This commit is contained in:
@@ -4,10 +4,9 @@ defmodule PlantIdDiscordBot.Consumer do
|
||||
"""
|
||||
use Nostrum.Consumer
|
||||
alias Nostrum.Api
|
||||
alias PlantIdDiscordBot.Cog
|
||||
alias PlantIdDiscordBot.Consumer.Commands
|
||||
alias PlantIdDiscordBot.{Cog, Consumer}
|
||||
|
||||
@global_application_commands Commands.global_application_commands()
|
||||
@global_application_commands Consumer.Commands.global_application_commands()
|
||||
|
||||
def handle_event({:READY, _data, _ws_state}) do
|
||||
Api.create_global_application_command(@global_application_commands)
|
||||
|
||||
@@ -9,6 +9,7 @@ defmodule PlantIdDiscordBot.Cog.PlantNetMessage do
|
||||
alias Nostrum.Cache.GuildCache
|
||||
alias PlantIdDiscordBot.Metrics
|
||||
|
||||
# TODO reintroduce mocks
|
||||
# @api Application.compile_env(:plantid_discord_bot, :api)
|
||||
@plantnet_api_base_url Application.compile_env(:plantid_discord_bot, :plantnet_api_base_url)
|
||||
@max_results Application.compile_env(:plantid_discord_bot, :max_results)
|
||||
@@ -34,11 +35,14 @@ defmodule PlantIdDiscordBot.Cog.PlantNetMessage do
|
||||
|> Enum.map(fn attachment -> attachment.url end)
|
||||
|> File.download_and_save_files!()
|
||||
rescue
|
||||
# TODO add guild id and name into error
|
||||
# TODO test by raising error
|
||||
e in ArgumentError ->
|
||||
Api.create_message(message.channel_id, content: e.message)
|
||||
nil
|
||||
end
|
||||
|
||||
# TODO improve composition
|
||||
if saved_images do
|
||||
try do
|
||||
prepare_images(saved_images)
|
||||
@@ -72,6 +76,8 @@ defmodule PlantIdDiscordBot.Cog.PlantNetMessage do
|
||||
|
||||
defp get_response(query_uri, message) do
|
||||
guild_id = message.guild_id
|
||||
|
||||
# TODO move into its own function
|
||||
{:ok, %{name: guild_name}} = GuildCache.get(guild_id)
|
||||
|
||||
case HTTPoison.get(query_uri) do
|
||||
|
||||
Reference in New Issue
Block a user