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

13
pom.xml
View file

@ -1,11 +1,11 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>
<groupId>Hadder</groupId>
<artifactId>Hadder</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<name>Hadder</name>
@ -13,6 +13,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.13</maven.compiler.source>
<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>
<developers>
@ -50,12 +51,12 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.5.4</version>
<version>3.6.3</version>
</dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.1.1_101</version>
<version>4.1.1_104</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
@ -80,12 +81,12 @@
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.103</version>
<version>1.106</version>
</dependency>
<dependency>
<groupId>com.sedmelluq</groupId>
<artifactId>lavaplayer</artifactId>
<version>1.3.33</version>
<version>1.3.34</version>
</dependency>
</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.sharding.DefaultShardManagerBuilder;
import net.dv8tion.jda.api.sharding.ShardManager;
import net.dv8tion.jda.api.utils.ChunkingFilter;
import java.util.List;
@ -54,7 +55,9 @@ public class Hadder {
builder.setAutoReconnect(true);
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.setToken(config.getBotToken());
@ -120,7 +123,8 @@ public class Hadder {
new PauseCommand(),
new LoopCommand(),
new BassCommand(),
new EchoCommand()), config, helpCommand);
new EchoCommand(),
new ServerStatsCommand()), config, helpCommand);
builder.addEventListeners(
new MentionListener(rethink),

View file

@ -18,6 +18,7 @@ package com.bbn.hadder;
import com.bbn.hadder.core.Config;
import com.rethinkdb.RethinkDB;
import com.rethinkdb.gen.exc.ReqlNonExistenceError;
import com.rethinkdb.gen.exc.ReqlOpFailedError;
import com.rethinkdb.net.Connection;
import org.json.JSONArray;
@ -125,10 +126,10 @@ public class Rethink {
this.insert("server", r
.hashMap("id", id)
.with("prefix", "h.")
.with("message_id", "")
.with("role_id", "")
.with("message_id", null)
.with("role_id", null)
.with("invite_detect", false)
.with("starboard", "")
.with("starboard", null)
.with("neededstars", "4")
);
}
@ -143,7 +144,7 @@ public class Rethink {
// TODO
public boolean hasStarboardChannel(String guild_id) {
return !this.getByID("server", guild_id, "starboard").equals("");
return this.getByID("server", guild_id, "starboard") != null;
}
// TODO
public void insertStarboardMessage(String message_id, String guild_id, String starboard_message_id) {
@ -159,7 +160,12 @@ public class Rethink {
}
// TODO
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;
String accept_emote = "";
String decline_emote = "";
String id;
boolean invite_detect = false;
String message_id = "";
String neededstars = "3";
String prefix = "h.";
String role_id = "";
String starboard = "";
public String accept_emote = null;
public String decline_emote = null;
public String id;
public boolean invite_detect = false;
public String message_id = null;
public String neededstars = "3";
public String prefix = "h.";
public String role_id = null;
public String starboard = null;
public RethinkServer(JSONObject object, Rethink rethink) {
for (Field field : this.getClass().getDeclaredFields()) {

View file

@ -24,10 +24,10 @@ public class RethinkUser {
private Rethink rethink;
String id;
String prefix = "h.";
String language = "en";
String blacklisted = "none";
public String id;
public String prefix = "h.";
public String language = "en";
public String blacklisted = null;
public RethinkUser(JSONObject object, Rethink rethink) {
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.Perms;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.User;
import java.util.ArrayList;
@ -42,7 +41,7 @@ public class BlacklistCommand implements Command {
if (args.length == 3) {
String blacklisted = e.getRethinkUser().getBlacklisted();
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(",")));
LinkedHashSet<String> hashSet = new LinkedHashSet<>(commands);
@ -50,9 +49,9 @@ public class BlacklistCommand implements Command {
String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none");
e.getRethinkUser().setBlacklisted(newblacklisted);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Removed Blacklisted Commands from User")
.setDescription("Blacklisted commands: "+newblacklisted)
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.owner.blacklist.success.add.title", "",
"commands.owner.blacklist.success.add.description", newblacklisted)
.build()).queue();
e.getRethinkUser().push();
}
@ -62,7 +61,7 @@ public class BlacklistCommand implements Command {
if (args.length == 3) {
String blacklisted = e.getRethinkUser().getBlacklisted();
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(",")));
LinkedHashSet<String> hashSet = new LinkedHashSet<>(commands);
@ -70,9 +69,9 @@ public class BlacklistCommand implements Command {
String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none");
e.getRethinkUser().setBlacklisted(newblacklisted);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Removed Blacklisted Commands from User")
.setDescription("Blacklisted commands: "+newblacklisted)
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.owner.blacklist.success.remove.title", "",
"commands.owner.blacklist.success.remove.description", newblacklisted)
.build()).queue();
e.getRethinkUser().push();
}
@ -83,7 +82,7 @@ public class BlacklistCommand implements Command {
for (User user : e.getJDA().getUsers()) {
if (!user.getId().equals(e.getJDA().getSelfUser().getId())) {
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");
}
}

View file

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

View file

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

View file

@ -19,7 +19,6 @@ package com.bbn.hadder.listener;
import com.bbn.hadder.Rethink;
import com.bbn.hadder.RethinkServer;
import com.bbn.hadder.RethinkUser;
import com.bbn.hadder.utils.MessageEditor;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
@ -56,31 +55,26 @@ public class MentionListener extends ListenerAdapter {
} catch (IOException | XmlPullParserException ex) {
ex.printStackTrace();
}
EmbedBuilder builder = new EmbedBuilder().setTitle("Hi!").addField("Version", model.getVersion(), false)
.addField("Userprefix", rethinkUser.getPrefix(), true).addField("Guildprefix", rethinkServer.getPrefix(), true);
EmbedBuilder builder = new EmbedBuilder()
.setTitle("Hi!")
.addField("Version", model.getVersion(), false)
.addField("User-Prefix", rethinkUser.getPrefix(), true)
.addField("Guild-Prefix", rethinkServer.getPrefix(), true);
StringBuilder stringBuilder = new StringBuilder();
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);
StringBuilder devs = new StringBuilder();
//TODO: Fix Mail stuff
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("Join our Dev Server!", "[Click here!](https://discord.gg/58My2dM)", true);
builder.addField("Github", "[Click here!](https://github.com/BigBotNetwork/Hadder)",false);
builder.addField("Twitch", "[Click here!](https://www.twitch.tv/bigbotnetwork)", false);
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")) {
int member = new Random().nextInt(e.getGuild().getMembers().size() - 1);
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.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.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.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.test.success = TEST my friends
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.settings.language.success.title = Language set