Represents an application command, created by your bot either globally, or on a guild. More...
#include "appcommand.h"
Public Member Functions | |
slashcommand () | |
Construct a new slashcommand object. More... | |
slashcommand (const std::string &_name, const slashcommand_contextmenu_type _type, const dpp::snowflake _application_id) | |
Construct a new slashcommand object. More... | |
slashcommand (const std::string &_name, const std::string &_description, const dpp::snowflake _application_id) | |
Construct a new slashcommand object. More... | |
virtual | ~slashcommand ()=default |
Destroy the slashcommand object. More... | |
slashcommand & | add_localization (const std::string &language, const std::string &_name, const std::string &_description="") |
Add a localisation for this slash command. More... | |
slashcommand & | add_option (const command_option &o) |
Add an option (parameter) More... | |
slashcommand & | add_permission (const command_permission &p) |
Adds a permission to the command. More... | |
std::string | build_json (bool with_id=false) const |
Convert object to json string. More... | |
slashcommand & | disable_default_permissions () |
Disable default permissions, command will be unusable unless permissions are overridden with add_permission and dpp::guild_command_edit_permissions. More... | |
slashcommand & | fill_from_json (nlohmann::json *j) |
Convert object from nlohmann::json. More... | |
constexpr double | get_creation_time () const noexcept |
Get the creation time of this object according to Discord. More... | |
std::string | get_mention () const |
Return a ping/mention for the slash command. More... | |
constexpr bool | operator!= (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
constexpr bool | operator== (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
slashcommand & | set_application_id (snowflake i) |
Set the application id of the command. More... | |
slashcommand & | set_default_permissions (uint64_t defaults) |
Set the default permissions of the slash command. More... | |
slashcommand & | set_description (const std::string &d) |
Set the description of the command. More... | |
slashcommand & | set_dm_permission (bool dm) |
Set the dm permission for the command. More... | |
slashcommand & | set_name (const std::string &n) |
Set the name of the command. More... | |
slashcommand & | set_nsfw (bool is_nsfw) |
Set whether the command should be age-restricted or not. More... | |
slashcommand & | set_type (slashcommand_contextmenu_type _type) |
Set the type of the slash command (only for context menu entries) More... | |
auto | to_json (bool with_id=false) const |
Convert object to nlohmann::json. More... | |
Public Attributes | |
snowflake | application_id |
Application id (usually matches your bots id) More... | |
permission | default_member_permissions |
The default permissions of this command on a guild. More... | |
bool | default_permission |
Whether the command is enabled by default when the app is added to a guild. More... | |
std::string | description |
Command description (1-100 chars) More... | |
std::map< std::string, std::string > | description_localizations |
Localisations of command description. More... | |
bool | dm_permission |
True if this command should be allowed in a DM D++ defaults this to false. More... | |
snowflake | id = {} |
Unique ID of object set by Discord. More... | |
std::string | name |
Command name (1-32 chars) More... | |
std::map< std::string, std::string > | name_localizations |
Localisations of command name. More... | |
bool | nsfw |
Indicates whether the command is age-restricted. More... | |
std::vector< command_option > | options |
Command options (parameters) More... | |
std::vector< command_permission > | permissions |
command permissions More... | |
slashcommand_contextmenu_type | type |
Context menu type, defaults to dpp::ctxm_chat_input. More... | |
snowflake | version |
autoincrementing version identifier updated during substantial record changes More... | |
Protected Member Functions | |
slashcommand & | fill_from_json_impl (nlohmann::json *j) |
Fill object properties from JSON. More... | |
json | to_json_impl (bool with_id=false) const |
Build a json for this object. More... | |
Friends | |
struct | json_interface< slashcommand > |
Represents an application command, created by your bot either globally, or on a guild.
dpp::slashcommand::slashcommand | ( | ) |
Construct a new slashcommand object.
References nsfw.
dpp::slashcommand::slashcommand | ( | const std::string & | _name, |
const std::string & | _description, | ||
const dpp::snowflake | _application_id | ||
) |
Construct a new slashcommand object.
_name | Command name |
_description | Command description |
_application_id | Application id (usually the bot's user id) |
dpp::slashcommand::slashcommand | ( | const std::string & | _name, |
const slashcommand_contextmenu_type | _type, | ||
const dpp::snowflake | _application_id | ||
) |
Construct a new slashcommand object.
_name | Command name |
_type | Context menu type |
_application_id | Application id (usually the bot's user id) |
|
virtualdefault |
Destroy the slashcommand object.
slashcommand & dpp::slashcommand::add_localization | ( | const std::string & | language, |
const std::string & | _name, | ||
const std::string & | _description = "" |
||
) |
Add a localisation for this slash command.
language | Name of language, see the list of locales linked to above |
_name | name of slash command in the specified language |
_description | description of slash command in the specified language (optional) |
slashcommand & dpp::slashcommand::add_option | ( | const command_option & | o | ) |
Add an option (parameter)
o | option (parameter) to add |
Referenced by dpp::commandhandler::add_command().
slashcommand & dpp::slashcommand::add_permission | ( | const command_permission & | p | ) |
Adds a permission to the command.
p | permission to add |
|
inlineinherited |
Convert object to json string.
with_id | Whether to include the ID or not |
slashcommand & dpp::slashcommand::disable_default_permissions | ( | ) |
Disable default permissions, command will be unusable unless permissions are overridden with add_permission and dpp::guild_command_edit_permissions.
|
inlineinherited |
Convert object from nlohmann::json.
j | nlohmann::json object |
|
protected |
Fill object properties from JSON.
j | JSON to fill from |
References dpp::command_option_choice::value.
|
inlineconstexprnoexceptinherited |
Get the creation time of this object according to Discord.
std::string dpp::slashcommand::get_mention | ( | ) | const |
Return a ping/mention for the slash command.
</airhorn:816437322781949972>
|
inlineconstexprnoexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
|
inlineconstexprnoexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
slashcommand & dpp::slashcommand::set_application_id | ( | snowflake | i | ) |
Set the application id of the command.
i | application id |
References dpp::command_option_choice::name, dpp::string_not_null(), and dpp::command_option_choice::value.
slashcommand & dpp::slashcommand::set_default_permissions | ( | uint64_t | defaults | ) |
Set the default permissions of the slash command.
defaults | default permissions to set. This is a permission bitmask of bits from dpp::permissions |
slashcommand & dpp::slashcommand::set_description | ( | const std::string & | d | ) |
Set the description of the command.
d | description |
slashcommand & dpp::slashcommand::set_dm_permission | ( | bool | dm | ) |
Set the dm permission for the command.
dm | true to allow this command in dms |
slashcommand & dpp::slashcommand::set_name | ( | const std::string & | n | ) |
Set the name of the command.
n | name of command |
slashcommand & dpp::slashcommand::set_nsfw | ( | bool | is_nsfw | ) |
Set whether the command should be age-restricted or not.
is_nsfw | true if the command should be age-restricted |
slashcommand & dpp::slashcommand::set_type | ( | slashcommand_contextmenu_type | _type | ) |
Set the type of the slash command (only for context menu entries)
_type | Type of context menu entry this command represents |
|
inlineinherited |
Convert object to nlohmann::json.
with_id | Whether to include the ID or not |
|
protected |
Build a json for this object.
with_id | True if to include the ID in the JSON |
References dpp::lowercase(), name, and dpp::utility::utf8substr().
|
friend |
snowflake dpp::slashcommand::application_id |
Application id (usually matches your bots id)
Referenced by dpp::cluster::guild_command_create(), and dpp::cluster::guild_command_edit_permissions().
permission dpp::slashcommand::default_member_permissions |
The default permissions of this command on a guild.
D++ defaults this to dpp::p_use_application_commands.
bool dpp::slashcommand::default_permission |
Whether the command is enabled by default when the app is added to a guild.
This has no effect as the default_member_permissions value is used instead.
std::string dpp::slashcommand::description |
Command description (1-100 chars)
std::map<std::string, std::string> dpp::slashcommand::description_localizations |
Localisations of command description.
Referenced by dpp::interaction::get_command_name().
bool dpp::slashcommand::dm_permission |
True if this command should be allowed in a DM D++ defaults this to false.
Cannot be set to true in a guild command, only a global command.
|
inherited |
Unique ID of object set by Discord.
This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata.
Referenced by dpp::poll::add_answer(), dpp::cluster::create_webhook(), dpp::cluster::current_user_join_thread(), dpp::invite::fill_from_json_impl(), dpp::command_permission::fill_from_json_impl(), dpp::interaction::get_resolved_role(), dpp::interaction::get_resolved_user(), dpp::cluster::global_bulk_command_create(), dpp::cluster::global_bulk_command_delete(), dpp::cluster::global_command_delete(), dpp::cluster::global_command_edit(), dpp::cluster::guild_ban_delete(), dpp::cluster::guild_command_create(), dpp::cluster::guild_command_edit_permissions(), dpp::cluster::guild_get_integrations(), dpp::events::guild_member_update::handle(), dpp::events::guild_role_create::handle(), dpp::events::channel_create::handle(), dpp::events::voice_state_update::handle(), dpp::discord_voice_client::handle_frame(), main(), dpp::component::set_disabled(), and dpp::select_option::set_label().
std::string dpp::slashcommand::name |
Command name (1-32 chars)
Referenced by dpp::interaction::get_channel(), and to_json_impl().
std::map<std::string, std::string> dpp::slashcommand::name_localizations |
Localisations of command name.
Referenced by dpp::interaction::get_command_name().
bool dpp::slashcommand::nsfw |
std::vector<command_option> dpp::slashcommand::options |
Command options (parameters)
std::vector<command_permission> dpp::slashcommand::permissions |
command permissions
Referenced by dpp::cluster::guild_command_create().
slashcommand_contextmenu_type dpp::slashcommand::type |
Context menu type, defaults to dpp::ctxm_chat_input.
snowflake dpp::slashcommand::version |
autoincrementing version identifier updated during substantial record changes