use of net.dv8tion.jda.api.managers.AudioManager in project Vinny by kikkia.
the class Bot method checkVoiceLobby.
private void checkVoiceLobby(GuildVoiceUpdateEvent event) {
Guild guild = event.getEntity().getGuild();
VoiceSendHandler handler = getHandler(guild);
AudioManager manager = guild.getAudioManager();
// if there are no humans left, then leave
int users = 0;
for (Member member : manager.getConnectedChannel().getMembers()) {
if (!member.getUser().isBot())
users++;
}
if (manager.isConnected() && users < 1) {
handler.stop();
manager.closeAudioConnection();
}
}
use of net.dv8tion.jda.api.managers.AudioManager in project Tux by Bakterio.
the class JoinCommand method invoke.
@Override
public void invoke(GuildMessageReceivedEvent e, String[] args) {
final GuildVoiceState voiceState = e.getGuild().getSelfMember().getVoiceState();
final GuildVoiceState memberVoiceState = e.getMember().getVoiceState();
if (voiceState.inVoiceChannel()) {
e.getChannel().sendMessage("I am already in " + voiceState.getChannel().getName() + " channel.").queue();
return;
}
if (!memberVoiceState.inVoiceChannel()) {
e.getChannel().sendMessage("You have to be in voice channel to invoke this command...").queue();
return;
}
final AudioManager audioManager = e.getGuild().getAudioManager();
audioManager.openAudioConnection(memberVoiceState.getChannel());
e.getChannel().sendMessage("I am in!!!").queue();
}
use of net.dv8tion.jda.api.managers.AudioManager in project Tux by Bakterio.
the class LeaveCommand method invoke.
@Override
public void invoke(GuildMessageReceivedEvent e, String[] args) {
final GuildVoiceState voiceState = e.getGuild().getSelfMember().getVoiceState();
if (!voiceState.inVoiceChannel()) {
e.getChannel().sendMessage("I can't leave, I am not in any voice channel!!!").queue();
return;
}
final AudioManager audioManager = e.getGuild().getAudioManager();
// TODO why tf is this not working?
audioManager.closeAudioConnection();
e.getChannel().sendMessage("See you around... :wink:").queue();
}
use of net.dv8tion.jda.api.managers.AudioManager in project clancy by brendonmiranda.
the class JoinCmd method command.
@Override
public void command(SlashCommandEvent event) {
VoiceChannel memberVoiceChannel = getChannel(event);
Guild guild = getGuild(event);
AudioManager audioManager = getAudioManager(guild);
audioManager.openAudioConnection(memberVoiceChannel);
event.replyEmbeds(MessageUtil.buildMessage("What's up!")).queue();
}
use of net.dv8tion.jda.api.managers.AudioManager in project clancy by brendonmiranda.
the class PlayCmd method command.
@Override
public void command(SlashCommandEvent event) {
OptionMapping option = event.getOption(MUSIC_ARG);
String args = option.getAsString();
logger.debug("PlayCmd loading track: {}", args);
AudioPlayer audioPlayer = audioPlayerManager.createPlayer();
audioPlayer.addListener(audioEventListener);
Consumer<Message> success = (message) -> {
Guild guild = event.getGuild();
AudioManager audioManager = guild.getAudioManager();
PlayResultHandler playResultHandler = new PlayResultHandler(audioPlayer, guild, audioManager, event, audioPlayerManager, eventWaiter, message, false, audioQueueService);
audioPlayerManager.loadItemOrdered(event.getGuild(), args, playResultHandler);
};
event.replyEmbeds(MessageUtil.buildMessage("Searching...")).queue(interactionHook -> {
interactionHook.retrieveOriginal().queue(success);
});
}
Aggregations