Merge remote-tracking branch 'origin/greg-dev' into hax-dev

This commit is contained in:
Hax 2020-02-01 13:39:15 +01:00
commit 1d7ad8af31
12 changed files with 128 additions and 53 deletions

View file

@ -26,7 +26,7 @@ Hax#6775
| h.help | Shows each command and explains its usage. | | h.help | Shows each command and explains its usage. |
| h.about | Shows information about Hadder. | | h.about | Shows information about Hadder. |
| h.equals | Checks if two strings are the same. | | h.equals | Checks if two strings are the same. |
| h.invite | Shows the invite link to invite Hadder to your server. | | h.invite | Shows the invite link to invite Hadder to your server. |
| h.ping | Shows the ping to the Discord API. | | h.ping | Shows the ping to the Discord API. |
| h.avatar | Sends the avatar of the specified member. | | h.avatar | Sends the avatar of the specified member. |
| h.gif | Looks for a GIF on Giphy. | | h.gif | Looks for a GIF on Giphy. |

13
pom.xml
View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<groupId>Hadder</groupId> <groupId>Hadder</groupId>
<artifactId>Hadder</artifactId> <artifactId>Hadder</artifactId>
<version>1.0.0</version> <version>1.0.1</version>
<name>Hadder</name> <name>Hadder</name>
@ -13,6 +13,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.13</maven.compiler.source> <maven.compiler.source>1.13</maven.compiler.source>
<maven.compiler.target>1.13</maven.compiler.target> <maven.compiler.target>1.13</maven.compiler.target>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
</properties> </properties>
<developers> <developers>
@ -50,12 +51,12 @@
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId> <artifactId>maven-model</artifactId>
<version>3.5.4</version> <version>3.6.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.dv8tion</groupId> <groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId> <artifactId>JDA</artifactId>
<version>4.1.1_101</version> <version>4.1.1_104</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.json</groupId> <groupId>org.json</groupId>
@ -80,12 +81,12 @@
<dependency> <dependency>
<groupId>org.kohsuke</groupId> <groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId> <artifactId>github-api</artifactId>
<version>1.103</version> <version>1.106</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sedmelluq</groupId> <groupId>com.sedmelluq</groupId>
<artifactId>lavaplayer</artifactId> <artifactId>lavaplayer</artifactId>
<version>1.3.33</version> <version>1.3.34</version>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -31,6 +31,7 @@ import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.Activity;
import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder; import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder;
import net.dv8tion.jda.api.sharding.ShardManager; import net.dv8tion.jda.api.sharding.ShardManager;
import net.dv8tion.jda.api.utils.ChunkingFilter;
import java.util.List; import java.util.List;
@ -54,7 +55,9 @@ public class Hadder {
builder.setAutoReconnect(true); builder.setAutoReconnect(true);
builder.setShardsTotal(1); builder.setShardsTotal(1);
builder.setActivity(Activity.streaming("on the BigBotNetwork", "https://twitch.tv/BigBotNetwork")); builder.setChunkingFilter(ChunkingFilter.ALL);
builder.setBulkDeleteSplittingEnabled(true);
builder.setActivity(Activity.listening("to h.help"));
builder.setStatus(OnlineStatus.DO_NOT_DISTURB); builder.setStatus(OnlineStatus.DO_NOT_DISTURB);
builder.setToken(config.getBotToken()); builder.setToken(config.getBotToken());
@ -120,7 +123,8 @@ public class Hadder {
new PauseCommand(), new PauseCommand(),
new LoopCommand(), new LoopCommand(),
new BassCommand(), new BassCommand(),
new EchoCommand()), config, helpCommand); new EchoCommand(),
new ServerStatsCommand()), config, helpCommand);
builder.addEventListeners( builder.addEventListeners(
new MentionListener(rethink), new MentionListener(rethink),

View file

@ -18,6 +18,7 @@ package com.bbn.hadder;
import com.bbn.hadder.core.Config; import com.bbn.hadder.core.Config;
import com.rethinkdb.RethinkDB; import com.rethinkdb.RethinkDB;
import com.rethinkdb.gen.exc.ReqlNonExistenceError;
import com.rethinkdb.gen.exc.ReqlOpFailedError; import com.rethinkdb.gen.exc.ReqlOpFailedError;
import com.rethinkdb.net.Connection; import com.rethinkdb.net.Connection;
import org.json.JSONArray; import org.json.JSONArray;
@ -125,10 +126,10 @@ public class Rethink {
this.insert("server", r this.insert("server", r
.hashMap("id", id) .hashMap("id", id)
.with("prefix", "h.") .with("prefix", "h.")
.with("message_id", "") .with("message_id", null)
.with("role_id", "") .with("role_id", null)
.with("invite_detect", false) .with("invite_detect", false)
.with("starboard", "") .with("starboard", null)
.with("neededstars", "4") .with("neededstars", "4")
); );
} }
@ -143,7 +144,7 @@ public class Rethink {
// TODO // TODO
public boolean hasStarboardChannel(String guild_id) { public boolean hasStarboardChannel(String guild_id) {
return !this.getByID("server", guild_id, "starboard").equals(""); return this.getByID("server", guild_id, "starboard") != null;
} }
// TODO // TODO
public void insertStarboardMessage(String message_id, String guild_id, String starboard_message_id) { public void insertStarboardMessage(String message_id, String guild_id, String starboard_message_id) {
@ -159,7 +160,12 @@ public class Rethink {
} }
// TODO // TODO
public boolean hasStarboardMessage(String message_id) { public boolean hasStarboardMessage(String message_id) {
return this.getByID("stars", message_id, "guild") != null; try {
this.getByID("stars", message_id, "guild");
return true;
} catch (ReqlNonExistenceError e) {
return false;
}
} }

View file

@ -24,15 +24,15 @@ public class RethinkServer {
private Rethink rethink; private Rethink rethink;
String accept_emote = ""; public String accept_emote = null;
String decline_emote = ""; public String decline_emote = null;
String id; public String id;
boolean invite_detect = false; public boolean invite_detect = false;
String message_id = ""; public String message_id = null;
String neededstars = "3"; public String neededstars = "3";
String prefix = "h."; public String prefix = "h.";
String role_id = ""; public String role_id = null;
String starboard = ""; public String starboard = null;
public RethinkServer(JSONObject object, Rethink rethink) { public RethinkServer(JSONObject object, Rethink rethink) {
for (Field field : this.getClass().getDeclaredFields()) { for (Field field : this.getClass().getDeclaredFields()) {

View file

@ -24,10 +24,10 @@ public class RethinkUser {
private Rethink rethink; private Rethink rethink;
String id; public String id;
String prefix = "h."; public String prefix = "h.";
String language = "en"; public String language = "en";
String blacklisted = "none"; public String blacklisted = null;
public RethinkUser(JSONObject object, Rethink rethink) { public RethinkUser(JSONObject object, Rethink rethink) {
for (Field field : this.getClass().getDeclaredFields()) { for (Field field : this.getClass().getDeclaredFields()) {

View file

@ -0,0 +1,65 @@
/*
* Copyright 2019-2020 GregTCLTK and Schlauer-Hax
*
* Licensed under the GNU Affero General Public License, Version 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.gnu.org/licenses/agpl-3.0.en.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bbn.hadder.commands.misc;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
import java.util.Date;
public class ServerStatsCommand implements Command {
@Override
public void executed(String[] args, CommandEvent e) {
EmbedBuilder eb = e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.misc.serverstats.title", "",
"commands.misc.serverstats.description", e.getGuild().getName())
.addField("Owner", e.getGuild().getOwner().getUser().getAsTag(), true)
.addField("ID", e.getGuild().getId(), true)
.addField("Region", e.getGuild().getRegion().getName(), true)
.addField("Time created", new Date(e.getGuild().getTimeCreated().toInstant().toEpochMilli()).toString(), true)
.setThumbnail(e.getGuild().getIconUrl())
.setImage(e.getGuild().getBannerUrl());
if (e.getGuild().getDescription() != null) eb.addField("Description", e.getGuild().getDescription(), true);
if (e.getGuild().getVanityCode() != null) eb.addField("Vanity Code", "[" + e.getGuild().getVanityCode() + "](https://discord.gg/" + e.getGuild().getVanityCode() + ")", true);
e.getTextChannel().sendMessage(eb.build()).queue();
}
@Override
public String[] labels() {
return new String[]{"serverstats"};
}
@Override
public String description() {
return "commands.misc.serverstats.help.description";
}
@Override
public String usage() {
return null;
}
@Override
public String example() {
return null;
}
}

View file

@ -21,7 +21,6 @@ import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm; import com.bbn.hadder.core.Perm;
import com.bbn.hadder.core.Perms; import com.bbn.hadder.core.Perms;
import com.bbn.hadder.utils.MessageEditor; import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User; import net.dv8tion.jda.api.entities.User;
import java.util.ArrayList; import java.util.ArrayList;
@ -42,7 +41,7 @@ public class BlacklistCommand implements Command {
if (args.length == 3) { if (args.length == 3) {
String blacklisted = e.getRethinkUser().getBlacklisted(); String blacklisted = e.getRethinkUser().getBlacklisted();
List<String> commands = new ArrayList<>(); List<String> commands = new ArrayList<>();
if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(","))); if (null != blacklisted) commands.addAll(Arrays.asList(blacklisted.split(",")));
commands.addAll(Arrays.asList(args[1].split(","))); commands.addAll(Arrays.asList(args[1].split(",")));
LinkedHashSet<String> hashSet = new LinkedHashSet<>(commands); LinkedHashSet<String> hashSet = new LinkedHashSet<>(commands);
@ -50,9 +49,9 @@ public class BlacklistCommand implements Command {
String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none"); String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none");
e.getRethinkUser().setBlacklisted(newblacklisted); e.getRethinkUser().setBlacklisted(newblacklisted);
e.getTextChannel().sendMessage( e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO) e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
.setTitle("Removed Blacklisted Commands from User") "commands.owner.blacklist.success.add.title", "",
.setDescription("Blacklisted commands: "+newblacklisted) "commands.owner.blacklist.success.add.description", newblacklisted)
.build()).queue(); .build()).queue();
e.getRethinkUser().push(); e.getRethinkUser().push();
} }
@ -62,7 +61,7 @@ public class BlacklistCommand implements Command {
if (args.length == 3) { if (args.length == 3) {
String blacklisted = e.getRethinkUser().getBlacklisted(); String blacklisted = e.getRethinkUser().getBlacklisted();
List<String> commands = new ArrayList<>(); List<String> commands = new ArrayList<>();
if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(","))); if (null != blacklisted) commands.addAll(Arrays.asList(blacklisted.split(",")));
commands.removeAll(Arrays.asList(args[1].split(","))); commands.removeAll(Arrays.asList(args[1].split(",")));
LinkedHashSet<String> hashSet = new LinkedHashSet<>(commands); LinkedHashSet<String> hashSet = new LinkedHashSet<>(commands);
@ -70,9 +69,9 @@ public class BlacklistCommand implements Command {
String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none"); String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none");
e.getRethinkUser().setBlacklisted(newblacklisted); e.getRethinkUser().setBlacklisted(newblacklisted);
e.getTextChannel().sendMessage( e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO) e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
.setTitle("Removed Blacklisted Commands from User") "commands.owner.blacklist.success.remove.title", "",
.setDescription("Blacklisted commands: "+newblacklisted) "commands.owner.blacklist.success.remove.description", newblacklisted)
.build()).queue(); .build()).queue();
e.getRethinkUser().push(); e.getRethinkUser().push();
} }
@ -83,7 +82,7 @@ public class BlacklistCommand implements Command {
for (User user : e.getJDA().getUsers()) { for (User user : e.getJDA().getUsers()) {
if (!user.getId().equals(e.getJDA().getSelfUser().getId())) { if (!user.getId().equals(e.getJDA().getSelfUser().getId())) {
String blacklisted = e.getRethinkUser().getBlacklisted(); String blacklisted = e.getRethinkUser().getBlacklisted();
if (!"none".equals(blacklisted)) { if (null != blacklisted) {
stringBuilder.append(user.getAsTag()).append(" (").append(user.getId()).append(") - ").append(blacklisted).append("\n"); stringBuilder.append(user.getAsTag()).append(" (").append(user.getId()).append(") - ").append(blacklisted).append("\n");
} }
} }

View file

@ -19,7 +19,6 @@ package com.bbn.hadder.commands.settings;
import com.bbn.hadder.commands.Command; import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent; import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.utils.MessageEditor; import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
public class LanguageCommand implements Command { public class LanguageCommand implements Command {

View file

@ -69,7 +69,7 @@ public class CommandHandler {
boolean run = true; boolean run = true;
String blacklisted = rethinkUser.getBlacklisted(); String blacklisted = rethinkUser.getBlacklisted();
if (!"none".equals(blacklisted)) { if (null != blacklisted) {
for (String BLLabel : blacklisted.split(",")) { for (String BLLabel : blacklisted.split(",")) {
if (Arrays.asList(cmd.labels()).contains(BLLabel)) { if (Arrays.asList(cmd.labels()).contains(BLLabel)) {
run = false; run = false;

View file

@ -19,7 +19,6 @@ package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink; import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkServer; import com.bbn.hadder.RethinkServer;
import com.bbn.hadder.RethinkUser; import com.bbn.hadder.RethinkUser;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.ChannelType; import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@ -56,31 +55,26 @@ public class MentionListener extends ListenerAdapter {
} catch (IOException | XmlPullParserException ex) { } catch (IOException | XmlPullParserException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
EmbedBuilder builder = new EmbedBuilder().setTitle("Hi!").addField("Version", model.getVersion(), false) EmbedBuilder builder = new EmbedBuilder()
.addField("Userprefix", rethinkUser.getPrefix(), true).addField("Guildprefix", rethinkServer.getPrefix(), true); .setTitle("Hi!")
.addField("Version", model.getVersion(), false)
.addField("User-Prefix", rethinkUser.getPrefix(), true)
.addField("Guild-Prefix", rethinkServer.getPrefix(), true);
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
model.getDependencies().forEach( model.getDependencies().forEach(
dependency -> stringBuilder.append(dependency.getArtifactId()+" - "+dependency.getVersion()+"\n") dependency -> stringBuilder.append(dependency.getArtifactId()).append(" - ").append(dependency.getVersion()).append("\n")
); );
builder.addField("Dependencies", stringBuilder.toString(), false); builder.addField("Dependencies", stringBuilder.toString(), false);
StringBuilder devs = new StringBuilder(); StringBuilder devs = new StringBuilder();
//TODO: Fix Mail stuff
model.getDevelopers().forEach( model.getDevelopers().forEach(
developer -> devs.append(developer.getId()+" - [Website]("+developer.getUrl()+"), [E-Mail](https://hax.bigbotnetwork.de/redirect.html?url=mailto:"+developer.getEmail()+")\n") developer -> devs.append(developer.getId()).append(" - [Website](").append(developer.getUrl()).append("), [E-Mail](https://hax.bigbotnetwork.de/redirect.html?url=mailto:").append(developer.getEmail()).append(")\n")
); );
builder.addField("Developer", devs.toString(), false); builder.addField("Developer", devs.toString(), false);
builder.addField("Join our Dev Server!", "[Click here!](https://discord.gg/58My2dM)", true); builder.addField("Join our Dev Server!", "[Click here!](https://discord.gg/58My2dM)", true);
builder.addField("Github", "[Click here!](https://github.com/BigBotNetwork/Hadder)",false); builder.addField("Github", "[Click here!](https://github.com/BigBotNetwork/Hadder)",false);
builder.addField("Twitch", "[Click here!](https://www.twitch.tv/bigbotnetwork)", false); builder.addField("Twitch", "[Click here!](https://www.twitch.tv/bigbotnetwork)", false);
e.getChannel().sendMessage(builder.build()).queue(); e.getChannel().sendMessage(builder.build()).queue();
/*e.getChannel().sendMessage(new MessageEditor(rethinkUser, e.getAuthor()).getMessage(MessageEditor.MessageType.INFO)
.setTitle("Hello I'm Hadder.")
.setAuthor(e.getJDA().getSelfUser().getName(), e.getJDA().getSelfUser().getAvatarUrl(), e.getJDA().getSelfUser().getAvatarUrl())
.addField("Users", String.valueOf(e.getJDA().getUsers().size()), false)
.addField("Guilds", String.valueOf(e.getJDA().getGuilds().size()), false)
.addField("Prefix (User)", rethinkUser.getPrefix(), false)
.addField("Prefix (Guild)", rethinkServer.getPrefix(), false)
.build()).queue();*/
} else if (e.getMessage().getContentRaw().equalsIgnoreCase("@someone")) { } else if (e.getMessage().getContentRaw().equalsIgnoreCase("@someone")) {
int member = new Random().nextInt(e.getGuild().getMembers().size() - 1); int member = new Random().nextInt(e.getGuild().getMembers().size() - 1);
if (member > 0 && member < e.getGuild().getMembers().size()) { if (member > 0 && member < e.getGuild().getMembers().size()) {

View file

@ -87,6 +87,9 @@ commands.misc.screenshare.number.error.description = This isn't a Number.
commands.misc.screenshare.channel.existing.error = Hol' up commands.misc.screenshare.channel.existing.error = Hol' up
commands.misc.screenshare.channel.existing.description = There is no Voice Channel named like this. \n\nNote\: Make sure the Voice Channel is in this Guild. commands.misc.screenshare.channel.existing.description = There is no Voice Channel named like this. \n\nNote\: Make sure the Voice Channel is in this Guild.
commands.misc.screenshare.help.description = Shows you the link to share your screen. commands.misc.screenshare.help.description = Shows you the link to share your screen.
commands.misc.serverstats.title = Serverstats
commands.misc.serverstats.description = This message contains some information about `%extra%`
commands.misc.serverstats.help.description = Shows information about a server.
commands.moderation.ban.success.title = Successfully banned commands.moderation.ban.success.title = Successfully banned
commands.moderation.ban.success.description = I successfully baned %extra% commands.moderation.ban.success.description = I successfully baned %extra%
@ -299,6 +302,10 @@ commands.owner.shutdown.success.title = Shutdown
commands.owner.shutdown.help.description = Shuts the Bot down commands.owner.shutdown.help.description = Shuts the Bot down
commands.owner.test.success = TEST my friends commands.owner.test.success = TEST my friends
commands.owner.test.help.description = Just a little Test Command commands.owner.test.help.description = Just a little Test Command
commands.owner.blacklist.success.add.title = Successfully blacklisted the specified commands
commands.owner.blacklist.success.add.description = I successfully added the following commands from the blacklist:\n %extra%
commands.owner.blacklist.success.remove.title = Successfully removed the commands from the blacklist
commands.owner.blacklist.success.remove.description = I successfully removed the following commands from the blacklist:\n %extra%
commands.owner.blacklist.help.description = Blacklist a user for specific commands commands.owner.blacklist.help.description = Blacklist a user for specific commands
commands.settings.language.success.title = Language set commands.settings.language.success.title = Language set