Pause Command

This commit is contained in:
GregTCLTK 2020-01-05 01:36:16 +01:00
parent 16f1dd8e5f
commit 78dfaa6f7b
2 changed files with 63 additions and 1 deletions

View file

@ -101,7 +101,8 @@ public class Hadder {
new EditRulesCommand(), new EditRulesCommand(),
new VolumeCommand(), new VolumeCommand(),
new StopCommand(), new StopCommand(),
new BlacklistCommand()), config, helpCommand); new BlacklistCommand(),
new PauseCommand()), config, helpCommand);
builder.addEventListeners( builder.addEventListeners(
new MentionListener(rethink), new MentionListener(rethink),

View file

@ -0,0 +1,61 @@
package com.bbn.hadder.commands.music;
/*
* @author Skidder / GregTCLTK
*/
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
public class PauseCommand implements Command {
@Override
public void executed(String[] args, CommandEvent event) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
if (!event.getAudioManager().getPlayer(event.getGuild()).isPaused()) {
event.getAudioManager().getPlayer(event.getGuild()).setPaused(true);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.pause.success.title",
"commands.music.pause.success.description")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.pause.error.paused.title",
"commands.music.pause.error.paused.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.pause.error.connected.title",
"commands.music.pause.error.connected.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title",
"commands.music.info.error.description").build()).queue();
}
}
@Override
public String[] labels() {
return new String[]{"pause"};
}
@Override
public String description() {
return "commands.music.pause.help.description";
}
@Override
public String usage() {
return null;
}
@Override
public String example() {
return null;
}
}