Nostrum.Api.ApplicationCommand (nostrum v0.11.0-dev)
View SourceModule for interacting with Discord's application commands.
See: https://discord.com/developers/docs/interactions/application-commands
Summary
Functions
Edits command permissions for a specific command for your application in a guild. You can only add up to 10 permission overwrites for a command.
Overwrite the existing global application commands.
Overwrite the existing guild application commands on the specified guild.
Create a new global application command.
Create a guild application command on the specified guild.
Delete an existing global application command.
Delete an existing guild application command.
Edits command permissions for a specific command for your application in a guild. You can only add up to 10 permission overwrites for a command.
Update an existing global application command.
Update an existing guild application command.
Fetch all global commands.
Fetch all guild application commands for the given guild.
Fetches command permissions for all commands for your application in a guild.
Fetches command permissions for a specific command for your application in a guild.
Functions
@spec batch_edit_permissions(Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id(), [ %{ id: Nostrum.Snowflake.t(), permissions: [ Nostrum.Struct.ApplicationCommand.application_command_permissions() ] } ]) :: {:ok, map()} | Nostrum.Api.error()
Edits command permissions for a specific command for your application in a guild. You can only add up to 10 permission overwrites for a command.
Parameters
application_id
: Application ID commands are registered under. If not given, this will be fetched fromMe
.guild_id
: Guild ID to fetch command permissions from.command_id
: Command ID to fetch permissions for.permissions
: List of partial guild application command permissions withid
andpermissions
. You can add up to 10 overwrites per command.
Return value
This method returns a guild application command permission object, see all available values on the Discord API docs.
@spec bulk_overwrite_global_commands(Nostrum.Struct.User.id(), [ Nostrum.Struct.ApplicationCommand.application_command_map() ]) :: {:ok, [map()]} | Nostrum.Api.error()
Overwrite the existing global application commands.
This action will:
- Create any command that was provided and did not already exist
- Update any command that was provided and already existed if its configuration changed
- Delete any command that was not provided but existed on Discord's end
Updates will be available in all guilds after 1 hour. Commands that do not already exist will count toward daily application command create limits.
Parameters
application_id
: Application ID for which to overwrite the commands. If not given, this will be fetched fromMe
.commands
: List of command configurations, see the linked API documentation for reference.
Return value
Updated list of global application commands. See the official reference: https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands
@spec bulk_overwrite_guild_commands( Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id(), [ Nostrum.Struct.ApplicationCommand.application_command_map() ] ) :: {:ok, [map()]} | Nostrum.Api.error()
Overwrite the existing guild application commands on the specified guild.
This action will:
- Create any command that was provided and did not already exist
- Update any command that was provided and already existed if its configuration changed
- Delete any command that was not provided but existed on Discord's end
Parameters
application_id
: Application ID for which to overwrite the commands. If not given, this will be fetched fromMe
.guild_id
: Guild on which to overwrite the commands.commands
: List of command configurations, see the linked API documentation for reference.
Return value
Updated list of guild application commands. See the official reference: https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
@spec create_global_command( Nostrum.Struct.User.id(), Nostrum.Struct.ApplicationCommand.application_command_map() ) :: {:ok, map()} | Nostrum.Api.error()
Create a new global application command.
The new command will be available on all guilds in around an hour.
If you want to test commands, use create_guild_command/2
instead,
as commands will become available instantly there.
If an existing command with the same name exists, it will be overwritten.
Parameters
application_id
: Application ID for which to create the command. If not given, this will be fetched fromMe
.command
: Command configuration, see the linked API documentation for reference.
Return value
The created command. See the official reference: https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
Example
Nostrum.Api.ApplicationCommand.create_global_command(
%{name: "edit", description: "ed, man! man, ed", options: []}
)
@spec create_guild_command( Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id(), Nostrum.Struct.ApplicationCommand.application_command_map() ) :: {:ok, map()} | Nostrum.Api.error()
Create a guild application command on the specified guild.
The new command will be available immediately.
Parameters
application_id
: Application ID for which to create the command. If not given, this will be fetched fromMe
.guild_id
: Guild on which to create the command.command
: Command configuration, see the linked API documentation for reference.
Return value
The created command. See the official reference: https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
@spec delete_global_command(Nostrum.Struct.User.id(), Nostrum.Snowflake.t()) :: {:ok} | Nostrum.Api.error()
Delete an existing global application command.
Parameters
application_id
: Application ID for which to create the command. If not given, this will be fetched fromMe
.command_id
: The current snowflake of the command.
@spec delete_guild_command( Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id(), Nostrum.Snowflake.t() ) :: {:ok} | Nostrum.Api.error()
Delete an existing guild application command.
Parameters
application_id
: Application ID for which to create the command. If not given, this will be fetched fromMe
.guild_id
: The guild on which the command exists.command_id
: The current snowflake of the command.
@spec edit_command_permissions( Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id(), Nostrum.Snowflake.t(), [Nostrum.Struct.ApplicationCommand.application_command_permissions()] ) :: {:ok, map()} | Nostrum.Api.error()
Edits command permissions for a specific command for your application in a guild. You can only add up to 10 permission overwrites for a command.
Parameters
application_id
: Application ID commands are registered under. If not given, this will be fetched fromMe
.guild_id
: Guild ID to fetch command permissions from.command_id
: Command ID to fetch permissions for.permissions
: List of application command permissions
Return value
This method returns a guild application command permission object, see all available values on the Discord API docs.
@spec edit_global_command( Nostrum.Struct.User.id(), Nostrum.Snowflake.t(), Nostrum.Struct.ApplicationCommand.application_command_edit_map() ) :: {:ok, map()} | Nostrum.Api.error()
Update an existing global application command.
The updated command will be available on all guilds in around an hour.
Parameters
application_id
: Application ID for which to edit the command. If not given, this will be fetched fromMe
.command_id
: The current snowflake of the command.command
: Command configuration, see the linked API documentation for reference.
Return value
The updated command. See the official reference: https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
@spec edit_guild_command( Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id(), Nostrum.Snowflake.t(), Nostrum.Struct.ApplicationCommand.application_command_edit_map() ) :: {:ok, map()} | Nostrum.Api.error()
Update an existing guild application command.
The updated command will be available immediately.
Parameters
application_id
: Application ID for which to edit the command. If not given, this will be fetched fromMe
.guild_id
: Guild for which to update the command.command_id
: The current snowflake of the command.command
: Command configuration, see the linked API documentation for reference.
Return value
The updated command. See the official reference: https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
@spec global_commands(Nostrum.Struct.User.id()) :: {:ok, [map()]} | Nostrum.Api.error()
Fetch all global commands.
Parameters
application_id
: Application ID for which to search commands. If not given, this will be fetched fromMe
.
Return value
A list of ApplicationCommand
s on success. See the official reference:
https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure
Example
iex> Nostrum.Api.global_commands
{:ok,
[
%{
application_id: "455589479713865749",
description: "ed, man! man, ed",
id: "789841753196331029",
name: "edit"
}
]}
@spec guild_commands(Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id()) :: {:ok, [map()]} | Nostrum.Api.error()
Fetch all guild application commands for the given guild.
Parameters
application_id
: Application ID for which to fetch commands. If not given, this will be fetched fromMe
.guild_id
: The guild ID for which guild application commands should be requested.
Return value
A list of ApplicationCommand
s on success. See the official reference:
https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure
@spec guild_permissions(Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id()) :: {:ok, [map()]} | Nostrum.Api.error()
Fetches command permissions for all commands for your application in a guild.
Parameters
application_id
: Application ID commands are registered under. If not given, this will be fetched fromMe
.guild_id
: Guild ID to fetch command permissions from.
Return value
This method returns a list of guild application command permission objects, see all available values on the Discord API docs.
@spec permissions( Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id(), Nostrum.Snowflake.t() ) :: {:ok, map()} | Nostrum.Api.error()
Fetches command permissions for a specific command for your application in a guild.
Parameters
application_id
: Application ID commands are registered under. If not given, this will be fetched fromMe
.guild_id
: Guild ID to fetch command permissions from.command_id
: Command ID to fetch permissions for.
Return value
This method returns a single guild application command permission object, see all available values on the Discord API docs.