D++ (DPP)
C++ Discord API Bot Library
dpp::commandhandler Class Reference

The commandhandler class represents a group of commands, prefixed or slash commands with handling functions. More...

#include <commandhandler.h>

Public Member Functions

 commandhandler ()
 
 ~commandhandler ()
 
commandhandleradd_prefix (const std::string &prefix)
 Add a prefix to the command handler. More...
 
commandhandleradd_command (const std::string &command, command_handler handler)
 Add a command to the command handler. More...
 
void route (const class dpp::message &msg)
 Route a command from the on_message_create function. Call this method from within your on_message_create with the received dpp::message object. More...
 
void route (const class dpp::command_interaction &cmd)
 Route a command from the on_interaction_create function. Call this method from yuor on_interaction_create with the recieved dpp::command_interaction object. More...
 
void reply (const dpp::message &m)
 Reply to a message. You should use this method rather than cluster::message_create as the way you reply varies between slash commands and message commands. More...
 

Detailed Description

The commandhandler class represents a group of commands, prefixed or slash commands with handling functions.

Constructor & Destructor Documentation

◆ commandhandler()

dpp::commandhandler::commandhandler ( )

Constructor

◆ ~commandhandler()

dpp::commandhandler::~commandhandler ( )

Destructor

Member Function Documentation

◆ add_command()

commandhandler & dpp::commandhandler::add_command ( const std::string &  command,
command_handler  handler 
)

Add a command to the command handler.

Parameters
commandCommand to be handled. Note that if any one of your prefixes is "/" this will attempt to register a global command using the API and you will receive notification of this command via an interaction event.
handlerHandler function
Returns
commandhandler& reference to self

◆ add_prefix()

commandhandler & dpp::commandhandler::add_prefix ( const std::string &  prefix)

Add a prefix to the command handler.

Parameters
prefixPrefix to be handled by the command handler
Returns
commandhandler& reference to self

◆ reply()

void dpp::commandhandler::reply ( const dpp::message m)

Reply to a message. You should use this method rather than cluster::message_create as the way you reply varies between slash commands and message commands.

Parameters
mmessage to reply with.

◆ route() [1/2]

void dpp::commandhandler::route ( const class dpp::command_interaction cmd)

Route a command from the on_interaction_create function. Call this method from yuor on_interaction_create with the recieved dpp::command_interaction object.

Parameters
cmdcommand interaction to parse

◆ route() [2/2]

void dpp::commandhandler::route ( const class dpp::message msg)

Route a command from the on_message_create function. Call this method from within your on_message_create with the received dpp::message object.

Parameters
msgmessage to parse
D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0