From 779f99a5f3afaa7ce3bea7bc1ed9d506e32456d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Bersier?= <loic.bersier1@gmail.com>
Date: Sat, 12 Oct 2024 17:05:40 +0200
Subject: [PATCH] Move commands to their own files

---
 lib/{commands.ex => HahaCommands/download.ex} | 18 ++--------------
 lib/HahaCommands/ping.ex                      | 21 +++++++++++++++++++
 2 files changed, 23 insertions(+), 16 deletions(-)
 rename lib/{commands.ex => HahaCommands/download.ex} (79%)
 create mode 100644 lib/HahaCommands/ping.ex

diff --git a/lib/commands.ex b/lib/HahaCommands/download.ex
similarity index 79%
rename from lib/commands.ex
rename to lib/HahaCommands/download.ex
index 3d0c317..931fca9 100644
--- a/lib/commands.ex
+++ b/lib/HahaCommands/download.ex
@@ -1,24 +1,10 @@
-defmodule HahaCommands do
+defmodule HahaYes.Commands.Download do
   @moduledoc """
   Contain all the function for each commands
   """
 
   alias Nostrum.Api
 
-  @doc """
-  Reply with a simple "Pong!"
-
-  ## Example
-
-    User: h3h3 ping
-
-    Bot: Pong!
-  """
-
-  def ping(msg) do
-    Api.create_message(msg.channel_id, "Pong!")
-  end
-
   @doc """
   Download the video sent by the user at 480p max.
 
@@ -36,7 +22,7 @@ defmodule HahaCommands do
 
     Bot: <video file>
   """
-  def download(msg) do
+  def execute(msg) do
     arg = String.replace(msg.content, "h3h3 download ", "")
     opt = ["-f", "bestvideo[height<=?480]+bestaudio/best", arg, "-o", "#{System.tmp_dir}/test.mp4", "--force-overwrites", "--playlist-reverse", "--no-playlist", "--remux-video=mp4/webm/mov", "--no-warnings"];
 
diff --git a/lib/HahaCommands/ping.ex b/lib/HahaCommands/ping.ex
new file mode 100644
index 0000000..4809552
--- /dev/null
+++ b/lib/HahaCommands/ping.ex
@@ -0,0 +1,21 @@
+defmodule HahaYes.Commands.Ping do
+  @moduledoc """
+  Contain all the function for each commands
+  """
+
+  alias Nostrum.Api
+
+  @doc """
+  Reply with a simple "Pong!"
+
+  ## Example
+
+    User: h3h3 ping
+
+    Bot: Pong!
+  """
+
+  def execute(msg) do
+    Api.create_message(msg.channel_id, "Pong!")
+  end
+end