D++ (DPP)
C++ Discord API Bot Library
|
Represents an application command, created by your bot either globally, or on a guild. More...
Public Member Functions | |
slashcommand () | |
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... | |
slashcommand (const std::string &_name, const slashcommand_contextmenu_type _type, 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 & | set_dm_permission (bool dm) |
Set the dm permission for the command. More... | |
slashcommand & | set_nsfw (bool is_nsfw) |
Set whether the command should be age-restricted or not. More... | |
slashcommand & | set_default_permissions (uint64_t defaults) |
Set the default permissions of the slash command. More... | |
slashcommand & | add_option (const command_option &o) |
Add an option (parameter) More... | |
slashcommand & | set_type (slashcommand_contextmenu_type _type) |
Set the type of the slash command (only for context menu entries) More... | |
slashcommand & | set_name (const std::string &n) |
Set the name of the command. More... | |
slashcommand & | set_description (const std::string &d) |
Set the description of the command. More... | |
slashcommand & | set_application_id (snowflake i) |
Set the application id of the command. More... | |
slashcommand & | add_permission (const command_permission &p) |
Adds a permission to the command. 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... | |
std::string | get_mention () const |
Return a ping/mention for the slash command. More... | |
constexpr double | get_creation_time () const noexcept |
Get the creation time of this object according to Discord. 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 & | fill_from_json (nlohmann::json *j) |
Convert object from nlohmann::json. More... | |
auto | to_json (bool with_id=false) const |
Convert object to nlohmann::json. More... | |
std::string | build_json (bool with_id=false) const |
Convert object to json string. More... | |
Public Attributes | |
snowflake | application_id |
Application id (usually matches your bots id) More... | |
slashcommand_contextmenu_type | type |
Context menu type, defaults to dpp::ctxm_chat_input. More... | |
std::string | name |
Command name (1-32 chars) More... | |
std::string | description |
Command description (1-100 chars) More... | |
std::vector< command_option > | options |
Command options (parameters) More... | |
bool | 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. More... | |
std::vector< command_permission > | permissions |
command permissions More... | |
snowflake | version |
autoincrementing version identifier updated during substantial record changes More... | |
std::map< std::string, std::string > | name_localizations |
Localisations of command name. More... | |
std::map< std::string, std::string > | description_localizations |
Localisations of command description. More... | |
permission | default_member_permissions |
The default permissions of this command on a guild. D++ defaults this to dpp::p_use_application_commands. More... | |
bool | 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. More... | |
bool | nsfw |
Indicates whether the command is age-restricted. Defaults to false. More... | |
snowflake | id = {} |
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. 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.
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 |
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 |
|
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 |
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 |
Build a json for this object.
with_id | True if to include the ID in the JSON |
|
friend |
snowflake dpp::slashcommand::application_id |
Application id (usually matches your bots id)
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.
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.
std::string dpp::slashcommand::name |
Command name (1-32 chars)
std::map<std::string, std::string> dpp::slashcommand::name_localizations |
Localisations of command name.
bool dpp::slashcommand::nsfw |
Indicates whether the command is age-restricted. Defaults to false.
std::vector<command_option> dpp::slashcommand::options |
Command options (parameters)
std::vector<command_permission> dpp::slashcommand::permissions |
command permissions
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