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
public void executed(String[] args, CommandEvent event) {
if (event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) {
event.getGuild().getAudioManager().closeAudioConnection();
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.music.leave.success.title",
"commands.music.leave.success.description")
.build()).queue();
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
event.getGuild().getAudioManager().closeAudioConnection();
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.music.leave.success.title",
"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 {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.music.leave.error.tile",
"commands.music.leave.error.description")
"commands.music.leave.error.connected.tile",
"commands.music.leave.error.connected.description")
.build()).queue();
}
}

View file

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

View file

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

View file

@ -14,22 +14,29 @@ public class VolumeCommand implements Command {
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 < 201 && volume > 0 || event.getConfig().getOwners().contains(event.getAuthor().getIdLong())) {
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();
if (event.getMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().inVoiceChannel() && event.getGuild().getSelfMember().getVoiceState().getChannel().equals(event.getMember().getVoiceState().getChannel())) {
try {
int volume = Integer.parseInt(args[0]);
if (volume < 201 && volume > 0 || event.getConfig().getOwners().contains(event.getAuthor().getIdLong())) {
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();
}
} 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.volume.error.connected.title",
"commands.volume.stop.error.connected.description")
.build()).queue();
}
} else {
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.leave.success.title = Successfully disconnected
commands.music.leave.success.description = I successfully disconnected from the Voice Channel
commands.music.leave.error.tile = Not connected
commands.music.leave.error.description = I'm currently in no Voice Channel on this Guild
commands.music.leave.error.channel.title = No channel
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.play.load.title = %extra% Now loading %extra%
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.stop.success.title = Successfully stopped
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.info.success.title = Track info
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.skip.success.title = Successfully skipped
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.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.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.nsfw.gif.error.title = GIF not showing? Click here