aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/thulani_bot/lib/thulani/bot/application.ex13
-rw-r--r--apps/thulani_bot/lib/thulani/bot/consumer.ex10
-rw-r--r--apps/thulani_bot/lib/thulani/bot/supervisor.ex17
-rw-r--r--apps/thulani_bot/mix.exs4
4 files changed, 34 insertions, 10 deletions
diff --git a/apps/thulani_bot/lib/thulani/bot/application.ex b/apps/thulani_bot/lib/thulani/bot/application.ex
index 7507eb8..cdbe2eb 100644
--- a/apps/thulani_bot/lib/thulani/bot/application.ex
+++ b/apps/thulani_bot/lib/thulani/bot/application.ex
@@ -1,19 +1,20 @@
defmodule Thulani.Bot.Application do
- alias Thulani.Bot.Config
use Application
+ alias Thulani.Bot.Config
+
@applications [
:nostrum
]
def start(_type, _args) do
Config.init!()
+ Enum.each(@applications, fn a -> {:ok, _} = Application.ensure_all_started(a) end)
- Enum.each(@applications, fn a -> Application.start(a) end)
-
- children = []
+ children = [
+ Thulani.Bot.Supervisor
+ ]
- opts = [strategy: :one_for_one, name: Thulani.Bot.Supervisor]
- Supervisor.start_link(children, opts)
+ Supervisor.start_link(children, strategy: :one_for_one)
end
end
diff --git a/apps/thulani_bot/lib/thulani/bot/consumer.ex b/apps/thulani_bot/lib/thulani/bot/consumer.ex
index f5deec6..5e43296 100644
--- a/apps/thulani_bot/lib/thulani/bot/consumer.ex
+++ b/apps/thulani_bot/lib/thulani/bot/consumer.ex
@@ -8,16 +8,20 @@ defmodule Thulani.Bot.Consumer do
Consumer.start_link(__MODULE__)
end
- def handle_event({:MESSAGE_CREATE, {msg}, ws_state}, state) do
- case msg.content do
+ def handle_event({:MESSAGE_CREATE, {msg}, _ws_state}, state) do
+ case IO.inspect(msg.content) do
"!thulani " <> command -> Logger.debug("got command", command: command)
_ -> :ignore
end
+ {:ok, _} = Api.create_message(msg.channel.id, "sup")
+
{:ok, state}
end
- def handle_event(_, state) do
+ def handle_event(msg, state) do
+ IO.inspect(msg)
+
{:ok, state}
end
end
diff --git a/apps/thulani_bot/lib/thulani/bot/supervisor.ex b/apps/thulani_bot/lib/thulani/bot/supervisor.ex
new file mode 100644
index 0000000..ac0e65b
--- /dev/null
+++ b/apps/thulani_bot/lib/thulani/bot/supervisor.ex
@@ -0,0 +1,17 @@
+defmodule Thulani.Bot.Supervisor do
+ @moduledoc false
+
+ use Supervisor
+
+ def start_link(arg) do
+ Supervisor.start_link(__MODULE__, arg, name: __MODULE__)
+ end
+
+ def init(_arg) do
+ children = [
+ {Thulani.Bot.Consumer, []}
+ ]
+
+ Supervisor.init(children, strategy: :one_for_one)
+ end
+end
diff --git a/apps/thulani_bot/mix.exs b/apps/thulani_bot/mix.exs
index 9d3b6ae..9338bb1 100644
--- a/apps/thulani_bot/mix.exs
+++ b/apps/thulani_bot/mix.exs
@@ -17,7 +17,9 @@ defmodule Thulani.Bot.MixProject do
def application do
[
- extra_applications: [:logger],
+ extra_applications: [
+ :logger
+ ],
mod: {Thulani.Bot.Application, []}
]
end