diff --git a/lib/nosedrum/application_command.ex b/lib/nosedrum/application_command.ex index 35088eb..29f7cec 100644 --- a/lib/nosedrum/application_command.ex +++ b/lib/nosedrum/application_command.ex @@ -272,6 +272,18 @@ defmodule Nosedrum.ApplicationCommand do """ @callback options() :: [option] + @doc """ + An optional callback that returns a bitset for the required default permissions to run this command. + + Example callback that requires that the user has the permission to ban members to be able to see and execute this command + + ```elixir + def default_member_permissions, do: + Nostrum.Permission.to_bitset([:ban_members]) + ``` + """ + @callback default_member_permissions() :: string + @doc """ Execute the command invoked by the given `t:Nostrum.Struct.Interaction.t/0`. Returns a `t:response/0` @@ -292,5 +304,5 @@ defmodule Nosedrum.ApplicationCommand do """ @callback command(interaction :: Interaction.t()) :: response - @optional_callbacks [options: 0] + @optional_callbacks [options: 0, default_member_permissions: 0] end diff --git a/lib/nosedrum/storage/dispatcher.ex b/lib/nosedrum/storage/dispatcher.ex index 8fa57cc..16def7b 100644 --- a/lib/nosedrum/storage/dispatcher.ex +++ b/lib/nosedrum/storage/dispatcher.ex @@ -20,7 +20,8 @@ defmodule Nosedrum.Storage.Dispatcher do channel: 7, role: 8, mentionable: 9, - number: 10 + number: 10, + attachment: 11 } ## Api @@ -225,11 +226,17 @@ defmodule Nosedrum.Storage.Dispatcher do [] end - %{ + payload = %{ type: parse_type(command.type()), name: name } |> put_type_specific_fields(command, options) + + if function_exported?(command, :default_member_permissions, 0) do + Map.put(payload, :default_member_permissions, command.default_member_permissions()) + else + payload + end end # This seems like a hacky way to unwrap the outer list...