By default D++ does not cache messages. The example program below demonstrates how to instantiate a custom cache using dpp::cache which will allow you to cache messages and query the cache for messages by ID.
#include <dpp/dpp.h>
#include <sstream>
int main() {
});
if (!find_msg) {
event.reply("There is no message cached with this ID");
return;
}
event.reply(
"This message had the following content: " + find_msg->
content);
}
});
if (dpp::run_once<struct register_bot_commands>()) {
dpp::slashcommand newcommand(
"get",
"Get the contents of a message that was cached via an id", bot.me.id);
bot.global_command_create(newcommand);
}
});
return 0;
}
A cache object maintains a cache of dpp::managed objects.
Definition: cache.h:50
void store(T *object)
Store an object in the cache. Passing a nullptr will have no effect.
Definition: cache.h:101
T * find(snowflake id)
Find an object in the cache by id.
Definition: cache.h:154
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:80
std::string get_command_name() const
Get the command name for a command interaction.
Represents an application command, created by your bot either globally, or on a guild.
Definition: appcommand.h:1342
constexpr const char m[]
Definition: unicode_emoji.h:5304
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ i_message_content
Intent for receipt of message content.
Definition: intents.h:112
@ i_default_intents
Default D++ intents (all non-privileged intents).
Definition: intents.h:132
@ co_string
A string value.
Definition: appcommand.h:64
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:63
Each command option is a command line parameter. It can have a type (see dpp::command_option_type),...
Definition: appcommand.h:203
interaction command
command interaction
Definition: dispatcher.h:678
virtual command_value get_parameter(const std::string &name) const
Get a slashcommand parameter.
Create message.
Definition: dispatcher.h:1635
Represents messages sent and received on Discord.
Definition: message.h:2016
std::string content
Contents of the message.
Definition: message.h:2061
Session ready.
Definition: dispatcher.h:961
User has issued a slash command.
Definition: dispatcher.h:695