Merge in my branch ;) #381

Merged
greg6775 merged 8 commits from master into greg-dev 2020-02-20 19:43:33 +01:00
8 changed files with 84 additions and 35 deletions
Showing only changes of commit 56676c52e1 - Show all commits

View file

@ -11,9 +11,10 @@ Hadder Discord is a multi-purpose Discord bot with 100% uptime.
[![GitHub license](https://img.shields.io/github/license/BigBotNetwork/Hadder)](https://github.com/BigBotNetwork/Hadder/blob/master/LICENSE)
[![time tracker](https://wakatime.com/badge/github/BigBotNetwork/Hadder.svg)](https://wakatime.com/badge/github/BigBotNetwork/Hadder)
[![Discord Extreme List](https://api.discordextremelist.xyz/v1/bot/637002314162372639/widget)](https://discordextremelist.xyz/bots/Hadder)
[![MBL](Https://Mythicalbots.Xyz/Bot/637002314162372639/Embed?Q=Dark/ )](Https://Mythicalbots.Xyz/Bot/637002314162372639)
[![Discord Bots](https://top.gg/api/widget/637002314162372639.svg)](https://top.gg/bot/637002314162372639)
[![Hadder's Widget](https://api.botlist.space/widget/637002314162372639/2 "Hadder's Widget")](https://botlist.space/bot/637002314162372639?utm_source=bls&utm_medium=widget&utm_campaign=637002314162372639)
[![Discord Bots](https://discordbotlist.com/bots/637002314162372639/widget)](https://discordbotlist.com/bots/637002314162372639)
## Hadder Team
### Developer

View file

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>Hadder</groupId>
<artifactId>Hadder</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<name>Hadder</name>
@ -56,7 +56,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.1.1_105</version>
<version>4.1.1_108</version>
</dependency>
<dependency>
<groupId>org.json</groupId>

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;
@ -26,7 +27,6 @@ import org.json.JSONObject;
import java.lang.reflect.Field;
import java.util.NoSuchElementException;
public class Rethink {
private RethinkDB r = RethinkDB.r;
private Connection conn;
@ -154,7 +154,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;
}
}
@ -185,5 +190,4 @@ public class Rethink {
}
r.table("user").get(user.getId()).update(object.toMap()).run(conn);
}
}

View file

@ -0,0 +1,56 @@
/*
* 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.moderation;
import com.bbn.hadder.commands.Command;
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.Permission;
@Perms(Perm.MANAGE_ROLES)
public class RoleAssignmentCommand implements Command {
@Override
public void executed(String[] args, CommandEvent e) {
//TODO: THIS LOL
if (e.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES)) {
} else e.getTextChannel().sendMessage(e.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}
@Override
public String[] labels() {
return new String[0];
}
@Override
public String description() {
return null;
}
@Override
public String usage() {
return null;
}
@Override
public String example() {
return null;
}
}

View file

@ -16,6 +16,7 @@
package com.bbn.hadder.commands.owner;
import com.bbn.hadder.RethinkUser;
import com.bbn.hadder.commands.Command;
import com.bbn.hadder.commands.CommandEvent;
import com.bbn.hadder.core.Perm;
@ -38,7 +39,8 @@ public class BlacklistCommand implements Command {
} else {
switch (args[0].toLowerCase()) {
case "add":
if (args.length == 3) {
if (args.length == 3 && e.getMessage().getMentionedUsers().size() == 1) {
RethinkUser u = new RethinkUser(e.getRethink().getObjectByID("user", e.getMessage().getMentionedUsers().get(0).getId()), e.getRethink());
String blacklisted = e.getRethinkUser().getBlacklisted();
List<String> commands = new ArrayList<>();
if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(",")));
@ -47,18 +49,19 @@ public class BlacklistCommand implements Command {
ArrayList<String> commandsWithoutDuplicates = new ArrayList<>(hashSet);
String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none");
e.getRethinkUser().setBlacklisted(newblacklisted);
u.setBlacklisted(newblacklisted);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.owner.blacklist.success.add.title", "",
"commands.owner.blacklist.success.add.description", newblacklisted)
.build()).queue();
e.getRethinkUser().push();
}
u.push();
} else e.getHelpCommand().sendHelp(this, e);
break;
case "remove":
if (args.length == 3) {
if (args.length == 3 && e.getMessage().getMentionedUsers().size() == 1) {
RethinkUser u = new RethinkUser(e.getRethink().getObjectByID("user", e.getMessage().getMentionedUsers().get(0).getId()), e.getRethink());
String blacklisted = e.getRethinkUser().getBlacklisted();
List<String> commands = new ArrayList<>();
if (!"none".equals(blacklisted)) commands.addAll(Arrays.asList(blacklisted.split(",")));
@ -67,21 +70,22 @@ public class BlacklistCommand implements Command {
ArrayList<String> commandsWithoutDuplicates = new ArrayList<>(hashSet);
String newblacklisted = ((commandsWithoutDuplicates.size()!=0) ? String.join(",", commandsWithoutDuplicates) : "none");
e.getRethinkUser().setBlacklisted(newblacklisted);
u.setBlacklisted(newblacklisted);
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
"commands.owner.blacklist.success.remove.title", "",
"commands.owner.blacklist.success.remove.description", newblacklisted)
.build()).queue();
e.getRethinkUser().push();
}
u.push();
} else e.getHelpCommand().sendHelp(this, e);
break;
case "list":
StringBuilder stringBuilder = new StringBuilder();
for (User user : e.getJDA().getUsers()) {
if (!user.getId().equals(e.getJDA().getSelfUser().getId())) {
String blacklisted = e.getRethinkUser().getBlacklisted();
RethinkUser u = new RethinkUser(e.getRethink().getObjectByID("user", user.getId()), e.getRethink());
String blacklisted = u.getBlacklisted();
if (!"none".equals(blacklisted)) {
stringBuilder.append(user.getAsTag()).append(" (").append(user.getId()).append(") - ").append(blacklisted).append("\n");
}
@ -89,7 +93,7 @@ public class BlacklistCommand implements Command {
}
e.getTextChannel().sendMessage(
e.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Blacklisted Users:")
.setTitle("Blacklisted Users")
.setDescription((stringBuilder.length()!=0) ? ("``" + stringBuilder.toString() + "``") : "No blacklisted Users")
.build()).queue();
break;

View file

@ -76,8 +76,8 @@ public class CommandHandler {
}
}
}
if (run)
cmd.executed(args, commandEvent);
if (run) cmd.executed(args, commandEvent);
else event.getMessage().addReaction("").queue();
return;
}
}

View file

@ -36,7 +36,6 @@ public class BotList {
private static String DiscordBoats = "https://discord.boats/api/bot/637002314162372639";
private static String YetAnotherBotList = "https://yabl.xyz/api/bot/637002314162372639/stats";
private static String DiscordExtremeList = "https://api.discordextremelist.xyz/v1/bot/637002314162372639";
private static String DiscordBotReviews = "https://discordbotreviews.xyz/api/bot/637002314162372639/stats";
private static String DiscordBots = "https://top.gg/api/bots/637002314162372639/stats";
private static String BotListSpace = "https://api.botlist.space/v1/bots/637002314162372639";
private static String DiscordBots2 = "https://discord.bots.gg/api/v1/bots/637002314162372639/stats";
@ -151,21 +150,6 @@ public class BotList {
e.printStackTrace();
}
// Discord Bot Reviews
Request discordbotreviews = new Request.Builder()
.url(DiscordBotReviews)
.post(body)
.addHeader("Authorization", config.getDiscordBotReviewsToken())
.build();
try {
new OkHttpClient().newCall(discordbotreviews).execute().close();
System.out.println("Successfully posted count to Discord Bot Reviews!");
} catch (IOException e) {
e.printStackTrace();
}
// Discord Bots
Request discordbots = new Request.Builder()

View file

@ -133,6 +133,6 @@ public class MessageEditor {
ResourceBundle resourceBundle = ResourceBundle.getBundle("Translations/Translations", locale);
if (resourceBundle.containsKey(string))
return resourceBundle.getString(string).replaceAll("%extra%", extra).replaceAll("%extra_two%", extra_two);
else return "This key doesn't exist. Please report this to the Bot Developers. Key: " + string + " Language_code: " + language_code;
else return "This key doesn't exist. Please report this to the Bot Developers. Key: `" + string + "` Language_code: `" + language_code + "`";
}
}