mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-23 04:26:57 +00:00
basic error handling test
This commit is contained in:
@@ -3,6 +3,13 @@ defmodule PlantIdDiscordBotTest.Mocks.Nostrum.Api do
|
||||
Mocks the Nostrum.Api module.
|
||||
"""
|
||||
|
||||
# def create_message(_channel_id, content), do: {:ok, content}
|
||||
|
||||
def create_message(_channel_id, content) do
|
||||
send(self(), {:create_message, 123456, content})
|
||||
{:ok, content}
|
||||
end
|
||||
|
||||
def create_interaction_response(_interaction, response), do: {:ok, response}
|
||||
|
||||
def get_application_information() do
|
||||
|
||||
@@ -7,7 +7,11 @@ defmodule PlantIdDiscordBot.Cog.PlantNetMessage do
|
||||
alias PlantIdDiscordBot.PlantNet.Parser
|
||||
alias PlantIdDiscordBot.FileServer.File
|
||||
|
||||
# @guild Application.compile_env(:plantid_discord_bot, :guild)
|
||||
# mock modules
|
||||
@api Application.compile_env(:plantid_discord_bot, :api)
|
||||
@guild Application.compile_env(:plantid_discord_bot, :guild)
|
||||
|
||||
# env vars
|
||||
@plantnet_api_base_url Application.compile_env(:plantid_discord_bot, :plantnet_api_base_url)
|
||||
@max_results Application.compile_env(:plantid_discord_bot, :max_results)
|
||||
|
||||
@@ -35,10 +39,10 @@ defmodule PlantIdDiscordBot.Cog.PlantNetMessage do
|
||||
e ->
|
||||
Logger.error(Exception.format(:error, e, __STACKTRACE__),
|
||||
guild_id: message.guild_id,
|
||||
guild_name: Guild.get_guild_name!(message.guild_id)
|
||||
guild_name: @guild.get_guild_name!(message.guild_id)
|
||||
)
|
||||
|
||||
Api.create_message(message.channel_id,
|
||||
@api.create_message(message.channel_id,
|
||||
content: "An error has occured. Please try again later."
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user