Skip to content

Commit

Permalink
find_all_plugins() for listing actual plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
ProducerMatt committed Mar 11, 2024
1 parent 1b54ae0 commit e24342f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/service/discord.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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 ",
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 16 additions & 1 deletion lib/stampede.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/stampede/interaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)

Expand Down

0 comments on commit e24342f

Please sign in to comment.