#include <dpp/dpp.h>
#include <iomanip>
#include <sstream>
int main() {
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();
}
event.reply("You don't seem to be in a voice channel!");
return;
}
event.reply("Joined your channel!");
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.");
}
});
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:89
Represents a guild on Discord (AKA a server).
Definition guild.h:999
bool connect_member_voice(const cluster &owner, snowflake user_id, bool self_mute=false, bool self_deaf=false, bool dave=true)
Connect to a voice channel another guild member is in.
snowflake guild_id
Optional: the guild it was sent from.
Definition appcommand.h:1038
const dpp::user & get_issuing_user() const
Get the user who issued this command.
std::string get_command_name() const
Get the command name for a command interaction.
snowflake id
Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID,...
Definition managed.h:39
Represents an application command, created by your bot either globally, or on a guild.
Definition appcommand.h:1436
Represents a connection to a voice channel. A client can only connect to one voice channel per guild ...
Definition discordclient.h:152
constexpr const char v[]
Definition unicode_emoji.h:1982
std::function< void(const dpp::log_t &)> DPP_EXPORT cout_logger()
Get a default logger that outputs to std::cout. e.g.
auto run_once()
Run some code within an if() statement only once.
Definition once.h:41
DPP_EXPORT class guild * find_guild(snowflake id)
@ st_wait
Wait forever on a condition variable. The cluster will spawn threads for each shard and start() will ...
Definition cluster.h:72
dpp::cluster * owner
Cluster owning the event dispatch.
Definition dispatcher.h:102
interaction command
command interaction
Definition dispatcher.h:789
Session ready.
Definition dispatcher.h:1072
User has issued a slash command.
Definition dispatcher.h:806