Skip to content

Commit

Permalink
Fix: blind test destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
papey committed Jan 26, 2022
1 parent f7029d5 commit 27d5e22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lib/blindtest/blindtest.ex
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,10 @@ defmodule BlindTest do
@doc """
Destroy the current blind test process
"""
def destroy() do
guild_id = O2M.Application.from_env_to_int(:o2m, :guild)

def destroy(guild_id) do
Nostrum.Voice.leave_channel(guild_id)

# leave the channel
# kill game process and downloader
case process() do
{:one, pid} -> Process.exit(pid, :kill)
_ -> nil
Expand Down
9 changes: 7 additions & 2 deletions lib/commands/blindtest.ex
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,14 @@ defmodule O2M.Commands.Bt do

with {:one, _} <- BlindTest.process(),
:member <- is_member(msg.author, adm, guild_id),
{:ok, _} <- BlindTest.check_channel_id(msg.channel_id) do
BlindTest.destroy()
{:ok, _} <- BlindTest.check_channel_id(msg.channel_id),
downloarder_pid <- Process.whereis(Downloader.Worker) do
# kill downloader is any
if downloarder_pid, do: Process.exit(downloarder_pid, :kill)
# clean cache
Cache.clean()
# kill running BT process
BlindTest.destroy(guild_id)

Nostrum.Api.create_message(
msg.channel_id,
Expand Down

0 comments on commit 27d5e22

Please sign in to comment.