Translation for Role and Rules command

This commit is contained in:
GregTCLTK 2019-12-11 19:43:08 +01:00
parent d2fb3a96ff
commit 6649f0b092
No known key found for this signature in database
GPG key ID: A91BADE5C070FF67
4 changed files with 72 additions and 38 deletions

View file

@ -32,8 +32,8 @@ public class RoleCommand implements Command {
}
}
event.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("✅ Successfully added role(s) ✅")
.setDescription("I successfully added " + event.getMessage().getMentionedRoles().size() + " roles to " + event.getMessage().getMentionedMembers().size() + " members.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.role.add.success.title", ""))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.role.add.success.description", String.valueOf(event.getMessage().getMentionedRoles().size()), String.valueOf(event.getMessage().getMentionedMembers().size())))
.build()).queue();
}
break;
@ -54,8 +54,8 @@ public class RoleCommand implements Command {
}
}
event.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("✅ Successfully removed role(s) ✅")
.setDescription("I successfully removed " + event.getMessage().getMentionedRoles().size() + " roles from " + event.getMessage().getMentionedMembers().size() + " members.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.role.remove.success.title", ""))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.role.remove.success.description", String.valueOf(event.getMessage().getMentionedRoles().size()), String.valueOf(event.getMessage().getMentionedMembers().size())))
.build()).queue();
}
break;
@ -78,7 +78,7 @@ public class RoleCommand implements Command {
@Override
public String description() {
return "Adds and removes roles from one or more user";
return MessageEditor.handle("en", "commands.moderation.role.help.description");
}
@Override

View file

@ -22,8 +22,8 @@ public class RulesCommand implements Command {
if (event.getMember().hasPermission(Permission.MANAGE_SERVER) || event.getConfig().getOwners().toString().contains(event.getAuthor().getId())) {
if (event.getGuild().getSelfMember().hasPermission(Permission.MANAGE_ROLES)) {
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("Set up rules")
.setDescription("Welcome to the Hadder rules setup. Please mention the channel in which I should send the rules. Your message should look like: #rules or #verify.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.setup.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.setup.description"))
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(event1 -> {
if (event1.getMessage().getMentionedChannels().size() == 1) {
@ -32,8 +32,8 @@ public class RulesCommand implements Command {
createRules(event, event1, channel);
} catch (Exception e) {
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.ERROR)
.setTitle("Channel not found")
.setDescription("I can't find the specified channel. Please start the setup again.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.channel.error.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.channel.error.description"))
.build()).queue();
}
} else {
@ -42,8 +42,8 @@ public class RulesCommand implements Command {
createRules(event, event1, channel);
} catch (Exception e) {
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.ERROR)
.setTitle("Channel not found")
.setDescription("I can't find the specified channel. Please start the setup again.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.channel.error.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.channel.error.description"))
.build()).queue();
}
}
@ -60,14 +60,14 @@ public class RulesCommand implements Command {
if (channel.getGuild().getId().equals(event1.getGuild().getId())) {
if (event.getGuild().getSelfMember().hasPermission(channel, Permission.MESSAGE_WRITE)) {
event1.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("Rules")
.setDescription("The channel was successfully set to " + channel.getName() + ". Please send me the rules now.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.rules.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.rules.title", channel.getName()))
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(event2 -> {
String message = event2.getMessage().getContentRaw();
event2.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("Role to assign")
.setDescription("The rules were successfully set. Please send me the name of the role which the user receives after he accepted the rules.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.role.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.role.description"))
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(event3 -> {
if (event3.getMessage().getMentionedRoles().size() == 1) {
@ -78,8 +78,8 @@ public class RulesCommand implements Command {
setRole(event, channel, message, event3, role);
} else {
event3.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.WARNING)
.setTitle("Role does not exist")
.setDescription("The specified role does not exist on this guild.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.role.error.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.role.error.description"))
.build()).queue();
}
}, event.getJDA(), event.getAuthor());
@ -90,8 +90,8 @@ public class RulesCommand implements Command {
}
} else {
event.getTextChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.WARNING)
.setTitle("Wrong Guild")
.setDescription("The mentioned channel must be on this guid!")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.guild.error.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.guild.error.description"))
.build()).queue();
}
}
@ -99,15 +99,15 @@ 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(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("Custom Accept Emote")
.setDescription("The role has been successfully set to " + role.getName() + ". Now send me the emote on which your user should react to to get verified.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emote.accept.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emote.accept.description", role.getName()))
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(event4 -> {
if (event4.getMessage().getEmotes().size() == 1) {
Emote aemote = event4.getMessage().getEmotes().get(0);
event4.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("Custom Decline Emote")
.setDescription("The first emote has been successfully set to " + aemote + ". Please send me now the decline emote.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emote.decline.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emote.decline.title", String.valueOf(aemote)))
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(event5 -> {
Emote demote = event5.getMessage().getEmotes().get(0);
@ -120,29 +120,29 @@ public class RulesCommand implements Command {
rules.addReaction(aemote).queue();
rules.addReaction(demote).queue();
event5.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("Successfully set the rules")
.setDescription("I successfully send the rules in " + channel.getAsMention() + ".")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.success.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.success.description", channel.getAsMention()))
.build()).queue();
} catch (Exception e) {
event5.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.ERROR)
.setTitle("Error")
.setDescription("I can not access the custom emote(s),")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "error"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "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(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.WARNING)
.setTitle("Emotes are equal")
.setDescription("The 1st and 2nd emote equals each other.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emote.error.equal.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emote.error.equal.description"))
.build()).queue();
}
}, event.getJDA(), event.getAuthor());
} else {
String aemote = event4.getMessage().getContentRaw();
event4.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("Custom Decline Emote")
.setDescription("The first emote has been successfully set. Please send me now the decline emote.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emote.decline.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emoji.decline.description"))
.build()).queue();
new EventWaiter().newOnMessageEventWaiter(event5 -> {
String demote = event5.getMessage().getContentRaw();
@ -155,21 +155,21 @@ public class RulesCommand implements Command {
rules.addReaction(aemote).queue();
rules.addReaction(demote).queue();
event5.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.INFO)
.setTitle("Successfully set the rules")
.setDescription("I successfully send the rules in " + channel.getAsMention() + ".")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.success.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.success.description", channel.getAsMention()))
.build()).queue();
} catch (Exception e) {
event5.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.ERROR)
.setTitle("Error")
.setDescription("The given emote can't be used.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "error"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "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(new MessageEditor().setDefaultSettings(MessageEditor.MessageType.WARNING)
.setTitle("Emotes are equal")
.setDescription("The 1st and 2nd emote equals each other.")
.setTitle(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emote.error.equal.title"))
.setDescription(MessageEditor.handle(event.getRethink().getLanguage(event.getAuthor().getId()), "commands.moderation.rules.emote.error.equal.description"))
.build()).queue();
}
}, event.getJDA(), event.getAuthor());
@ -187,7 +187,7 @@ public class RulesCommand implements Command {
@Override
public String description() {
return "Setup the rules on your Discord server";
return MessageEditor.handle("en", "commands.moderation.rules.help.description");
}
@Override

View file

@ -71,4 +71,9 @@ public class MessageEditor {
Locale locale = new Locale(language_code);
return ResourceBundle.getBundle("Translations/Translations", locale).getString(string).replaceAll("%prefix%", "h.").replaceAll("%extra%", extra);
}
public static String handle(String language_code, String string, String extra, String extra_two) {
Locale locale = new Locale(language_code);
return ResourceBundle.getBundle("Translations/Translations", locale).getString(string).replaceAll("%prefix%", "h.").replaceAll("%extra%", extra).replaceAll("%extra_two%", extra_two);
}
}

View file

@ -128,3 +128,32 @@ commands.moderation.regionchange.regions.title = All regions
commands.moderation.regionchange.success.title = Successfully set region
commands.moderation.regionchange.success.description = I successfully set the new server region to %extra%.
commands.moderation.regionchange.help.description = Changes the server region to locked regions.
commands.moderation.role.add.success.title = %extra% Successfully added role(s) %extra%
commands.moderation.role.add.success.description = I successfully added %extra% roles to %extra_two% members.
commands.moderation.role.remove.success.title = %extra% Successfully removed role(s) %extra%
commands.moderation.role.remove.success.description = I successfully removed %extra% roles from %extra_two% members.
commands.moderation.role.help.description = Adds and removes one or more role(s) from one or more user(s)
commands.moderation.rules.setup.title = Set up rules
commands.moderation.rules.setup.description = Welcome to the Hadder rules setup. Please mention the channel in which I should send the rules. Your message should look like: #rules or #verify.
commands.moderation.rules.channel.error.title = Channel not found
commands.moderation.rules.channel.error.description = I can't find the specified channel. Please start the setup again.
commands.moderation.rules.rules.title = Rules
commands.moderation.rules.rules.description = The channel was successfully set to %extra%. Please send me the rules now.
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.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
commands.moderation.rules.emote.accept.description = The role has been successfully set to %extra%. Now send me the emote on which your user should react to to get verified.
commands.moderation.rules.emote.decline.title = Custom Decline Emote
commands.moderation.rules.emote.decline.description = The first emote has been successfully set to %extra%. Please send me now the decline emote.
commands.moderation.rules.success.title = Successfully set the rules
commands.moderation.rules.success.description = I successfully send the rules in %extra%.
commands.moderation.rules.emote.error.access.description = I can not access the custom emote(s).
commands.moderation.rules.emote.error.equal.title = Emotes are equal
commands.moderation.rules.emote.error.equal.description = The 1st and 2nd emote equals each other.
commands.moderation.rules.emoji.decline.description = The first emote has been successfully set. Please send me now the decline emote.
commands.moderation.rules.emoji.error.description = The given emote can't be used.
commands.moderation.rules.help.description = Setup the rules on your Discord server