use of net.kodehawa.mantarobot.commands.music.GuildMusicManager in project MantaroBot by Mantaro.
the class MusicCmds method queue.
@Command
public static void queue(CommandRegistry cr) {
cr.register("queue", new SimpleCommand(Category.MUSIC) {
@Override
protected void call(GuildMessageReceivedEvent event, String content, String[] args) {
GuildMusicManager musicManager = MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild());
int page = 0;
try {
page = Math.max(Integer.parseInt(args[0]), 1);
} catch (Exception ignored) {
}
if (content.startsWith("clear")) {
if (!event.getMember().getVoiceState().inVoiceChannel() || !event.getMember().getVoiceState().getChannel().equals(event.getGuild().getAudioManager().getConnectedChannel())) {
sendNotConnectedToMyChannel(event.getChannel());
return;
}
if (isDJ(event.getMember())) {
event.getChannel().sendMessage(EmoteReference.CORRECT + "The server DJ has decided to clear the queue!").queue();
int TEMP_QUEUE_LENGTH = musicManager.getTrackScheduler().getQueue().size();
MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild()).getTrackScheduler().getQueue().clear();
event.getChannel().sendMessage(EmoteReference.CORRECT + "Removed **" + TEMP_QUEUE_LENGTH + " songs** from the queue" + ".").queue();
MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild()).getTrackScheduler().next(true);
return;
}
event.getChannel().sendMessage(EmoteReference.ERROR + "Either you're not connected to the VC or you're not the DJ.").queue();
return;
}
embedForQueue(page, event, musicManager);
TextChannelGround.of(event).dropItemWithChance(0, 10);
}
@Override
public MessageEmbed help(GuildMessageReceivedEvent event) {
return helpEmbed(event, "Queue Command").setDescription("**Either returns the current queue playing on the server or clears it.**").addField("Usage:", "`~>queue` - **Shows the queue**\n" + "`~>queue clear` - **Clears the queue**", false).build();
}
});
cr.registerAlias("queue", "q");
}
use of net.kodehawa.mantarobot.commands.music.GuildMusicManager in project MantaroBot by Mantaro.
the class MusicCmds method repeat.
@Command
public static void repeat(CommandRegistry cr) {
cr.register("repeat", new SimpleCommand(Category.MUSIC) {
@Override
protected void call(GuildMessageReceivedEvent event, String content, String[] args) {
if (!event.getMember().getVoiceState().inVoiceChannel() || !event.getMember().getVoiceState().getChannel().equals(event.getGuild().getAudioManager().getConnectedChannel())) {
sendNotConnectedToMyChannel(event.getChannel());
return;
}
GuildMusicManager musicManager = MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild());
try {
switch(args[0].toLowerCase()) {
case "queue":
if (musicManager.getTrackScheduler().getRepeat() == Repeat.QUEUE) {
musicManager.getTrackScheduler().setRepeat(null);
event.getChannel().sendMessage(EmoteReference.CORRECT + "Continuing with the current queue.").queue();
} else {
musicManager.getTrackScheduler().setRepeat(Repeat.QUEUE);
event.getChannel().sendMessage(EmoteReference.CORRECT + "Repeating the current queue.").queue();
}
break;
}
} catch (Exception e) {
if (musicManager.getTrackScheduler().getRepeat() == Repeat.SONG) {
musicManager.getTrackScheduler().setRepeat(null);
event.getChannel().sendMessage(EmoteReference.CORRECT + "Continuing with the normal queue.").queue();
} else {
musicManager.getTrackScheduler().setRepeat(Repeat.SONG);
event.getChannel().sendMessage(EmoteReference.CORRECT + "Repeating the current song.").queue();
}
}
TextChannelGround.of(event).dropItemWithChance(0, 10);
}
@Override
public MessageEmbed help(GuildMessageReceivedEvent event) {
return helpEmbed(event, "Repeat command").setDescription("**Repeats a song.**").addField("Usage", "`~>repeat` - **Toggles repeat**\n" + "`~>repeat queue` - **Repeats the entire queue**.", false).addField("Warning", "Might not work correctly if I leave the voice channel after you have disabled repeat. *To fix, just " + "add a song to the queue*", true).build();
}
});
}
use of net.kodehawa.mantarobot.commands.music.GuildMusicManager in project MantaroBot by Mantaro.
the class MusicCmds method stop.
private static void stop(GuildMessageReceivedEvent event) {
GuildMusicManager musicManager = MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild());
if (musicManager.getTrackScheduler().getAudioPlayer().getPlayingTrack() != null && !musicManager.getTrackScheduler().getAudioPlayer().isPaused())
musicManager.getTrackScheduler().getAudioPlayer().getPlayingTrack().stop();
int TEMP_QUEUE_LENGTH = musicManager.getTrackScheduler().getQueue().size();
MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild()).getTrackScheduler().getQueue().clear();
if (TEMP_QUEUE_LENGTH > 0) {
//else we just don't show this, why shall we?
event.getChannel().sendMessage(EmoteReference.OK + "Removed **" + TEMP_QUEUE_LENGTH + " songs** from the queue.").queue();
}
MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild()).getTrackScheduler().next(true);
event.getGuild().getAudioManager().closeAudioConnection();
}
use of net.kodehawa.mantarobot.commands.music.GuildMusicManager in project MantaroBot by Mantaro.
the class VoiceLeave method run.
@Override
public void run() {
MantaroBot.getInstance().getAudioManager().getMusicManagers().forEach((guildId, manager) -> {
try {
Guild guild = MantaroBot.getInstance().getGuildById(guildId);
if (guild == null)
return;
GuildVoiceState voiceState = guild.getSelfMember().getVoiceState();
if (voiceState == null)
return;
if (voiceState.inVoiceChannel()) {
TextChannel channel = guild.getPublicChannel();
if (channel != null) {
if (channel.canTalk()) {
VoiceChannel voiceChannel = voiceState.getChannel();
AudioPlayer player = manager.getAudioPlayer();
GuildMusicManager mm = MantaroBot.getInstance().getAudioManager().getMusicManager(guild);
if (player == null || mm == null || voiceChannel == null)
return;
if (mm.getTrackScheduler().getCurrentTrack().getRequestedChannel() != null) {
channel = mm.getTrackScheduler().getCurrentTrack().getRequestedChannel();
}
if (voiceState.isGuildMuted()) {
channel.sendMessage(EmoteReference.SAD + "Pausing player because I got muted :(").queue();
player.setPaused(true);
}
if (voiceChannel.getMembers().size() == 1) {
channel.sendMessage(EmoteReference.THINKING + "I decided to leave **" + voiceChannel.getName() + "** " + "because I was left all " + "alone :<").queue();
if (mm.getTrackScheduler().getAudioPlayer().getPlayingTrack() != null) {
mm.getTrackScheduler().getAudioPlayer().getPlayingTrack().stop();
mm.getTrackScheduler().getQueue().clear();
mm.getTrackScheduler().next(true);
} else {
guild.getAudioManager().closeAudioConnection();
}
}
}
}
}
} catch (Exception ignored) {
}
});
}
Aggregations