diff --git a/src/main/java/com/bbn/hadder/Hadder.java b/src/main/java/com/bbn/hadder/Hadder.java index 4169459..d98da1a 100644 --- a/src/main/java/com/bbn/hadder/Hadder.java +++ b/src/main/java/com/bbn/hadder/Hadder.java @@ -97,6 +97,7 @@ public class Hadder { new InfoCommand(), new SkipCommand(), new EditRulesCommand(), + new VolumeCommand(), new StopCommand()), config, helpCommand); builder.addEventListeners( diff --git a/src/main/java/com/bbn/hadder/commands/music/VolumeCommand.java b/src/main/java/com/bbn/hadder/commands/music/VolumeCommand.java new file mode 100644 index 0000000..b0391b9 --- /dev/null +++ b/src/main/java/com/bbn/hadder/commands/music/VolumeCommand.java @@ -0,0 +1,61 @@ +package com.bbn.hadder.commands.music; + +import com.bbn.hadder.commands.Command; +import com.bbn.hadder.commands.CommandEvent; +import com.bbn.hadder.utils.MessageEditor; + +/** + * @author Skidder / GregTCLTK + */ + +public class VolumeCommand implements Command { + + @Override + public void executed(String[] args, CommandEvent event) { + if (args.length > 0) { + if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) { + try { + int volume = Integer.parseInt(args[0]); + if (volume < 200 && volume > 0 || event.getConfig().getOwners().contains(event.getAuthor().getId())) { + event.getAudioManager().getPlayer(event.getGuild()).setVolume(volume); + event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, + "commands.music.volume.success.title", "", + "commands.music.volume.success.description", String.valueOf(volume)).build()).queue(); + } else { + event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, + "commands.music.volume.error.int.title", + "commands.music.volume.error.int.description").build()).queue(); + } + } catch (NumberFormatException e) { + event.getHelpCommand().sendHelp(this, event); + } catch (Exception e) { + e.printStackTrace(); + } + } else { + event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, + "commands.music.info.error.title", + "commands.music.info.error.description").build()).queue(); + } + } else event.getHelpCommand().sendHelp(this, event); + } + + @Override + public String[] labels() { + return new String[]{"volume"}; + } + + @Override + public String description() { + return "Change the volume of the music."; + } + + @Override + public String usage() { + return "[New volume]"; + } + + @Override + public String example() { + return "100"; + } +} diff --git a/src/main/resources/Translations/Translations_en.properties b/src/main/resources/Translations/Translations_en.properties index f958c88..c46cbe0 100644 --- a/src/main/resources/Translations/Translations_en.properties +++ b/src/main/resources/Translations/Translations_en.properties @@ -4,20 +4,6 @@ Hadder = Hadder -user = <@User> -searchterm = -username = -number = /all -prefix = -userprefix = -vc-name/id = -user+nickname = <@user> -region = -guildid = -content = -song = -user/id= [@User]/[ID] - error = Error none = None success\! = Success\! @@ -221,6 +207,10 @@ commands.music.queue.help.description = Shows the music queue commands.music.skip.success.title = Successfully skipped commands.music.skip.success.description = I successfully skipped to the next song commands.music.skip.help.description = Skips the currently playing song +commands.music.volume.success.title = Successfully set +commands.music.volume.success.description = I successfully set the new volume to %extra% +commands.music.volume.error.int.title = Invalid number +commands.music.volume.error.int.description = The volume have to be between 1 and 200 commands.nsfw.gif.error.title = GIF not showing? Click here commands.nsfw.img.error.title = Image not showing? Click here