mirror of
https://github.com/TheRealOwenRees/plantid-discord-bot.git
synced 2026-07-23 12:36:58 +00:00
02372f2076
* 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
23 lines
556 B
Elixir
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
|