use of net.dv8tion.jda.internal.managers.AudioManagerImpl in project JDA by DV8FromTheWorld.
the class AudioWebSocket method locked.
private void locked(Consumer<AudioManagerImpl> consumer) {
AudioManagerImpl manager = (AudioManagerImpl) guild.getAudioManager();
MiscUtil.locked(manager.CONNECTION_LOCK, () -> consumer.accept(manager));
}
use of net.dv8tion.jda.internal.managers.AudioManagerImpl in project JDA by DV8FromTheWorld.
the class GuildImpl method getAudioManager.
@Nonnull
@Override
public AudioManager getAudioManager() {
if (!getJDA().isIntent(GatewayIntent.GUILD_VOICE_STATES))
throw new IllegalStateException("Cannot use audio features with disabled GUILD_VOICE_STATES intent!");
final AbstractCacheView<AudioManager> managerMap = getJDA().getAudioManagersView();
AudioManager mng = managerMap.get(id);
if (mng == null) {
// No previous manager found -> create one
try (UnlockHook hook = managerMap.writeLock()) {
GuildImpl cachedGuild = (GuildImpl) getJDA().getGuildById(id);
if (cachedGuild == null)
throw new IllegalStateException("Cannot get an AudioManager instance on an uncached Guild");
mng = managerMap.get(id);
if (mng == null) {
mng = new AudioManagerImpl(cachedGuild);
managerMap.getMap().put(id, mng);
}
}
}
return mng;
}
Aggregations