diff --git a/lib/service/discord.ex b/lib/service/discord.ex index d8528cc..fc45006 100644 --- a/lib/service/discord.ex +++ b/lib/service/discord.ex @@ -1,6 +1,7 @@ defmodule Service.Discord do alias Stampede, as: S alias S.{Msg} + alias Nostrum.Api require Msg use TypeCheck use Supervisor, restart: :permanent @@ -40,7 +41,7 @@ defmodule Service.Discord do @impl Service def at_bot?(_cfg, msg) do - Nostrum.Api.get_channel_message(msg.channel_id, msg.referenced_msg_id) + Api.get_channel_message(msg.channel_id, msg.referenced_msg_id) |> case do {:ok, service_msg} -> bot_id?(service_msg.author.id) @@ -88,7 +89,7 @@ defmodule Service.Discord do end def do_send_msg(channel_id, msg, try \\ 0) do - case Nostrum.Api.create_message( + case Api.create_message( channel_id, content: msg ) do @@ -135,7 +136,7 @@ defmodule Service.Discord do [ "Message from ", - msg.author_id |> Nostrum.Api.get_user!() |> Nostrum.Struct.User.full_name() |> inspect(), + msg.author_id |> Api.get_user!() |> Nostrum.Struct.User.full_name() |> inspect(), " lead to ", error_type, " in plugin ", @@ -223,7 +224,7 @@ defmodule Service.Discord do @spec! get_msg({discord_channel_id(), discord_msg_id()}) :: {:ok, Msg.t()} | {:error, any()} def get_msg({channel_id, msg_id}) do - case Nostrum.Api.get_channel_message(channel_id, msg_id) do + case Api.get_channel_message(channel_id, msg_id) do {:ok, discord_msg} -> {:ok, into_msg(discord_msg)} @@ -259,7 +260,6 @@ defmodule Service.Discord.Handler do alias Stampede, as: S alias S.{Response, Msg} require Msg - alias Nostrum.Api alias Service.Discord @typep! vips :: S.CfgTable.vips() diff --git a/test/stampede_stateless_test.exs b/test/stampede_stateless_test.exs index 7fb95c5..74f0ae6 100644 --- a/test/stampede_stateless_test.exs +++ b/test/stampede_stateless_test.exs @@ -3,7 +3,6 @@ defmodule StampedeStatelessTest do import ExUnit.CaptureLog alias Stampede, as: S require S.Msg - alias Service.Dummy, as: D doctest Stampede @dummy_cfg """ diff --git a/test/stampede_test.exs b/test/stampede_test.exs index 7ffc88c..99cca00 100644 --- a/test/stampede_test.exs +++ b/test/stampede_test.exs @@ -22,7 +22,10 @@ defmodule StampedeTest do server_id: :testing, error_channel_id: :error, prefix: "!", - plugs: MapSet.new([Plugin.Test, Plugin.Sentience, Plugin.Why]) + plugs: MapSet.new([Plugin.Test, Plugin.Sentience, Plugin.Why]), + dm_handler: false, + filename: :"test SiteConfig load_all", + vip_ids: MapSet.new([:server]) } setup_all do %{ @@ -199,20 +202,15 @@ defmodule StampedeTest do test "load_all", s do ids = Atom.to_string(s.id) - this_cfg = - @dummy_cfg - |> String.replace("server_id: testing", "server_id: foobar") - Path.join([s.tmp_dir, ids <> ".yml"]) - |> File.write!(this_cfg) + |> File.write!(@dummy_cfg) newtable = SiteConfig.load_all(s.tmp_dir) |> Map.fetch!(Service.Dummy) - |> Map.fetch!(:foobar) + |> Map.fetch!(:testing) - assert "!" == newtable.prefix - assert :foobar == newtable.server_id + assert newtable == @dummy_cfg_verified end end