Files
plantid-discord-bot/lib/plantid_discord_bot/utils.ex
T
owenrees 02372f2076 Feat/error logs (#16)
* added list of tasks to achieve

* update deps

* update elixir version in CI/CD pipeline

* update todo with branch push checks

* underscores separation of large numbers

* update elixir version and deps

* add basic module  docs

* remove IO.inspect call

* check if list is empty rather than traversing list for length

* revert empty list code

* duration tests

* add mime type tests

* use logger instread of inspect, remove todos

* replace list length check with Enum.empty

* replace list length check with !Enum.empty?

* numbers readability fix by using underscores on large numbers

* iucn parser replaced case with multiclause function and added test

* replace map and join with map_join

* fix multiple spec issues where map() must be inside a list
2025-12-06 23:41:59 +01:00

23 lines
556 B
Elixir

defmodule PlantIdDiscordBot.Utils do
@moduledoc """
Bot related utility functions.
"""
def get_uptime() do
start_time = Application.get_env(:plantid_discord_bot, :start_time)
DateTime.diff(DateTime.utc_now(), start_time)
|> PlantIdDiscordBot.Utils.Duration.sec_to_str()
end
def get_shard_latency() do
Nostrum.Util.get_all_shard_latencies()
|> Map.get(0)
|> to_string()
|> Kernel.<>("ms")
end
def get_guilds_names() do
Nostrum.Cache.GuildCache.fold([], fn %{name: name}, acc -> [name | acc] end)
end
end