Merge Hax's branch into Greg's branch #298

Merged
greg6775 merged 4 commits from hax-dev into greg-dev 2020-01-03 16:00:31 +01:00
11 changed files with 184 additions and 137 deletions
Showing only changes of commit 4abfa70453 - Show all commits

View file

@ -9,6 +9,7 @@ Hadder Discord is a multi-purpose Discord bot with 100% uptime.
[![Crowdin](https://badges.crowdin.net/e/bc0babde730eb3eada34778502a31b03/localized.svg)](https://bbn.crowdin.com/hadder)
[![GitHub issues](https://img.shields.io/github/issues/BigBotNetwork/Hadder)](https://github.com/BigBotNetwork/Hadder/issues)
[![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)
[![Discord Bots](https://top.gg/api/widget/637002314162372639.svg)](https://top.gg/bot/637002314162372639)
@ -21,3 +22,38 @@ Hax#6775
### Designer
TopComp#1288
## A few commands
| **Command** | **Description** |
|----------------|---------------------------------------------------------------|
| h.help | Shows each command and explains its usage. |
| h.about | Shows information about Hadder. |
| h.equals | Checks if two strings are the same. |
| h.invite | Shows the invitation link to invite Hadder to your server. |
| h.ping | Shows the ping to the Discord API. |
| h.avatar | Sends the avatar of the specified member. |
| h.gif | Looks for a GIF on Giphy. |
| h.meme | Sends you a random meme. |
| h.clyde | Sends a message as a webhook named Clyde. |
| h.feedback | Sends feedback directly to the developers. |
| h.github | Displays information about a GitHub user profile. |
| h.screenshare | Shows you the link to share your screen. |
| h.ban | Bans one or more users from the server. |
| h.clear | Deletes the specified number of messages. |
| h.prefix | Sets the Guild-Prefix. |
| h.invitedetect | Activate or deactivate the Discord invite link detection. |
| h.kick | Kicks one or more user from the server. |
| h.nick | Rename a one or more user. |
| h.regionchange | Changes the server region to locked regions. |
| h.role | Adds and removes one or more role(s) from one or more user(s) |
| h.rules | Setup the rules on your Discord server |
| h.starboard | Sets the starboard channel. |
| h.editrules | Edits the rules message. |
| h.join | Joins your voice channel. |
| h.leave | Leaves your voice channel. |
| h.play | Plays the specified song. |
| h.stop | Stops the song. |
| h.info | Shows information about the playing song. |
| h.queue | Shows the music queue. |
| h.skip | Skips the currently playing song. |
| h.volume | Change the volume of the music. |

View file

@ -19,7 +19,7 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.1.0_90</version>
<version>4.1.0_93</version>
</dependency>
<dependency>
<groupId>org.json</groupId>

View file

@ -30,9 +30,9 @@ public class ClearCommand implements Command {
}
Message message = event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.lear.all.success.title",
"commands.moderation.clear.all.success.title",
"",
"commands.moderation.lear.all.success.description",
"commands.moderation.clear.all.success.description",
String.valueOf(msg.size()))
.build()).complete();
try {

View file

@ -82,8 +82,8 @@ public class RulesCommand implements Command {
if (event3.getMessage().getMentionedRoles().size() == 1) {
Role role = event3.getMessage().getMentionedRoles().get(0);
setRole(event, channel, message, event3, role);
} else if (event3.getGuild().getRolesByName(event3.getMessage().getContentStripped(), true).size() > 0) {
Role role = event3.getGuild().getRolesByName(event3.getMessage().getContentStripped(), true).get(0);
} else if (event3.getGuild().getRolesByName(event3.getMessage().getContentRaw(), true).size() > 0) {
Role role = event3.getGuild().getRolesByName(event3.getMessage().getContentRaw(), true).get(0);
setRole(event, channel, message, event3, role);
} else {
event3.getChannel().sendMessage(
@ -113,106 +113,113 @@ public class RulesCommand implements Command {
public void setRole(CommandEvent event, TextChannel channel, String message, GuildMessageReceivedEvent event3, Role role) {
if (event3.getGuild().getSelfMember().canInteract(role)) {
event3.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.emote.accept.title",
"",
"commands.moderation.rules.emote.accept.description", role.getName())
.build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event4 -> {
if (event4.getMessage().getEmotes().size() == 1) {
Emote aemote = event4.getMessage().getEmotes().get(0);
event4.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.emote.decline.title", "",
"commands.moderation.rules.emote.decline.description", String.valueOf(aemote))
.build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event5 -> {
Emote demote = event5.getMessage().getEmotes().get(0);
if (!aemote.equals(demote)) {
Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Rules")
.setDescription(message)
.build()).complete();
try {
rules.addReaction(aemote).queue();
rules.addReaction(demote).queue();
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.success.title",
"",
"commands.moderation.rules.success.description",
channel.getAsMention())
if (event3.getMember().canInteract(role)) {
event3.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.emote.accept.title",
"",
"commands.moderation.rules.emote.accept.description", role.getName())
.build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event4 -> {
if (event4.getMessage().getEmotes().size() == 1) {
Emote aemote = event4.getMessage().getEmotes().get(0);
event4.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.emote.decline.title", "",
"commands.moderation.rules.emote.decline.description", String.valueOf(aemote))
.build()).queue();
} catch (Exception e) {
event5.getChannel().sendMessage(
event.getEventWaiter().newOnMessageEventWaiter(event5 -> {
Emote demote = event5.getMessage().getEmotes().get(0);
if (!aemote.equals(demote)) {
Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Rules")
.setDescription(message)
.build()).complete();
try {
rules.addReaction(aemote).queue();
rules.addReaction(demote).queue();
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.success.title",
"",
"commands.moderation.rules.success.description",
channel.getAsMention())
.build()).queue();
} catch (Exception e) {
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"error",
"commands.moderation.rules.emote.error.access.description")
.build()).queue();
e.printStackTrace();
}
event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote.toString(), demote.toString());
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"error",
"commands.moderation.rules.emote.error.access.description")
.build()).queue();
e.printStackTrace();
"commands.moderation.rules.emote.error.equal.title",
"commands.moderation.rules.emote.error.equal.description")
.build()).queue();
}
event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote.toString(), demote.toString());
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.rules.emote.error.equal.title",
"commands.moderation.rules.emote.error.equal.description")
.build()).queue();
}
}, event.getJDA(), event.getAuthor());
} else {
String aemote = event4.getMessage().getContentRaw();
event4.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.emote.decline.title",
"commands.moderation.rules.emoji.decline.description")
.build()).queue();
event.getEventWaiter().newOnMessageEventWaiter(event5 -> {
String demote = event5.getMessage().getContentRaw();
if (!aemote.equals(demote)) {
Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Rules")
.setDescription(message)
.build()).complete();
try {
rules.addReaction(aemote).queue();
rules.addReaction(demote).queue();
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.success.title",
"",
"commands.moderation.rules.success.description",
channel.getAsMention())
}, event.getJDA(), event.getAuthor());
} else {
String aemote = event4.getMessage().getContentRaw();
event4.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.emote.decline.title",
"commands.moderation.rules.emoji.decline.description")
.build()).queue();
} catch (Exception e) {
event5.getChannel().sendMessage(
event.getEventWaiter().newOnMessageEventWaiter(event5 -> {
String demote = event5.getMessage().getContentRaw();
if (!aemote.equals(demote)) {
Message rules = channel.sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO)
.setTitle("Rules")
.setDescription(message)
.build()).complete();
try {
rules.addReaction(aemote).queue();
rules.addReaction(demote).queue();
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.INFO,
"commands.moderation.rules.success.title",
"",
"commands.moderation.rules.success.description",
channel.getAsMention())
.build()).queue();
} catch (Exception e) {
event5.getChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"error",
"commands.moderation.rules.emoji.error.description")
.build()).queue();
e.printStackTrace();
}
event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote, demote);
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"error",
"commands.moderation.rules.emoji.error.description")
.build()).queue();
e.printStackTrace();
"commands.moderation.rules.emote.error.equal.title",
"commands.moderation.rules.emote.error.equal.description")
.build()).queue();
}
event.getRethink().updateRules(event.getGuild().getId(), rules.getId(), role.getId(), aemote, demote);
} else {
event.getTextChannel().sendMessage(
event.getMessageEditor().getMessage(
MessageEditor.MessageType.ERROR,
"commands.moderation.rules.emote.error.equal.title",
"commands.moderation.rules.emote.error.equal.description")
.build()).queue();
}
}, event.getJDA(), event.getAuthor());
}
}, event.getJDA(), event.getAuthor());
}, event.getJDA(), event.getAuthor());
}
}, event.getJDA(), event.getAuthor());
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.moderation.rules.role.permission.error.title",
"commands.moderation.rules.role.permission.error.description")
.build()).queue();
}
} else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.NO_SELF_PERMISSION).build()).queue();
}

View file

@ -40,7 +40,7 @@ public class StarboardCommand implements Command {
@Override
public String description() {
return "Sets the starboard channel";
return "commands.moderation.starboard.help.description";
}
@Override

View file

@ -1,15 +1,14 @@
package com.bbn.hadder.commands.music;
/*
* @author Skidder / GregTCLTK
*/
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.managers.AudioManager;
/*
* @author Skidder / GregTCLTK
*/
public class JoinCommand implements Command {

View file

@ -71,7 +71,7 @@ public class BlacklistCommand implements Command {
for (User user : event.getJDA().getUsers()) {
if (!user.getId().equals(event.getJDA().getSelfUser().getId())) {
String blacklisted = event.getRethink().getBlackListed(user.getId());
if (!blacklisted.equals("none")) {
if (!"none".equals(blacklisted)) {
stringBuilder.append(user.getAsTag()).append(" (").append(user.getId()).append(") - ").append(blacklisted).append("\n");
}
}

View file

@ -41,8 +41,9 @@ public class CommandHandler {
for (Perm perm : cmd.getClass().getAnnotation(Perms.class).value()) {
if (!perm.check(commandEvent)) {
commandEvent.getTextChannel()
.sendMessage(commandEvent.getMessageEditor().getMessage(MessageEditor.MessageType.NO_PERMISSION).build())
.queue();
.sendMessage(commandEvent.getMessageEditor().getMessage(MessageEditor.MessageType.NO_PERMISSION)
.setDescription("To execute this command, you need the `" + cmd.getClass().getAnnotation(Perms.class).value()[0] + "` permission.")
.build()).queue();
return;
}
}
@ -51,8 +52,8 @@ public class CommandHandler {
boolean run = true;
String blacklisted = rethink.getBlackListed(event.getAuthor().getId());
if (!"none".equals(blacklisted)) {
for (String blacklistedlabel : blacklisted.split(",")) {
if (Arrays.asList(cmd.labels()).contains(blacklistedlabel)) {
for (String BLLabel : blacklisted.split(",")) {
if (Arrays.asList(cmd.labels()).contains(BLLabel)) {
run = false;
}
}

View file

@ -115,10 +115,6 @@ public class Config {
return config.getJSONObject("Tokens").getString("DiscordBotList");
}
public String getDiscordBestBotsToken() {
return config.getJSONObject("Tokens").getString("DiscordBestBots");
}
public String getDiscordBoatsToken() {
return config.getJSONObject("Tokens").getString("DiscordBoats");
}
@ -147,6 +143,10 @@ public class Config {
return config.getJSONObject("Tokens").getString("DiscordBots2");
}
public String getCloudListToken() {
return config.getJSONObject("Tokens").getString("CloudList");
}
public String getClydeName() {
return config.getString("Clyde");
}

View file

@ -21,7 +21,6 @@ public class BotList {
private static String MythicalBotList = "https://mythicalbots.xyz/api/bot/637002314162372639";
private static String BotsForDiscord = "https://botsfordiscord.com/api/bot/637002314162372639";
private static String DiscordBotList = "https://discordbotlist.com/api/bots/637002314162372639/stats";
private static String DiscordBestBots = "https://discordsbestbots.xyz/api/bots/637002314162372639/stats";
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";
@ -29,6 +28,7 @@ public class BotList {
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";
private static String CloudList = "https://www.cloudlist.xyz/api/stats/637002314162372639";
private Config config;
@ -42,6 +42,7 @@ public class BotList {
json.put("server_count", Hadder.shardManager.getGuilds().size());
json.put("guildCount", Hadder.shardManager.getGuilds().size());
json.put("guilds", Hadder.shardManager.getGuilds().size());
json.put("count", Hadder.shardManager.getGuilds().size());
json.put("users", Hadder.shardManager.getUsers().size());
json.put("shard_count", Hadder.shardManager.getShards().size());
json.put("shardCount", Hadder.shardManager.getShards().size());
@ -93,21 +94,6 @@ public class BotList {
e.printStackTrace();
}
// Discord Best Bots
Request discordbestbots = new Request.Builder()
.url(DiscordBestBots)
.post(body)
.addHeader("Authorization", config.getDiscordBestBotsToken())
.build();
try {
new OkHttpClient().newCall(discordbestbots).execute().close();
System.out.println("Successfully posted count to Discord Best Bots!");
} catch (IOException e) {
e.printStackTrace();
}
// Discord Boats
Request discordboats = new Request.Builder()
@ -212,6 +198,21 @@ public class BotList {
} catch (IOException e) {
e.printStackTrace();
}
// CloudList
Request cloudlist = new Request.Builder()
.url(CloudList)
.post(body)
.addHeader("Authorization", config.getCloudListToken())
.build();
try {
new OkHttpClient().newCall(cloudlist).execute().close();
System.out.println("Successfully posted count to the CloudList!");
} catch (IOException e) {
e.printStackTrace();
}
}
}
}

View file

@ -45,8 +45,8 @@ commands.misc.feedback.title.request.title = Feedback Topic
commands.misc.feedback.title.request.description = Please send me the feedback topic.
commands.misc.feedback.description.request.title = Feedback Description
commands.misc.feedback.description.request.description = Please send me the feedback description now.
commands.misc.feedback.help.description = Sends feedback directly to the developers.
commands.misc.feedback.success.title = Feedback successfully sent\!
commands.misc.feedback.help.description = Sends feedback directly to the developers.
commands.misc.github.link.title = Link your GitHub Account
commands.misc.github.success.title = Information about %extra%
commands.misc.github.success.bio = User bio
@ -81,8 +81,8 @@ commands.moderation.ban.myself.error.description = I can not ban myself\!
commands.moderation.ban.yourself.error.description = You can not ban yourself\!
commands.moderation.ban.massban.success.description = I successfully banned %extra% members\!
commands.moderation.ban.help.description = Bans one or more users from the server.
commands.moderation.lear.all.success.title = Successfully deleted
commands.moderation.lear.all.success.description = I successfully deleted %extra% messages.
commands.moderation.clear.all.success.title = Successfully deleted
commands.moderation.clear.all.success.description = I successfully deleted %extra% messages.
commands.moderation.clear.number.error.title = Invalid number
commands.moderation.clear.number.error.description = You have to choose a number between 1 and 99\!
commands.moderation.clear.success.title = Successfully cleared
@ -136,6 +136,8 @@ commands.moderation.rules.role.title = Role to assign
commands.moderation.rules.role.description = The rules were successfully set. Please send me the name of the role which the user receives after he accepted the rules.
commands.moderation.rules.role.error.title = Role does not exist
commands.moderation.rules.role.error.description = The specified role does not exist on this guild.
commands.moderation.rules.role.permission.error.title = No permission
commands.moderation.rules.role.permission.error.description = You cannot select this role because you cannot interact with it.
commands.moderation.rules.guild.error.title = Wrong Guild
commands.moderation.rules.guild.error.description = The mentioned channel must be on this guild\!
commands.moderation.rules.emote.accept.title = Custom Accept Emote
@ -153,6 +155,7 @@ commands.moderation.rules.error.message.title = Can't write messages
commands.moderation.rules.error.message.description = I can not write messages in the specified channel
commands.moderation.rules.help.description = Setup the rules on your Discord server
commands.moderation.starboard.success.title = Successfully set the Channel\!
commands.moderation.starboard.help.description = Sets the starboard channel.
commands.moderation.editrules.channel.title = Rules channel
commands.moderation.editrules.channel.description = Please send me the channel with the rules as mention
commands.moderation.editrules.channel.found.error.title = Channel not found
@ -175,12 +178,12 @@ 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.help.description = Joins 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.help.description = Leaves a voice channel
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...
commands.music.play.success.loading.title = %extra% Now playing %extra%
@ -192,22 +195,22 @@ commands.music.play.error.load.title = %extra% Load failed %extra%
commands.music.play.error.load.description = Unfortunately I can not load the given song
commands.music.play.error.match.title = %extra% No matches %extra%
commands.music.play.error.match.description = I can not find a song named this on YouTube
commands.music.play.help.description = Plays a song
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.help.description = Stops the song.
commands.music.info.success.title = Track info
commands.music.info.error.title = No playing track
commands.music.info.error.description = I am not playing anything at the moment
commands.music.info.help.description = Shows information about the playing song
commands.music.stop.help.description = Stops the song
commands.music.info.help.description = Shows information about the playing song.
commands.music.queue.error.title = No queue
commands.music.queue.error.description = There are no queued songs at the moment
commands.music.queue.success.title = Queue
commands.music.queue.success.description = This is the queue\: \n %extra%
commands.music.queue.help.description = Shows the music queue
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.help.description = Skips the currently playing 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