Closed ghost closed 2 years ago
Voice states have user IDs, or at least it should.
onServer
gives you voice states, use server.voiceStates
, this should tell you who on each voice channel and their voice state.
I did some testing and this should work without needing to join a voice channel
void onServer(SleepyDiscord::Server server) override {
if (server.ID == "202917641101246465") {
std::cout << "Targeted Server Found\n";
for (SleepyDiscord::VoiceState& voiceState : server.voiceStates) {
std::cout << "Voice State:\n"
"UserID: " << voiceState.userID.string() << "\n"
"ChannelID: " << voiceState.channelID.string() << '\n';
}
}
}
Mind you, it's important that you have the Intents set up correctly and your bot has the SleepyDiscord::Intent::SERVERS
intent set up.
client.setIntents(SleepyDiscord::Intent::SERVERS);
More info on using intents with this library here https://yourwaifu.dev/sleepy-discord/docs/connect-options#intents
Please understand that this library isn't designed like other Discord libraries. This library is more minimal in that it does only what's needed for your bot to keep ram and CPU usage low.
Other than that, you can keep track of the number of users in a voice channel via voice states.
and
server.voiceStates
only available duringonServer
event with these, you can keep track of the users that are in the voice channel by updating the count as users join and leave voice channels.