DPP supports receiving audio. This example shows how to use it to record some user in a VC.
- Note
- Voice receiving by bots is not officially supported by the Discord API. We cannot guarantee that this feature will work in the future.
#include <iomanip>
#include <sstream>
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;
}