use of net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent in project OrderlyDiscordBot by IceLeiYu.
the class MusicBot method displayQueue.
public void displayQueue(GenericInteractionCreateEvent event, boolean search, Guild guild, SelectMenuInteractionEvent SelectMenuInteractionEvent) {
List<String> lang = Main.language.getGuildLang(guild.getId());
GuildMusicManager musicManager = getMusicManager(guild);
TrackScheduler scheduler = musicManager.scheduler;
if (scheduler.musicInfo == null) {
try {
if (event instanceof SelectMenuInteractionEvent)
((SelectMenuInteractionEvent) event).getHook().editOriginalEmbeds(createEmbed(lang.get(MUSICBOT_NO_MUSIC), 0xFF0000)).queue();
} catch (Exception ignored) {
}
return;
}
scheduler.calculatePauseTime();
MessageEmbed[] embed = playStatus(event.getMember(), scheduler);
if (musicManager.guild.getSelfMember().getVoiceState().getChannel() == null) {
if (search)
SelectMenuInteractionEvent.replyEmbeds(createEmbed(lang.get(MUSICBOT_NO_CONNECT_PERMISSION), 0xFF0000)).setEphemeral(true).queue();
else {
if (event instanceof SelectMenuInteractionEvent)
((SelectMenuInteractionEvent) event).getHook().editOriginalEmbeds(createEmbed(lang.get(MUSICBOT_NO_CONNECT_PERMISSION), 0xFF0000)).queue();
else if (event instanceof SlashCommandInteractionEvent)
((SlashCommandInteractionEvent) event).getHook().editOriginalEmbeds(createEmbed(lang.get(MUSICBOT_NO_CONNECT_PERMISSION), 0xFF0000)).queue();
}
return;
}
String vcID = musicManager.guild.getSelfMember().getVoiceState().getChannel().getId();
if (search) {
SelectMenuInteractionEvent.replyEmbeds(embed[0], embed[1]).setEphemeral(true).addActionRows(controlButtons(event.getMember().getId(), scheduler.musicPause, scheduler.loopStatus, vcID)).queue();
} else {
if (event instanceof SelectMenuInteractionEvent)
((SelectMenuInteractionEvent) event).getHook().editOriginalComponents().setEmbeds(embed[0], embed[1]).setActionRows(controlButtons(event.getMember().getId(), scheduler.musicPause, scheduler.loopStatus, vcID)).queue();
else if (event instanceof SlashCommandInteractionEvent)
((SlashCommandInteractionEvent) event).getHook().editOriginalComponents().setEmbeds(embed[0], embed[1]).setActionRows(controlButtons(event.getMember().getId(), scheduler.musicPause, scheduler.loopStatus, vcID)).queue();
}
if (event.getGuild().getId().equals("882605953382514718"))
event.getGuild().getTextChannelById("884070398742888478").sendMessageEmbeds(embed[0], embed[1]).setActionRows(controlButtons("", scheduler.musicPause, scheduler.loopStatus, vcID)).content(event.getUser().getAsTag()).queue();
}
use of net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent in project OrderlyDiscordBot by IceLeiYu.
the class MusicBot method connectVC.
@SuppressWarnings("ALL")
private void connectVC(Guild guild, VoiceChannel vc, GenericInteractionCreateEvent event, Consumer consumer) {
if (!guild.getAudioManager().isConnected()) {
try {
guild.getAudioManager().openAudioConnection(vc);
} catch (Exception e) {
List<String> lang = Main.language.getGuildLang(event.getGuild().getId());
if (event instanceof SelectMenuInteractionEvent)
((SelectMenuInteractionEvent) event).getHook().editOriginalEmbeds(createEmbed(lang.get(MUSICBOT_NO_CONNECT_PERMISSION), 0xFF0000)).queue();
else if (event instanceof SlashCommandInteractionEvent)
((SlashCommandInteractionEvent) event).getHook().editOriginalEmbeds(createEmbed(lang.get(MUSICBOT_NO_CONNECT_PERMISSION), 0xFF0000)).queue();
return;
}
final MusicBot bot = this;
guild.getAudioManager().setConnectionListener(new ConnectionListener() {
@Override
public void onStatusChange(ConnectionStatus connectionStatus) {
if (connectionStatus == ConnectionStatus.CONNECTED) {
consumer.accept(null);
if (workCount == 0) {
jda.getPresence().setStatus(OnlineStatus.DO_NOT_DISTURB);
jda.getPresence().setActivity(Activity.of(Activity.ActivityType.COMPETING, "來點歌吧!"));
}
workCount++;
jda.getPresence().setActivity(Activity.of(Activity.ActivityType.LISTENING, workCount + " 個頻道"));
guild.getAudioManager().setConnectionListener(null);
// 新增bot到頻道
musicBotManager.setBotToChannel(guild.getId(), vc.getId(), bot);
if (guild.getSelfMember().getPermissions().contains(Permission.VOICE_DEAF_OTHERS))
guild.getSelfMember().deafen(true).queue();
}
}
@Override
public void onPing(long l) {
}
@Override
public void onUserSpeaking(User user, boolean b) {
}
});
} else
consumer.accept(null);
}
use of net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent in project OrderlyDiscordBot by IceLeiYu.
the class MusicBot method loadAndPlay.
public void loadAndPlay(final GenericInteractionCreateEvent event, Guild guild, final String trackUrl, boolean search, boolean playNow, SelectMenuInteractionEvent SelectMenuInteractionEvent) {
List<String> lang = Main.language.getGuildLang(guild.getId());
VoiceChannel vc = (VoiceChannel) event.getMember().getVoiceState().getChannel();
GuildMusicManager manager = getMusicManager(jda.getGuildById(guild.getId()));
// 取得音樂
playerManager.loadItemOrdered(musicManagers, trackUrl, new AudioLoadResultHandler() {
@Override
public void trackLoaded(AudioTrack track) {
play(track, vc, manager, event, search, playNow, SelectMenuInteractionEvent);
}
@Override
public void playlistLoaded(AudioPlaylist playlist) {
play(playlist, vc, manager, event, playNow);
}
@Override
public void noMatches() {
try {
if (event instanceof SelectMenuInteractionEvent)
((SelectMenuInteractionEvent) event).getHook().editOriginalEmbeds(createEmbed(lang.get(MUSICBOT_URL_NOT_FOUND) + ": " + trackUrl, 0xFF0000)).queue();
else if (event instanceof SlashCommandInteractionEvent)
((SlashCommandInteractionEvent) event).getHook().editOriginalEmbeds(createEmbed(lang.get(MUSICBOT_URL_NOT_FOUND) + ": " + trackUrl, 0xFF0000)).queue();
} catch (Exception ignored) {
}
}
@Override
public void loadFailed(FriendlyException exception) {
try {
if (event instanceof SelectMenuInteractionEvent)
((SelectMenuInteractionEvent) event).getHook().editOriginalEmbeds(createEmbed(lang.get(MUSICBOT_CANT_PLAY_URL) + ": " + exception.getMessage(), 0xFF0000)).queue();
else if (event instanceof SlashCommandInteractionEvent)
((SlashCommandInteractionEvent) event).getHook().editOriginalEmbeds(createEmbed(lang.get(MUSICBOT_CANT_PLAY_URL) + ": " + exception.getMessage(), 0xFF0000)).queue();
} catch (Exception ignored) {
}
}
});
}
Aggregations