Browse Source

23.08.2017 -- Update Language

pull/11/head
Niklas H. 2 years ago
parent
commit
325a88151d
No known key found for this signature in database
5 changed files with 64 additions and 53 deletions
  1. +6
    -0
      lang/lang_en.json
  2. +1
    -1
      src/main/java/events/Module.java
  3. +9
    -6
      src/main/java/modules/Gamestats.java
  4. +13
    -12
      src/main/java/modules/InfoCommands.java
  5. +35
    -34
      src/main/java/modules/Moderation.java

+ 6
- 0
lang/lang_en.json View File

@@ -46,6 +46,7 @@
"shutdowninfo": "The Bot will shutting down in 10 seconds! Bye bye.",
"getServer_getserver": "Get Servers",
"search_result": "Your search Result",
"game_overwatch_level": "Level",
"playMusic_play": "The Bot plays the first song.",
"stats_uptime": "Uptime",
"setplaying_setplaying": "Change the Bot Game",
@@ -67,6 +68,7 @@
"skipTrack_skip": "The Bot skips a song.",
"perm_rem_success": "Permission removed successful.",
"del_topic": "Deletion %1s of %2s",
"help_page": "Page",
"changeStatus_changestatus": "Change the Status",
"music_volumechange": "Volume changed from %1s to %2s.",
"perm_add_success": "Permission added successful.",
@@ -76,12 +78,15 @@
"printProperties_printprop": "Print the Property",
"role_notfound": "The Role was not found.",
"getGameStats_gamestats": "Get Statistics about a Player in a Game",
"game_unsupported": "This Game isn\u0027t supported.",
"perm_add_failed": "Failed to add Permission to group.",
"norolefound": "The Role was not found.",
"stats_title": "General Stats",
"changeprop_error": "This option can\u0027t found in the config file!",
"del_wait_success": "Deletion invoked... Wait until messages disapear.",
"deleteMessages_deletemessages": "Deletion of Message Amount",
"addPermToGroup_addperm": "Add Permission to Group",
"game_overwatch_comprank": "Competitive Rank",
"leaveMusic_leave": "The Bot leaves voice Server",
"searchtoken_google": "Please provide a google search api token.",
"music_add": "Adding to queue: %1s.",
@@ -92,6 +97,7 @@
"help_command": "Command",
"changeProperty_changeprop": "Change the Property",
"music_add_queue": "Adding to queue %1s (first track of playlist %2s).",
"game_overwatch_gameswon": "Games Won Quickplay",
"music_notloaded": "Could not play the choosen song.",
"music_skip": "Skipped to next track.",
"deleteprivateMessages_deleteprivmsg": "Shutdown the bot",

+ 1
- 1
src/main/java/events/Module.java View File

@@ -11,6 +11,6 @@ import util.Fast;
public class Module implements Fast, LanguageInterface {
@Override
public void setdefaultLanguage() {
Console.error("No Language");
Console.error("No Language for "+this.getClass().getName());
}
}

+ 9
- 6
src/main/java/modules/Gamestats.java View File

@@ -42,12 +42,12 @@ public class Gamestats extends Module implements Fast{
JSONObject competitive = stats.getJSONObject("competitive").getJSONObject("overall_stats");
JSONObject quickplay = stats.getJSONObject("quickplay").getJSONObject("game_stats");
builder.withThumbnail(competitive.getString("avatar"));
builder.withTitle(args[1]+" Level: "+(competitive.getInt("prestige") * 100 + competitive.getInt("level")));
builder.appendField("Competitive Rank", competitive.get("comprank").toString()+" "+competitive.getString("tier"), false);
builder.appendField("Games Won Quickplay", quickplay.get("games_won").toString(), false);
builder.withTitle(args[1]+" "+LANG.getTranslation("game_overwatch_level")+": "+(competitive.getInt("prestige") * 100 + competitive.getInt("level")));
builder.appendField(LANG.getTranslation("game_overwatch_comprank")+": ", competitive.get("comprank").toString()+" "+competitive.getString("tier"), false);
builder.appendField(LANG.getTranslation("game_overwatch_gameswon"), quickplay.get("games_won").toString(), false);
BotUtils.sendEmbMessage(event.getChannel(), builder, false);
} else {
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage("This Game isn't supported."), true);
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(LANG.getTranslation("game_unsupported")), true);
}
} catch (Exception ex) {
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(String.format(LANG.getTranslation("commonmessage_error"), ex.getMessage())), true);
@@ -56,10 +56,13 @@ public class Gamestats extends Module implements Fast{
}

@LanguageMethod(
languagestringcount = 0
languagestringcount = 4
)
@Override
public void setdefaultLanguage() {

DRIVER.setProperty(DEF_LANG, "game_overwatch_level", "Level");
DRIVER.setProperty(DEF_LANG, "game_overwatch_comprank", "Competitive Rank");
DRIVER.setProperty(DEF_LANG, "game_overwatch_gameswon", "Games Won Quickplay");
DRIVER.setProperty(DEF_LANG, "game_unsupported", "This Game isn't supported.");
}
}

+ 13
- 12
src/main/java/modules/InfoCommands.java View File

@@ -51,6 +51,7 @@ public class InfoCommands extends Module implements Fast {
}).start();
return true;
}

/**
* Help Command
*
@@ -71,13 +72,13 @@ public class InfoCommands extends Module implements Fast {
StringBuilder content = new StringBuilder();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy H:m:s");
if (event.getMessage().getMentions().size() > 0) {
for (IUser user: event.getMessage().getMentions()) {
for (IUser user : event.getMessage().getMentions()) {
content.append(user.getName()).append(": ").append(user.getCreationDate().format(formatter)).append("\n");
}
} else {
content.append("No User specified");
}
BotUtils.sendMessage(event.getChannel(), content.toString() , false);
BotUtils.sendMessage(event.getChannel(), content.toString(), false);
}).start();
return true;
}
@@ -109,6 +110,7 @@ public class InfoCommands extends Module implements Fast {

return true;
}

/**
* Send a invitation
*
@@ -125,7 +127,7 @@ public class InfoCommands extends Module implements Fast {
prefix = Globals.ADMIN_PREFIX
)
public boolean createInvite(MessageReceivedEvent event, String[] args) {
Console.debug("Creating Invite link to Server: "+args[0]);
Console.debug("Creating Invite link to Server: " + args[0]);
if (INIT.BOT.getGuildByID(Long.valueOf(args[0])) != null) {
IChannel channel = INIT.BOT.getGuildByID(Long.valueOf(args[0])).getGeneralChannel();
if (channel == null) {
@@ -204,13 +206,11 @@ public class InfoCommands extends Module implements Fast {
builders.get(page - 1).appendDescription(LANG.getTranslation("help_prefixinfo"));
int count = 0;
for (Command command : COMMAND.getAllCommands()) {
if (PERM.hasPermission(event.getAuthor(), event.getGuild(), command.permission())) {
String string = "\n" + LANG.getTranslation("help_alias") + ": | " + botprefix + command.prefix() + command.alias() +
"\n" + LANG.getTranslation("help_arguments") + ": | " + Arrays.toString(command.arguments()).replace("[", "").replace("]", "") +
"\n" + LANG.getTranslation("help_description") + ": | " + LANG.getMethodDescription(command) +
"\n" + LANG.getTranslation("help_permission") + ": | " + command.permission() + "\n";
builders.get(page - 1).appendField((count+1)+". "+LANG.getTranslation("help_command") + " | " + botprefix + command.prefix() + command.command(), string, false);
}
String string = "\n" + LANG.getTranslation("help_alias") + ": | " + botprefix + command.prefix() + command.alias() +
"\n" + LANG.getTranslation("help_arguments") + ": | " + Arrays.toString(command.arguments()).replace("[", "").replace("]", "") +
"\n" + LANG.getTranslation("help_description") + ": | " + LANG.getMethodDescription(command) +
"\n" + LANG.getTranslation("help_permission") + ": | " + command.permission() + "\n";
builders.get(page - 1).appendField((count + 1) + ". " + LANG.getTranslation("help_command") + " | " + botprefix + command.prefix() + command.command(), string, false);
if (builders.get(page - 1).getFieldCount() >= EmbedBuilder.FIELD_COUNT_LIMIT || builders.get(page - 1).getTotalVisibleCharacters() >= (EmbedBuilder.MAX_CHAR_LIMIT - 1000)) {
page++;
EmbedBuilder buildertemp = new EmbedBuilder();
@@ -220,12 +220,12 @@ public class InfoCommands extends Module implements Fast {
builders.get(page - 1).withTitle(":information_source: " + LANG.getTranslation("help_title") + " Page: " + page + " :information_source:");
builders.get(page - 1).withColor(Color.CYAN);
}
builders.get(0).withTitle(":information_source: " + LANG.getTranslation("help_title") + "(" + count + ")" + " Page: " + 1 + " :information_source:");
builders.get(0).withTitle(":information_source: " + LANG.getTranslation("help_title") + "(" + count + ")" + LANG.getTranslation("help_page") + 1 + " :information_source:");
return builders;
}

@LanguageMethod(
languagestringcount = 16
languagestringcount = 18
)
@Override
public void setdefaultLanguage() {
@@ -242,6 +242,7 @@ public class InfoCommands extends Module implements Fast {

//Help Command
DRIVER.setProperty(DEF_LANG, "help_title", "All Commands");
DRIVER.setProperty(DEF_LANG, "help_page", "Page");
DRIVER.setProperty(DEF_LANG, "help_command", "Command");
DRIVER.setProperty(DEF_LANG, "help_alias", "Alias");
DRIVER.setProperty(DEF_LANG, "help_arguments", "Arguments");

+ 35
- 34
src/main/java/modules/Moderation.java View File

@@ -21,12 +21,13 @@ import java.util.List;
* Created by N.Hartmann on 28.06.2017.
* Copyright 2017
*/
public class Moderation extends Module implements Fast{
public class Moderation extends Module implements Fast {

/**
* Deletes a List Message
*
* @param event MessageEvent
* @param args Argumente [Not needed]
* @param args Argumente [Not needed]
* @return state
*/
@Command(
@@ -42,32 +43,31 @@ public class Moderation extends Module implements Fast{
int total = 0;
try {
IChannel channel = event.getChannel();
String origintopic = channel.getTopic();
MessageHistory messages = channel.getMessageHistory(Integer.parseInt(args[0]));
if (messages.getLatestMessage().getLongID() == event.getMessage().getLongID()) {
while (!event.getMessage().isDeleted()) {
Thread.sleep(200);
}
messages = channel.getMessageHistory(Integer.parseInt(args[0]));
MessageHistory messages = channel.getMessageHistory(Integer.parseInt(args[0]));
BotUtils.bulkdeleteMessage(channel, messages);
if (messages.getLatestMessage().getLongID() == event.getMessage().getLongID()) {
while (!event.getMessage().isDeleted()) {
Thread.sleep(200);
}
total = messages.size();
BotUtils.bulkdeleteMessage(channel, messages);
channel.changeTopic(origintopic + " ["+String.format(LANG.getTranslation("del_topic"), total, total)+"]");
Console.debug(Console.sendprefix+"DM: "+total);
Thread.sleep(2000);
channel.changeTopic(origintopic);
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(LANG.SUCCESS+LANG.getTranslation("command_success")), true);
messages = channel.getMessageHistory(Integer.parseInt(args[0]));
}
total = messages.size();

Thread.sleep(2000);
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(LANG.SUCCESS + LANG.getTranslation("del_wait_success")), true);
} catch (Exception ex) {
BotUtils.sendMessage(event.getChannel(), LANG.ERROR+String.format(LANG.getTranslation("deletion_error"), total, total, ex.getMessage()), true);
BotUtils.sendMessage(event.getChannel(), LANG.ERROR + String.format(LANG.getTranslation("deletion_error"), total, total, ex.getMessage()), true);
}
}).start();

return true;
}

/**
* Force Deletes a List Message
*
* @param event MessageEvent
* @param args Argumente [Not needed]
* @param args Argumente [Not needed]
* @return state
*/
@Command(
@@ -85,32 +85,30 @@ public class Moderation extends Module implements Fast{
try {
IChannel channel = event.getChannel();
String origintopic = channel.getTopic();
MessageHistory messages = channel.getMessageHistory(Integer.parseInt(args[0]));
MessageHistory messages = channel.getMessageHistory(Integer.parseInt(args[0]));
if (messages.getLatestMessage().getLongID() == event.getMessage().getLongID()) {
while (!event.getMessage().isDeleted()) {
Thread.sleep(200);
}
messages = channel.getMessageHistory(Integer.parseInt(args[0]));
}
total = messages.size();
for (IMessage message: messages) {
if (!message.isDeleted()) {
BotUtils.deleteMessageOne(message);
count++;
channel.changeTopic(origintopic + " ["+String.format(LANG.getTranslation("del_topic"), count, total)+"]");
}
total = messages.size();
for (IMessage message : messages) {
if (!message.isDeleted()) {
BotUtils.deleteMessageOne(message);
count++;
}
Thread.sleep(1000);
channel.changeTopic(origintopic);
Console.debug(Console.sendprefix+"FDM: "+count+" of "+total);
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(LANG.SUCCESS+LANG.getTranslation("command_success")), true);
}
Thread.sleep(1000);
BotUtils.sendEmbMessage(event.getChannel(), SMB.shortMessage(LANG.SUCCESS + LANG.getTranslation("del_wait_success")), true);
} catch (Exception ex) {
BotUtils.sendMessage(event.getChannel(), LANG.ERROR+String.format(LANG.getTranslation("deletion_error"), count, total, ex.getMessage()), true);
BotUtils.sendMessage(event.getChannel(), LANG.ERROR + String.format(LANG.getTranslation("deletion_error"), count, total, ex.getMessage()), true);
}
}).start();

return true;
}

@Command(
command = "shutdown",
description = "Shutdown the bot",
@@ -126,11 +124,12 @@ public class Moderation extends Module implements Fast{
Thread.sleep(10000);
System.exit(0);
} catch (Exception ex) {
Console.error("Error on shutdown: "+ex.getMessage());
Console.error("Error on shutdown: " + ex.getMessage());
}
}).start();
return true;
}

@Command(
command = "deleteprivmsg",
description = "Shutdown the bot",
@@ -144,7 +143,7 @@ public class Moderation extends Module implements Fast{
try {
IPrivateChannel privateChannel = event.getAuthor().getOrCreatePMChannel();
List<IMessage> messageList = privateChannel.getMessageHistory(Integer.parseInt(args[0]));
for (IMessage message: messageList) {
for (IMessage message : messageList) {
if (message.getAuthor().isBot()) {
BotUtils.deleteMessageOne(message);
}
@@ -156,12 +155,14 @@ public class Moderation extends Module implements Fast{
}).start();
return true;
}

@LanguageMethod(
languagestringcount = 1
languagestringcount = 2
)
@Override
public void setdefaultLanguage() {
//Deletion
DRIVER.setProperty(DEF_LANG, "del_topic", "Deletion %1s of %2s");
DRIVER.setProperty(DEF_LANG, "del_wait_success", "Deletion invoked... Wait until messages disapear.");
}
}

Loading…
Cancel
Save