Perm error msg

This commit is contained in:
GregTCLTK 2020-01-04 13:58:55 +01:00
parent b5f4ed98fa
commit ba46d948cc
No known key found for this signature in database
GPG key ID: A91BADE5C070FF67
3 changed files with 34 additions and 15 deletions

View file

@ -11,6 +11,7 @@ import com.bbn.hadder.commands.settings.*;
import com.bbn.hadder.commands.music.*;
import com.bbn.hadder.core.*;
import com.bbn.hadder.listener.*;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder;
import net.dv8tion.jda.api.sharding.ShardManager;
@ -39,6 +40,7 @@ public class Hadder {
builder.setAutoReconnect(true);
builder.setShardsTotal(1);
builder.setActivity(Activity.streaming("on the BigBotNetwork", "https://twitch.tv/BigBotNetwork"));
builder.setStatus(OnlineStatus.DO_NOT_DISTURB);
builder.setToken(config.getBotToken());
HelpCommand helpCommand = new HelpCommand();

View file

@ -4,6 +4,7 @@ import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.entities.VoiceChannel;
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import net.dv8tion.jda.api.managers.AudioManager;
/*
@ -20,15 +21,22 @@ public class JoinCommand implements Command {
VoiceChannel vc = event.getMember().getVoiceState().getChannel();
if (event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) {
if (!event.getGuild().getSelfMember().getVoiceState().getChannel().getId().equals(vc.getId())) {
event.getGuild().getAudioManager().openAudioConnection(vc);
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.music.join.success.title",
"",
"commands.music.join.success.description",
vc.getName())
.build()).queue();
try {
event.getGuild().getAudioManager().openAudioConnection(vc);
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.music.join.success.title",
"",
"commands.music.join.success.description",
vc.getName())
.build()).queue();
} catch (InsufficientPermissionException e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.join.error.permission.title",
"commands.music.join.error.permission.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
@ -38,12 +46,19 @@ public class JoinCommand implements Command {
.build()).queue();
}
} else {
event.getGuild().getAudioManager().openAudioConnection(vc);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.music.join.success.title", "",
"commands.music.join.success.description", vc.getName())
.build()).queue();
try {
event.getGuild().getAudioManager().openAudioConnection(vc);
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.music.join.success.title", "",
"commands.music.join.success.description", vc.getName())
.build()).queue();
} catch (InsufficientPermissionException e) {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.join.error.permission.title",
"commands.music.join.error.permission.description")
.build()).queue();
}
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(

View file

@ -178,6 +178,8 @@ commands.music.join.error.connecting.trying.title = Already trying to connect
commands.music.join.error.connecting.trying.description = Hadder is already trying to connect. Please wait a moment
commands.music.join.error.channel.title = No Voice Channel
commands.music.join.error.channel.description = You aren't in a Voice Channel.
commands.music.join.error.permission.title = No permission
commands.music.join.error.permission.description = I am not allowed to join your voice channel.
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