use of net.dv8tion.jda.api.managers.AudioManager in project clancy by brendonmiranda.
the class MusicCmd method execute.
@Override
protected void execute(SlashCommandEvent event) {
AudioManager audioManager = getAudioManager(event.getGuild());
VoiceChannel memberVoiceChannel = getChannel(event);
/*
* To execute any music command the bot needs to be in a voice channel. It
* validates this. A voice channel is reached by the bot through the Join command.
*/
if (audioManager.getConnectedChannel() == null) {
event.replyEmbeds(MessageUtil.buildMessage("Type `/join`")).queue();
return;
}
/*
* It validates if the member who trigger the event is present in a voice channel.
*/
if (memberVoiceChannel == null) {
event.replyEmbeds(MessageUtil.buildMessage("You must be in a voice channel.")).queue();
return;
}
command(event);
}
use of net.dv8tion.jda.api.managers.AudioManager in project Emolga by TecToast.
the class StartClippingCommand method process.
@Override
public void process(GuildCommandEvent e) {
AudioManager am = e.getGuild().getAudioManager();
am.openAudioConnection(e.getMember().getVoiceState().getChannel());
clips.put(e.getGuild().getIdLong(), new CircularFifoQueue<>(1500));
am.setReceivingHandler(new AudioReceiveHandler() {
@Override
public boolean canReceiveCombined() {
return true;
}
@Override
public boolean canReceiveUser() {
return false;
}
@Override
public void handleCombinedAudio(@NotNull CombinedAudio audio) {
clips.get(e.getGuild().getIdLong()).add(audio.getAudioData(1.0));
}
@Override
public boolean includeUserInCombinedAudio(@NotNull User user) {
return true;
}
});
e.reply("Sehr interessant was ihr so redet \uD83D\uDC40");
}
use of net.dv8tion.jda.api.managers.AudioManager in project Papilertus by Handschrift.
the class SkipCommand method execute.
@Override
protected void execute(SlashCommandEvent slashCommandEvent) {
if (slashCommandEvent.getGuild() == null) {
slashCommandEvent.reply("You can only execute this command in a server").setEphemeral(true).queue();
return;
}
final AudioManager manager = slashCommandEvent.getGuild().getAudioManager();
final Member executor = slashCommandEvent.getMember();
if (!executor.getVoiceState().inVoiceChannel() || !executor.getVoiceState().getChannel().getId().equals(manager.getConnectedChannel().getId())) {
// Check if member is NOT in the same channel
slashCommandEvent.reply("You have to be in the same voice channel!").setEphemeral(true).queue();
return;
}
final EmbedBuilder builder = new EmbedBuilder();
final GuildMusicManager guildManager = getGuildAudioPlayer(slashCommandEvent.getGuild());
guildManager.getScheduler().nextTrack();
builder.setDescription("Skipped to the next track");
slashCommandEvent.replyEmbeds(builder.build()).queue();
}
use of net.dv8tion.jda.api.managers.AudioManager 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 net.dv8tion.jda.api.managers.AudioManager 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