diff --git a/lib/service/discord.ex b/lib/service/discord.ex index 68873d0..0628526 100644 --- a/lib/service/discord.ex +++ b/lib/service/discord.ex @@ -107,7 +107,7 @@ defmodule Service.Discord do [ "Message from ", - msg.author_id |> Nostrum.Struct.User.full_name() |> inspect(), + msg.author_id |> Nostrum.Api.get_user!() |> Nostrum.Struct.User.full_name() |> inspect(), " lead to ", error_type, " in plugin ", @@ -145,7 +145,9 @@ defmodule Service.Discord do "Erlang-level error ", inspect(level), "\n", - message |> S.pp() |> Service.Discord.txt_format(:source_block) + message + |> TxtBlock.to_str_list(Service.Discord) + |> Service.Discord.txt_format(:source_block) ] _ = send_msg(channel_id, log) diff --git a/lib/stampede.ex b/lib/stampede.ex index 854f6dd..6fc741d 100644 --- a/lib/stampede.ex +++ b/lib/stampede.ex @@ -80,11 +80,26 @@ defmodule Stampede do :code.all_available() |> Enum.map(&(elem(&1, 0) |> to_string)) |> Enum.filter(&String.starts_with?(&1, to_string(module_name) <> ".")) - |> Enum.sort() |> Enum.map(&String.to_atom/1) |> MapSet.new() end + def find_all_plugins() do + find_submodules(Plugin) + |> Enum.reduce(MapSet.new(), fn + mod, acc -> + b = + apply(mod, :__info__, [:attributes]) + |> Keyword.get(:behaviour, []) + + if Plugin in b do + MapSet.put(acc, mod) + else + acc + end + end) + end + @doc """ If passed a text prefix, will match the start of the string. If passed a regex, it will match whatever was given and return the first match group. diff --git a/lib/stampede/interaction.ex b/lib/stampede/interaction.ex index f2ef86c..ff3b672 100644 --- a/lib/stampede/interaction.ex +++ b/lib/stampede/interaction.ex @@ -8,7 +8,7 @@ defmodule Stampede.Interaction do plugin: _ :: any(), msg: _ :: Msg, response: _ :: Response, - traceback: [] :: iodata() | String.t(), + traceback: [] :: TxtBlock.t(), channel_lock: false :: S.channel_lock_action() )