28 lines
739 B
Elixir
28 lines
739 B
Elixir
defmodule Mithridate.Option.SubCommand do
|
|
alias Mithridate.Option
|
|
alias Nostrum.Constants.ApplicationCommandOptionType
|
|
|
|
@behaviour Option
|
|
|
|
@impl Option
|
|
def parse(_value, _interaction), do: nil
|
|
|
|
@impl Option
|
|
def new(name, description, options) do
|
|
%Option{
|
|
name: name,
|
|
description: description,
|
|
type: ApplicationCommandOptionType.sub_command(),
|
|
options: Keyword.get(options, :options),
|
|
kind: __MODULE__
|
|
}
|
|
end
|
|
|
|
@impl Option
|
|
def to_discord(%Option{} = option) do
|
|
option
|
|
|> Map.take([:name, :description, :type, :options])
|
|
|> Map.replace_lazy(:name, &Atom.to_string/1)
|
|
|> Map.replace_lazy(:options, fn children -> Enum.map(children, &Option.to_discord/1) end)
|
|
end
|
|
end
|