- #317

Merged
greg6775 merged 72 commits from master into greg-dev 2020-01-13 08:40:12 +01:00
8 changed files with 111 additions and 51 deletions
Showing only changes of commit 0e77468d6f - Show all commits

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

@ -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

@ -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.Message;
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
import java.net.URL;
@ -24,6 +25,11 @@ public class PlayCommand implements Command {
"commands.music.play.load.title", "",
"commands.music.play.load.description", "").build()).complete();
event.getAudioManager().loadTrack(input, event, msg);
} 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();
} catch (Exception ignore) {
Message msg = event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.music.play.load.title", "",

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

@ -178,11 +178,15 @@ 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
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...
@ -198,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
@ -210,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