use of io.github.aquerr.futrzakbot.audio.handler.AudioPlayerSendHandler in project FutrzakBot by Aquerr.
the class PlayCommand method execute.
@Override
public boolean execute(Member member, TextChannel textChannel, List<String> args) {
Guild guild = textChannel.getGuild();
GuildVoiceState guildVoiceState = member.getVoiceState();
VoiceChannel voiceChannel = guildVoiceState.getChannel();
if (voiceChannel == null) {
textChannel.sendMessage("Aby użyć tej komendy musisz być na kanale głosowym!").complete();
} else {
AudioManager audioManager = guild.getAudioManager();
if (audioManager.getSendingHandler() == null) {
audioManager.setSendingHandler(new AudioPlayerSendHandler(this.futrzakAudioPlayerManager.getOrCreateAudioPlayer(guild.getIdLong()).getInternalAudioPlayer()));
}
audioManager.openAudioConnection(voiceChannel);
String songName = args.get(0);
this.futrzakAudioPlayerManager.queue(guild.getIdLong(), textChannel, songName);
}
return true;
}
use of io.github.aquerr.futrzakbot.audio.handler.AudioPlayerSendHandler in project FutrzakBot by Aquerr.
the class SlashCommandListener method onSlashCommand.
@Override
public void onSlashCommand(SlashCommandEvent event) {
if (event.getName().equals("player")) {
if (event.getOption("song") != null) {
GuildVoiceState guildVoiceState = event.getMember().getVoiceState();
VoiceChannel voiceChannel = guildVoiceState.getChannel();
if (voiceChannel == null) {
event.reply("Aby użyć tej komendy musisz być na kanale głosowym!").queue();
}
Guild guild = event.getGuild();
AudioManager audioManager = guild.getAudioManager();
audioManager.setSendingHandler(new AudioPlayerSendHandler(this.futrzakAudioPlayerManager.getOrCreateAudioPlayer(guild.getIdLong()).getInternalAudioPlayer()));
audioManager.openAudioConnection(voiceChannel);
this.futrzakAudioPlayerManager.queue(event.getGuild().getIdLong(), event.getTextChannel(), event.getOption("song").getAsString());
}
event.reply("Futrzak Song Player").addActionRow(// Button with only a label
Button.primary("queue", "View Song Queue"), // Button with only an emoji
Button.success("next", ":track_next:")).queue();
}
}
Aggregations