DPP supports receiving audio. This examples show how to use it to record some user in a VC.
#include <dpp/dpp.h>
#include <iomanip>
#include <sstream>
int main(int argc, char const *argv[])
{
FILE *fd;
fd = fopen("./me.pcm", "wb");
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, now recording!");
event.from->disconnect_voice(event.command.guild_id);
fclose(fd);
event.reply("Stopped recording.");
}
});
fwrite((char *)event.audio, 1, event.audio_size, fd);
}
});
if (dpp::run_once<struct register_bot_commands>()) {
dpp::slashcommand recordcommand(
"record",
"Joins your voice channel and records you.", bot.me.id);
bot.global_bulk_command_create({recordcommand, stopcommand});
}
});
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
A container for a 64 bit unsigned value representing many things on discord. This value is known in d...
Definition: snowflake.h:49
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:643
Session ready.
Definition: dispatcher.h:898
User has issued a slash command.
Definition: dispatcher.h:660
voice receive packet
Definition: dispatcher.h:1787
snowflake user_id
User ID of speaker (zero if unknown)
Definition: dispatcher.h:1844