mirror of
https://codeberg.org/godmaire/sergei.git
synced 2024-09-19 15:58:26 +00:00
refactor: Move queue commands to queue.ex
This commit is contained in:
parent
d24e6530b7
commit
7243837cdb
2 changed files with 20 additions and 10 deletions
|
@ -11,19 +11,10 @@ defmodule Sergei.Commands do
|
|||
opt.(3, "url", "URL of the audio to play", [])
|
||||
]
|
||||
|
||||
@queue_add_opts [
|
||||
opt.(3, "url", "URL of the audio to queue", required: true)
|
||||
]
|
||||
|
||||
@queue_opts [
|
||||
opt.(1, "add", "Add a song to the queue", options: @queue_add_opts),
|
||||
opt.(1, "clear", "Clear the queue", [])
|
||||
]
|
||||
|
||||
@slash_commands [
|
||||
{"ping", "Pong", []},
|
||||
{"play", "Play a song or resume playback", @play_opts},
|
||||
{"queue", "Manage the song queue", @queue_opts},
|
||||
{"queue", "Manage the song queue", Sergei.Commands.Queue.subcommands()},
|
||||
{"pause", "Pause media playback", []},
|
||||
{"stop", "Stop media playback and leave the voice channel", []},
|
||||
{"song", "What song is currently playing?", []}
|
||||
|
|
|
@ -1,4 +1,23 @@
|
|||
defmodule Sergei.Commands.Queue do
|
||||
# Translate params to list of maps
|
||||
opt = fn type, name, desc, opts ->
|
||||
%{type: type, name: name, description: desc}
|
||||
|> Map.merge(Enum.into(opts, %{}))
|
||||
end
|
||||
|
||||
@queue_add_opts [
|
||||
opt.(3, "url", "URL of the audio to queue", required: true)
|
||||
]
|
||||
|
||||
@queue_commands [
|
||||
opt.(1, "add", "Add a song to the queue", options: @queue_add_opts),
|
||||
opt.(1, "clear", "Clear the queue", [])
|
||||
]
|
||||
|
||||
def subcommands() do
|
||||
@queue_commands
|
||||
end
|
||||
|
||||
@spec handle(integer(), String.t(), [%{name: String.t(), value: String.t()}]) ::
|
||||
{:ok, String.t()} | {:err, String.t()}
|
||||
def handle(guild_id, "add", opts) do
|
||||
|
|
Loading…
Reference in a new issue