From 4ff396f36717f2b325d6b109f051da07f736af21 Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Sun, 15 Apr 2018 14:21:57 +0200 Subject: [PATCH] d --- pom.xml | 2 +- .../java/commands/moderation/CommandBan.java | 12 +++++-- src/main/java/commands/music/CommandJoin.java | 35 ------------------- .../java/commands/music/CommandLeave.java | 25 ------------- .../java/commands/tools/CommandBotInfo.java | 8 ++--- .../java/commands/tools/CommandUpvoted.java | 1 - src/main/java/core/Main.java | 15 +++----- src/main/java/util/Constants.java | 9 +++++ 8 files changed, 29 insertions(+), 78 deletions(-) delete mode 100644 src/main/java/commands/music/CommandJoin.java delete mode 100644 src/main/java/commands/music/CommandLeave.java diff --git a/pom.xml b/pom.xml index 22ab0f9..46fa1b6 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ com.sedmelluq lavaplayer - 1.2.56 + 1.2.34 com.github.taycaldwell diff --git a/src/main/java/commands/moderation/CommandBan.java b/src/main/java/commands/moderation/CommandBan.java index 49a9554..b50595c 100644 --- a/src/main/java/commands/moderation/CommandBan.java +++ b/src/main/java/commands/moderation/CommandBan.java @@ -22,6 +22,7 @@ public boolean called(String[] args, MessageReceivedEvent event) { public void action(String[] args, MessageReceivedEvent event) { if (event.getAuthor().getId() == event.getGuild().getOwner().getUser().getId() || event.getMember().hasPermission(Permission.BAN_MEMBERS) || Owner.get(event.getAuthor())) { Message msg = event.getMessage(); + if (msg.getMentionedUsers().size()== 0) { event.getTextChannel().sendMessage(MessageHandler.getEmbed("moderation.ban.title", "moderation.ban.text", "", "normal", event)).queue(); } else { @@ -33,8 +34,15 @@ public void action(String[] args, MessageReceivedEvent event) { PrivateChannel channel = User.getUser().openPrivateChannel().complete(); channel.sendMessage(MessageHandler.getEmbed("moderation.ban.ban", "moderation.ban.user", event.getGuild().getName(), "sucess", event)).queue(); } - msg.getGuild().getController().ban(User, 1).queue(); - event.getTextChannel().sendMessage(MessageHandler.getEmbed("moderation.ban.ban", "moderation.ban.channel", User.getUser().getName(), "sucess", event)).queue(); + if (args.length > 0) { + String reason = event.getMessage().getContentRaw().replaceFirst(MessageHandler.getprefix(event.getGuild()), "").replaceFirst("ban", "").replaceFirst(args[0], ""); + msg.getGuild().getController().ban(User, 1).reason(reason).queue(); + event.getTextChannel().sendMessage(MessageHandler.getEmbed("moderation.ban.ban", "moderation.ban.channel", User.getUser().getName(), "sucess", event)).queue(); + } else { + msg.getGuild().getController().ban(User, 1).queue(); + event.getTextChannel().sendMessage(MessageHandler.getEmbed("moderation.ban.ban", "moderation.ban.channel", User.getUser().getName(), "sucess", event)).queue(); + } + } } } else { diff --git a/src/main/java/commands/music/CommandJoin.java b/src/main/java/commands/music/CommandJoin.java deleted file mode 100644 index b74e5b3..0000000 --- a/src/main/java/commands/music/CommandJoin.java +++ /dev/null @@ -1,35 +0,0 @@ -package commands.music; - -import commands.Command; -import net.dv8tion.jda.core.events.message.MessageReceivedEvent; -import net.dv8tion.jda.core.exceptions.PermissionException; - -public class CommandJoin implements Command { - @Override - public boolean called(String[] args, MessageReceivedEvent event) { - return false; - } - - @Override - public void action(String[] args, MessageReceivedEvent event) { - try { - if (!event.getGuild().getAudioManager().isConnected() && !event.getGuild().getAudioManager().isAttemptingToConnect()) { - if (event.getGuild().getAudioManager().getGuild().getVoiceChannels().contains(event.getMember().getVoiceState().getChannel())) { - event.getGuild().getAudioManager().openAudioConnection(event.getMember().getVoiceState().getChannel()); - } else { - event.getTextChannel().sendMessage("unknown error (eigentlich nicht)").queue(); - } - } else { - event.getTextChannel().sendMessage("I am already connected!").queue(); - } - } catch (PermissionException e) { - - } - event.getGuild().getAudioManager().setSelfDeafened(true); - } - - @Override - public void executed(boolean success, MessageReceivedEvent event) { - - } -} diff --git a/src/main/java/commands/music/CommandLeave.java b/src/main/java/commands/music/CommandLeave.java deleted file mode 100644 index e2de0b3..0000000 --- a/src/main/java/commands/music/CommandLeave.java +++ /dev/null @@ -1,25 +0,0 @@ -package commands.music; - -import commands.Command; -import net.dv8tion.jda.core.events.message.MessageReceivedEvent; - -public class CommandLeave implements Command { - @Override - public boolean called(String[] args, MessageReceivedEvent event) { - return false; - } - - @Override - public void action(String[] args, MessageReceivedEvent event) { - if (event.getGuild().getAudioManager().isConnected() || event.getGuild().getAudioManager().isAttemptingToConnect()) { - event.getGuild().getAudioManager().closeAudioConnection(); - } else { - event.getTextChannel().sendMessage("I cant leave when i am not in a voice channel").queue(); - } - } - - @Override - public void executed(boolean success, MessageReceivedEvent event) { - - } -} diff --git a/src/main/java/commands/tools/CommandBotInfo.java b/src/main/java/commands/tools/CommandBotInfo.java index d4bd87f..ffc98a4 100644 --- a/src/main/java/commands/tools/CommandBotInfo.java +++ b/src/main/java/commands/tools/CommandBotInfo.java @@ -29,7 +29,10 @@ public void action(String[] args, MessageReceivedEvent event) { JsonObject jsonObject = new JsonParser().parse(requestResponse.getResponseMessage()).getAsJsonObject(); event.getTextChannel().sendMessage(jsonObject.toString()).queue(); - event.getTextChannel().sendMessage(new EmbedBuilder().setThumbnail(jsonObject.get("avatar").getAsString()).setTitle("Botinfo: " + jsonObject.get("name").getAsString()).build()).queue(); + event.getTextChannel().sendMessage(new EmbedBuilder().setThumbnail(jsonObject.get("avatar").getAsString()) + .setTitle("Botinfo: " + jsonObject.get("name").getAsString()) + .addField("Owner", "jisdjisdjijsdij " + jsonObject.get("username"), true) + .build()).queue(); } catch (IOException e) { e.printStackTrace(); @@ -49,9 +52,6 @@ public void action(String[] args, MessageReceivedEvent event) { } - - - } else { event.getTextChannel().sendMessage("Zu kurz!").queue(); } diff --git a/src/main/java/commands/tools/CommandUpvoted.java b/src/main/java/commands/tools/CommandUpvoted.java index 8e14be3..db38dda 100644 --- a/src/main/java/commands/tools/CommandUpvoted.java +++ b/src/main/java/commands/tools/CommandUpvoted.java @@ -34,7 +34,6 @@ public void action(String[] args, MessageReceivedEvent event) { List voters = api.getVoterIds("407189087649398795", 1); - if (event.getMessage().getGuild().getId().equals(BBN)) { if (voters.contains(u.getId())) { diff --git a/src/main/java/core/Main.java b/src/main/java/core/Main.java index f83ef19..a04aede 100644 --- a/src/main/java/core/Main.java +++ b/src/main/java/core/Main.java @@ -2,18 +2,15 @@ import commands.botowner.*; import commands.moderation.*; -import commands.music.CommandJoin; import commands.tools.*; import commands.usercommands.*; import commands.usercommands.CommandHelp; import commands.botowner.CommandInfo; import commands.usercommands.CommandPremium; import listener.*; -import music.AudioCore; import net.dv8tion.jda.bot.sharding.DefaultShardManagerBuilder; import net.dv8tion.jda.bot.sharding.ShardManager; import net.dv8tion.jda.core.JDA; -import net.dv8tion.jda.core.entities.Game; import net.dv8tion.jda.core.utils.SessionController; import org.apache.commons.net.ftp.FTPClient; import org.slf4j.Logger; @@ -31,7 +28,6 @@ public class Main { public static boolean dev = true; public static SessionController sessionController; public static ShardManager shardManager; - public static AudioCore audioCore; public static void main(String[] args2) { try { @@ -82,7 +78,7 @@ public static void main(String[] args2) { commandHandler.commands.put("ban", new CommandBan()); commandHandler.commands.put("kick", new CommandKick()); commandHandler.commands.put("github", new CommandGitHub()); - commandHandler.commands.put("stop", new CommandStop()); + commandHandler.commands.put("botstop", new CommandStop()); commandHandler.commands.put("setlvl", new CommandSetLevel()); commandHandler.commands.put("setxp", new CommandSetXP()); commandHandler.commands.put("clyde", new CommandClyde()); @@ -96,11 +92,11 @@ public static void main(String[] args2) { commandHandler.commands.put("levelmessage", new CommandLevelMessage()); commandHandler.commands.put("guild", new CommandGuild()); commandHandler.commands.put("help", new CommandHelp()); - commandHandler.commands.put("info", new CommandInfo()); + commandHandler.commands.put("about", new CommandInfo()); commandHandler.commands.put("warn", new CommandWarn()); commandHandler.commands.put("token", new CommandToken()); commandHandler.commands.put("log", new CommandLog()); - commandHandler.commands.put("play", new CommandPlay()); + commandHandler.commands.put("game-play", new CommandPlay()); commandHandler.commands.put("dm", new CommandDM()); commandHandler.commands.put("miner", new CommandMiner()); commandHandler.commands.put("premium", new CommandPremium()); @@ -111,9 +107,8 @@ public static void main(String[] args2) { commandHandler.commands.put("uptime", new CommandUptime()); commandHandler.commands.put("role", new CommandRole()); commandHandler.commands.put("botinfo", new CommandBotInfo()); - /*MUSIC*/ - commandHandler.commands.put("join", new CommandJoin()); - commandHandler.commands.put("leave", new commands.music.CommandLeave()); + commandHandler.commands.put("upvoted", new CommandUpvoted()); + args = args2; logger.info("loaded all commands"); logger.info("Starting the Bot..."); diff --git a/src/main/java/util/Constants.java b/src/main/java/util/Constants.java index 03bb78f..d47d5f0 100644 --- a/src/main/java/util/Constants.java +++ b/src/main/java/util/Constants.java @@ -15,6 +15,15 @@ public class Constants { progBars.put(names[i], ids[i]); } } + public static String argsToString(String[] args, String filler){ + String out = ""; + for (String s : args){ + if (out != "") + out += filler; + out += s; + } + return out; + } }