Replace control with filtering

This commit is contained in:
Roman 2023-06-06 17:01:17 -04:00
parent b8e7c0f87b
commit a8551a2ba7

View file

@ -24,10 +24,10 @@ defmodule Sergei.Player do
@impl true @impl true
def handle_info(:tick, state) do def handle_info(:tick, state) do
state state
|> Enum.each(fn {guild_id, %{url: url, paused: paused}} = _state -> |> Enum.filter(fn {_id, %{paused: paused} = _state} -> not paused end)
if not Voice.playing?(guild_id) and not paused do |> Enum.filter(fn {guild_id, _data} -> not Voice.playing?(guild_id) end)
Voice.play(guild_id, url, :ytdl) |> Enum.each(fn {guild_id, %{url: url}} = _state ->
end Voice.play(guild_id, url, :ytdl)
end) end)
Process.send_after(self(), :tick, 100) Process.send_after(self(), :tick, 100)