use of com.ice.multiBot.music.TrackScheduler 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 com.ice.multiBot.music.TrackScheduler in project OrderlyDiscordBot by IceLeiYu.
the class MultiMusicBotManager method onButton.
public void onButton(ButtonInteractionEvent event, String[] args) {
List<String> lang = Main.language.getGuildLang(event.getGuild().getId());
if (!args[0].equals("MusicBot"))
return;
if (!checkVcState(event, event.getHook()))
return;
if (!event.getMember().getVoiceState().getChannel().getId().equals(args[4])) {
event.deferEdit().setEmbeds(createEmbed(lang.get(MUSICBOT_MG_UNKNOWN_CHANNEL_BUTTON), 0xFF0000)).setActionRows().queue();
return;
}
MusicBot bot = bots.get(args[3]);
GuildMusicManager manager = bot.getMusicManager(event.getGuild().getId());
TrackScheduler scheduler = manager.scheduler;
int volume;
switch(args[1]) {
case "loopChange":
{
switch(scheduler.loopStatus = (scheduler.loopStatus + 1) % 3) {
case 0:
scheduler.repeat = false;
scheduler.loop = false;
break;
case 1:
scheduler.repeat = false;
scheduler.loop = true;
break;
case 2:
scheduler.repeat = true;
scheduler.loop = false;
break;
default:
return;
}
break;
}
case "pauseToggle":
scheduler.switchPause();
break;
case "next":
scheduler.nextTrack(null, false);
break;
case "volumeUp":
volume = scheduler.getVolume() + 5;
scheduler.setVolume(Math.min(volume, 100), null);
break;
case "volumeDown":
volume = scheduler.getVolume() - 5;
scheduler.setVolume(Math.max(volume, 0), null);
break;
default:
}
// 如果是等待的話要加時間
scheduler.calculatePauseTime();
GuildMusicManager musicManager = bot.getMusicManager(event.getGuild().getId());
VoiceChannel vc = (VoiceChannel) musicManager.guild.getSelfMember().getVoiceState().getChannel();
if (vc == null) {
event.editMessageEmbeds(createEmbed(0xFF0000, lang.get(MUSICBOT_MG_NO_BOT_IN_CHANNEL))).setActionRows().queue();
commandState = -1;
} else {
MessageEmbed[] embed = bot.playStatus(event.getMember(), scheduler);
event.editMessageEmbeds(embed[0], embed[1]).setActionRows(bot.controlButtons(args[2], scheduler.musicPause, scheduler.loopStatus, vc.getId())).queue();
}
}
Aggregations