Move commands to their own files

This commit is contained in:
Loïc Bersier 2024-10-12 17:05:40 +02:00
parent ed8b78385c
commit 779f99a5f3
2 changed files with 23 additions and 16 deletions

View file

@ -1,24 +1,10 @@
defmodule HahaCommands do defmodule HahaYes.Commands.Download do
@moduledoc """ @moduledoc """
Contain all the function for each commands Contain all the function for each commands
""" """
alias Nostrum.Api 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 """ @doc """
Download the video sent by the user at 480p max. Download the video sent by the user at 480p max.
@ -36,7 +22,7 @@ defmodule HahaCommands do
Bot: <video file> Bot: <video file>
""" """
def download(msg) do def execute(msg) do
arg = String.replace(msg.content, "h3h3 download ", "") 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"]; 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"];

21
lib/HahaCommands/ping.ex Normal file
View file

@ -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