#include <dpp/dpp.h>
#include <iomanip>
#include <sstream>
int main(int argc, char const *argv[])
{
uint8_t*
robot =
nullptr;
size_t robot_size = 0;
std::ifstream input ("../testdata/Robot.pcm", std::ios::in|std::ios::binary|std::ios::ate);
if (input.is_open()) {
robot_size = input.tellg();
robot =
new uint8_t[robot_size];
input.seekg (0, std::ios::beg);
input.read ((char*)robot, robot_size);
input.close();
}
dpp::guild* g = dpp::find_guild(event.command.guild_id);
if (!g->connect_member_voice(event.command.get_issuing_user().id)) {
event.reply("You don't seem to be in a voice channel!");
return;
}
event.
reply(
"Joined your channel!");
dpp::voiceconn* v = event.from->get_voice(event.channel.guild_id);
if (!v || !v->voiceclient || !v->voiceclient->is_ready()) {
event.reply("There was an issue with getting the voice channel. Make sure I'm in a voice channel!");
return;
}
v->voiceclient->send_audio_raw((uint16_t*)robot, robot_size);
event.
reply(
"Played robot.");
}
});
if (dpp::run_once<struct register_bot_commands>()) {
dpp::slashcommand robotcommand(
"robot",
"Plays a robot noise in your voice channel.", bot.me.id);
bot.global_bulk_command_create({joincommand, robotcommand});
}
});
return 0;
}
The cluster class represents a group of shards and a command queue for sending and receiving commands...
Definition: cluster.h:82
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:999
constexpr const char robot[]
Definition: unicode_emoji.h:1652
constexpr const char v[]
Definition: unicode_emoji.h:1835
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition: cluster.h:65
void reply(command_completion_event_t callback=utility::log_error()) const
Acknowledge interaction without displaying a message to the user, for use with button and select menu...
interaction command
command interaction
Definition: dispatcher.h:585
Session ready.
Definition: dispatcher.h:877
User has issued a slash command.
Definition: dispatcher.h:607