More error messages

This commit is contained in:
GregTCLTK 2020-01-04 14:39:02 +01:00
parent ba46d948cc
commit 7a09a2b1bc
No known key found for this signature in database
GPG key ID: A91BADE5C070FF67
5 changed files with 71 additions and 36 deletions

View file

@ -13,17 +13,24 @@ public class LeaveCommand implements Command {
@Override @Override
public void executed(String[] args, CommandEvent event) { public void executed(String[] args, CommandEvent event) {
if (event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) { if (event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) {
event.getGuild().getAudioManager().closeAudioConnection(); if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage( event.getGuild().getAudioManager().closeAudioConnection();
MessageEditor.MessageType.INFO, event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
"commands.music.leave.success.title", MessageEditor.MessageType.INFO,
"commands.music.leave.success.description") "commands.music.leave.success.title",
.build()).queue(); "commands.music.leave.success.description")
.build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.leave.error.channel.title",
"commands.music.leave.error.channel.description")
.build()).queue();
}
} else { } else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage( event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR, MessageEditor.MessageType.ERROR,
"commands.music.leave.error.tile", "commands.music.leave.error.connected.tile",
"commands.music.leave.error.description") "commands.music.leave.error.connected.description")
.build()).queue(); .build()).queue();
} }
} }

View file

@ -13,10 +13,16 @@ public class SkipCommand implements Command {
@Override @Override
public void executed(String[] args, CommandEvent event) { public void executed(String[] args, CommandEvent event) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && !event.getAudioManager().getTrackManager(event.getGuild()).getQueuedTracks().isEmpty()) { if (event.getAudioManager().hasPlayer(event.getGuild()) && !event.getAudioManager().getTrackManager(event.getGuild()).getQueuedTracks().isEmpty()) {
event.getAudioManager().forceSkipTrack(event); if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, event.getAudioManager().forceSkipTrack(event);
"commands.music.skip.success.title", event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.skip.success.description").build()).queue(); "commands.music.skip.success.title",
"commands.music.skip.success.description").build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.skip.error.connected.title",
"commands.music.skip.error.connected.description ").build()).queue();
}
} else { } else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title", "commands.music.info.error.title",

View file

@ -13,13 +13,20 @@ public class StopCommand implements Command {
@Override @Override
public void executed(String[] args, CommandEvent event) { public void executed(String[] args, CommandEvent event) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) { if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
event.getAudioManager().players.remove(event.getGuild().getId()); if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
event.getAudioManager().getPlayer(event.getGuild()).destroy(); event.getAudioManager().players.remove(event.getGuild().getId());
event.getAudioManager().getTrackManager(event.getGuild()).purgeQueue(); event.getAudioManager().getPlayer(event.getGuild()).destroy();
event.getGuild().getAudioManager().closeAudioConnection(); event.getAudioManager().getTrackManager(event.getGuild()).purgeQueue();
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, event.getGuild().getAudioManager().closeAudioConnection();
"commands.music.stop.success.title", event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.stop.success.description").build()).queue(); "commands.music.stop.success.title",
"commands.music.stop.success.description").build()).queue();
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.stop.error.connected.title",
"commands.music.stop.error.connected.description")
.build()).queue();
}
} else { } else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title", "commands.music.info.error.title",

View file

@ -14,22 +14,29 @@ public class VolumeCommand implements Command {
public void executed(String[] args, CommandEvent event) { public void executed(String[] args, CommandEvent event) {
if (args.length > 0) { if (args.length > 0) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) { if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
try { if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
int volume = Integer.parseInt(args[0]); try {
if (volume < 201 && volume > 0 || event.getConfig().getOwners().contains(event.getAuthor().getIdLong())) { int volume = Integer.parseInt(args[0]);
event.getAudioManager().getPlayer(event.getGuild()).setVolume(volume); if (volume < 201 && volume > 0 || event.getConfig().getOwners().contains(event.getAuthor().getIdLong())) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, event.getAudioManager().getPlayer(event.getGuild()).setVolume(volume);
"commands.music.volume.success.title", "", event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.volume.success.description", String.valueOf(volume)).build()).queue(); "commands.music.volume.success.title", "",
} else { "commands.music.volume.success.description", String.valueOf(volume)).build()).queue();
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, } else {
"commands.music.volume.error.int.title", event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.volume.error.int.description").build()).queue(); "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();
} }
} catch (NumberFormatException e) { } else {
event.getHelpCommand().sendHelp(this, event); event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
} catch (Exception e) { "commands.music.volume.error.connected.title",
e.printStackTrace(); "commands.volume.stop.error.connected.description")
.build()).queue();
} }
} else { } else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,

View file

@ -183,8 +183,10 @@ commands.music.join.error.permission.description = I am not allowed to join your
commands.music.join.help.description = Joins your voice channel. commands.music.join.help.description = Joins your voice channel.
commands.music.leave.success.title = Successfully disconnected commands.music.leave.success.title = Successfully disconnected
commands.music.leave.success.description = I successfully disconnected from the Voice Channel commands.music.leave.success.description = I successfully disconnected from the Voice Channel
commands.music.leave.error.tile = Not connected commands.music.leave.error.channel.title = No channel
commands.music.leave.error.description = I'm currently in no Voice Channel on this Guild commands.music.leave.error.channel.description = You have to be in the same voice channel as the bot.
commands.music.leave.error.connected.tile = Not connected
commands.music.leave.error.connected.description = I'm currently in no Voice Channel on this Guild
commands.music.leave.help.description = Leaves your voice channel. commands.music.leave.help.description = Leaves your voice channel.
commands.music.play.load.title = %extra% Now loading %extra% commands.music.play.load.title = %extra% Now loading %extra%
commands.music.play.load.description = Trying to load the song... commands.music.play.load.description = Trying to load the song...
@ -200,6 +202,8 @@ commands.music.play.error.match.description = I can not find a song named this o
commands.music.play.help.description = Plays the specified song. commands.music.play.help.description = Plays the specified song.
commands.music.stop.success.title = Successfully stopped commands.music.stop.success.title = Successfully stopped
commands.music.stop.success.description = I successfully stopped the song. commands.music.stop.success.description = I successfully stopped the song.
commands.music.stop.error.connected.title = No channel
commands.music.stop.error.connected.description = You have to be in the same voice channel as the bot to stop the song.
commands.music.stop.help.description = Stops the song. commands.music.stop.help.description = Stops the song.
commands.music.info.success.title = Track info commands.music.info.success.title = Track info
commands.music.info.error.title = No playing track commands.music.info.error.title = No playing track
@ -212,11 +216,15 @@ commands.music.queue.success.description = This is the queue\: \n %extra%
commands.music.queue.help.description = Shows the music queue. commands.music.queue.help.description = Shows the music queue.
commands.music.skip.success.title = Successfully skipped commands.music.skip.success.title = Successfully skipped
commands.music.skip.success.description = I successfully skipped to the next song commands.music.skip.success.description = I successfully skipped to the next song
commands.music.skip.error.connected.title = No channel
commands.music.skip.error.connected.description = You have to be in the same voice channel as the bot to skip the song.
commands.music.skip.help.description = Skips the currently playing song. commands.music.skip.help.description = Skips the currently playing song.
commands.music.volume.success.title = Successfully set commands.music.volume.success.title = Successfully set
commands.music.volume.success.description = I successfully set the new volume to %extra% 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.title = Invalid number
commands.music.volume.error.int.description = The volume have to be between 1 and 200 commands.music.volume.error.int.description = The volume have to be between 1 and 200
commands.music.volume.error.connected.title = No channel
commands.music.volume.error.connected.description = You have to be in the same voice channel as the bot to change the volume.
commands.music.volume.help.description = Change the volume of the music. commands.music.volume.help.description = Change the volume of the music.
commands.nsfw.gif.error.title = GIF not showing? Click here commands.nsfw.gif.error.title = GIF not showing? Click here