Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3a4cbd6
Language System is now added.
DxsSucuk Sep 15, 2022
8abdb7b
Merge branch 'master' into feature/multi-language
DxsSucuk Sep 15, 2022
1592f95
Merge branch 'master' into feature/multi-language
DxsSucuk Sep 21, 2022
35d3b9d
Continued description replacement.
DxsSucuk Sep 21, 2022
5bec6a6
Translation start of InstagramNotifier.
DxsSucuk Sep 21, 2022
b0ae5f6
More translations!
DxsSucuk Sep 21, 2022
8e8a33a
Merge branch 'master' into feature/multi-language
DxsSucuk Sep 21, 2022
6dcd684
Refactoring.
DxsSucuk Sep 21, 2022
29641e6
New Language-File.
DxsSucuk Sep 21, 2022
62175b1
Translation
DxsSucuk Sep 22, 2022
4afa0ef
Language adding
DxsSucuk Sep 26, 2022
854e84f
Merge branch 'master' into feature/multi-language
DxsSucuk Sep 29, 2022
db79d47
Merge branch 'master' into feature/multi-language
DxsSucuk Sep 30, 2022
e763bd2
Merge branch 'master' into feature/multi-language
DxsSucuk Sep 30, 2022
a51cef4
Merge branch 'master' into feature/multi-language
DxsSucuk Oct 4, 2022
c366065
Merge branch 'master' into feature/multi-language
DxsSucuk Oct 4, 2022
eb152e4
Merge branch 'master' into feature/multi-language
DxsSucuk Oct 4, 2022
ff41b0b
Merge branch 'master' into feature/multi-language
DxsSucuk Oct 5, 2022
c5c33ec
Cleanup of the Language System.
DxsSucuk Oct 5, 2022
348571e
Cleaning and fixing of the Language-System.
DxsSucuk Oct 5, 2022
0e29b10
Cleaning and improving of the Language-System.
DxsSucuk Oct 5, 2022
235cf74
Renamed Methods to make it simpler.
DxsSucuk Oct 7, 2022
845fe03
Documentation.
DxsSucuk Oct 7, 2022
693f42c
Clean up.
DxsSucuk Oct 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions languages/en_EN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
language:
name: "English (UK)"
locale: "en_GB"
version: "1.9.7"
author: "Presti"
command:
perform:
cooldown: "You are on cooldown!"
error: "There was an error while executing the Command!"
internalError: "An error occurred while performing the Command!\nIf this continues to happen please contact our support!\n<https://support.ree6.de>"
notFound: "That Command couldn't be found"
blocked: "This Command is blocked!"
slashNotSupported: "This Command doesn't support Slash Commands yet!"
onlySlashSupported: "This Command only supports Slash-Commands!"
description:
birthday: "Let the bot remember your Birthday."
instagramNotifier: "Manage your Instagram-Notifier!"
redditNotifier: "Manage your Reddit-Notifier!"
twitch: "Manage your Twitch-Notifier!"
twitterNotifier: "Manage your Twitter-Notifier!"
youtubeNotifier: "Manage your Youtube-Notifier!"
anime: "Search for animes on kitsu.io!"
randomcat: "Shows random Cat Images, from thecatapi.com."
cringe: "Let shrek tell them that their message was cringe!"
cringe_slash: "Let shrek tell them that their message was not funny!"
randomdog: "Shows random Dog Images, from dog.ceo."
funFact: "Just some random facts!"
funnyCrypto: "Wanna see at how much the funniest cryptocurrencies are worth?"
hornyjail: "Put someone into the Horny-Jail"
hug: "Hug someone you like!"
kiss: "Kiss someone!"
manga: "Search for mangas on kitsu.io!"
meme: "Wanna see some Memes?"
monke: "Shows an Image of a Monke."
ping: "Pong!"
8ball: "Let the Magic 8Ball decide the faith of your Question."
record: "Record the voice channel!"
shiba: "Shows a random shiba image, from shiba.online."
slap: "Slap someone in the face!"
twitter: "Create a \"realistic\" looking Tweet!"
waifu: "Wanna see some Waifus or Husbandos?"
addon: "Only meant for Developers, used to reload or load new Addons."
test: "Just a test command."
credits: "See the beautiful and lovely team working behind Ree6!"
help: "Shows a list of every Command!"
info: "Shows user specific information."
invite: "Retrieve an Invite link for Ree6!"
optout: "Opts you out of any data collection on this Guild."
server: "See server specific information."
stats: "See Stats of Ree6!"
support: "Get an Invite to the Support Server of Ree6!"
leaderboard: "Shows you the Rank Leaderboard of the current Server"
level: "Show your own Level or the Level of another User in the Guild."
ban: "Ban an specific User from the Guild."
blacklist: "Manage the Filters of the Guild."
clear: "Clear a specific amount of Messages from the current Chat."
clearData: "Clear every stored Invite and replace it with the current ones."
embedSender: "Send an Embed Message."
import: "Import data from another Bot."
kick: "Kick an specific User from the Guild."
mute: "Mute an specific User from the Guild."
prefix: "Change the Prefix of the Guild."
setup: "Setup specific features for the Guild."
unban: "Unban an specific User from the Guild."
unmute: "Unmute an specific User from the Guild."
webinterface: "Shows the url to the Webinterface of Ree6."
clearQueue: "Clear the Song-Queue for the Guild."
disconnect: "Disconnect the Bot from the Voice-Channel."
loop: "Loop the current Song."
lyrics: "Shows the Lyrics of the current playing Track."
pause: "Pause the current Track."
play: "Play or add a Track to the Queue."
resume: "Resume the current Track."
seek: "Seek to a specific Time in the current Track."
shuffle: "Shuffle the Song-Queue."
skip: "Skip the some Tracks in the Song-Queue."
songinfo: "Shows information about the current playing Track."
songlist: "Shows the Song-Queue."
stop: "Stop the current Track."
volume: "Change the Volume of the current Track."
nsfw: "Shows a random NSFW Image."
rule34: "Shows a random Rule34 Image."
message:
default:
usage: "Please use {0}{1}."
needPermission: "Looks like I do not have the Permission `{0}`!"
noMention:
user: "Please mention a user!"
role: "Please mention a role!"
channel: "Please mention a channel!"
onlyNSFW: "This Command can only be used in NSFW Channels!"
invalidQuery: "Please provide a valid Query!"
birthday:
added:
self: "Your Birthday has been added!"
other: "The Birthday of {0} has been added!"
noPerms: "You don't have the permission to add a Birthday!"
removed:
self: "Your Birthday has been removed!"
other: "The Birthday of {0} has been removed!"
noPerms: "You don't have the permission to remove a Birthday!"
other:
dateError: "Please use a valid Date!\nNote that we use the the format dd.MM.yyyy (day.month.year)!"
instagramNotifier:
anime:
searching: "Searching for Anime..."
found: "Anime found!"
category:
info: "Used to gather information or provide information."
moderation: "Moderation Tools that can help you manager Users or prevent rule breaking on the Server."
music: "Music utilities that allow you to have fun with your friends through the power of music!"
fun: "Fun utilities that give you the power to do dumb stuff because you can!"
level: "Leveling Tools that allow you to keep track of progress on the Server."
community: "Community Tools that allow you to interact with your community."
nsfw: "NSFW stuff that you can only use in NSFW Channels."
hidden: "Hidden Commands that are only visible to the Owner of the Bot."
16 changes: 8 additions & 8 deletions src/main/java/de/presti/ree6/commands/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ public enum Category {
/**
* Category used for informativ Commands.
*/
INFO("re_icon_info",1019221661070917632L, false, "Used to gather information or provide information."),
INFO("re_icon_info",1019221661070917632L, false, "category.info"),
/**
* Category used for moderativ Commands.
*/
MOD("re_icon_mod",1019221710932803624L, false, "Moderation Tools that can help you manager Users or prevent rule breaking on the Server."),
MOD("re_icon_mod",1019221710932803624L, false, "category.moderation"),
/**
* Category used for music Commands.
*/
MUSIC("re_icon_music",1019221781762023575L, false, "Music utilities that allow you to have fun with your friends through the power of music!"),
MUSIC("re_icon_music",1019221781762023575L, false, "category.music"),
/**
* Category used for fun Commands.
*/
FUN("re_icon_fun",1019221814670532628L, false, "Fun utilities that give you the power to do dumb stuff because you can!"),
FUN("re_icon_fun",1019221814670532628L, false, "category.fun"),
/**
* Category used for level Commands.
*/
LEVEL("re_icon_level",1019221845972635809L, false, "Leveling Tools that allow you to keep track of progress on the Server."),
LEVEL("re_icon_level",1019221845972635809L, false, "category.level"),
/**
* Category used for community Commands.
*/
COMMUNITY("re_icon_community",1019221884686057552L, false, "Community Tools that allow you to interact with your community."),
COMMUNITY("re_icon_community",1019221884686057552L, false, "category.community"),
/**
* Category used for NSFW Commands.
*/
NSFW("re_icon_nsfw",1019221923466584166L, false, "NSFW stuff that you can only use in NSFW Channels."),
NSFW("re_icon_nsfw",1019221923466584166L, false, "category.nsfw"),
/**
* Category used for admin Commands.
*/
HIDDEN("re_icon_hidden",1019221957817933865L, false, "Hidden Commands that are only visible to the Owner of the Bot.");
HIDDEN("re_icon_hidden",1019221957817933865L, false, "category.hidden");

private final String icon;
private final long iconId;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/de/presti/ree6/commands/CommandEvent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.presti.ree6.commands;

import de.presti.ree6.language.LanguageService;
import de.presti.ree6.main.Main;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
Expand Down Expand Up @@ -134,6 +135,16 @@ public void reply(MessageCreateData message, int deleteSecond) {
Main.getInstance().getCommandManager().sendMessage(message, deleteSecond, getChannel(), getInteractionHook());
}

/**
* Get a Message from the Guild specific Language Setting.
* @param key the Key of the Message.
* @param parameters the Parameters to replace in the Message.
* @return the Message.
*/
public String getResource(String key, Object... parameters) {
return LanguageService.getByEvent(this, key, parameters);
}

/**
* Get the {@link Member} Entity associated with the Event.
* @return the {@link Member} Entity.
Expand Down
45 changes: 29 additions & 16 deletions src/main/java/de/presti/ree6/commands/CommandManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,19 @@
import de.presti.ree6.commands.interfaces.ICommand;
import de.presti.ree6.main.Main;
import de.presti.ree6.utils.data.ArrayUtil;
import de.presti.ree6.language.LanguageService;
import de.presti.ree6.utils.others.ThreadUtil;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
import net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion;
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
import net.dv8tion.jda.api.interactions.DiscordLocale;
import net.dv8tion.jda.api.interactions.InteractionHook;
import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
Expand Down Expand Up @@ -81,17 +86,25 @@ public void addSlashCommand(JDA jda) {
commandData = new CommandDataImpl(command.getClass().getAnnotation(Command.class).name(), command.getClass().getAnnotation(Command.class).description());
}

if (commandData != null) {
for (DiscordLocale discordLocale : DiscordLocale.values()) {
if (!LanguageService.languageResources.containsKey(discordLocale)) continue;

if (commandAnnotation.category() == Category.MOD) {
commandData.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR));
String description = LanguageService.getByLocale(discordLocale, command.getClass().getAnnotation(Command.class).description() + "_slash");
if (description.equals("Missing language resource!")) {
description = LanguageService.getByLocale(discordLocale, command.getClass().getAnnotation(Command.class).description());
}

commandData.setGuildOnly(true);
commandData.setNameLocalization(discordLocale, description);
}

//noinspection ResultOfMethodCallIgnored
listUpdateAction.addCommands(commandData);
if (commandAnnotation.category() == Category.MOD) {
commandData.setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.ADMINISTRATOR));
}

commandData.setGuildOnly(true);

//noinspection ResultOfMethodCallIgnored
listUpdateAction.addCommands(commandData);
}

listUpdateAction.queue();
Expand Down Expand Up @@ -170,10 +183,10 @@ public boolean perform(Member member, Guild guild, String messageContent, Messag

// Check if it is a Slash Command or not.
if (slashCommandInteractionEvent != null) {
sendMessage("You are on cooldown!", 5, textChannel, slashCommandInteractionEvent.getHook().setEphemeral(true));
sendMessage(LanguageService.getByGuild(guild, "command.perform.cooldown"), 5, textChannel, slashCommandInteractionEvent.getHook().setEphemeral(true));
deleteMessage(message, slashCommandInteractionEvent.getHook().setEphemeral(true));
} else if (messageContent.toLowerCase().startsWith(Main.getInstance().getSqlConnector().getSqlWorker().getSetting(guild.getId(), "chatprefix").getStringValue().toLowerCase())) {
sendMessage("You are on cooldown!", 5, textChannel, null);
sendMessage(LanguageService.getByGuild(guild, "command.perform.cooldown"), 5, textChannel, null);
deleteMessage(message, null);
}

Expand All @@ -193,12 +206,12 @@ public boolean perform(Member member, Guild guild, String messageContent, Messag
}

// Check if this is a Developer build, if not then cooldown the User.
if (BotWorker.getVersion() != BotVersion.DEVELOPMENT_BUILD) {
if (!BotWorker.getVersion().isDebug()) {
ThreadUtil.createNewThread(x -> ArrayUtil.commandCooldown.remove(member.getUser().getId()), null, Duration.ofSeconds(5), false, false);
}

// Add them to the Cooldown.
if (!ArrayUtil.commandCooldown.contains(member.getUser().getId()) && BotWorker.getVersion() != BotVersion.DEVELOPMENT_BUILD) {
if (!ArrayUtil.commandCooldown.contains(member.getUser().getId()) && !BotWorker.getVersion().isDebug()) {
ArrayUtil.commandCooldown.add(member.getUser().getId());
}

Expand All @@ -219,7 +232,7 @@ public boolean perform(Member member, Guild guild, String messageContent, Messag
private boolean performMessageCommand(Member member, Guild guild, String messageContent, Message message, MessageChannelUnion textChannel) {
// Check if the Message is null.
if (message == null) {
sendMessage("There was an error while executing the Command!", 5, textChannel, null);
sendMessage(LanguageService.getByGuild(guild, "command.perform.error"), 5, textChannel, null);
return false;
}

Expand All @@ -238,14 +251,14 @@ private boolean performMessageCommand(Member member, Guild guild, String message

// Check if there is even a Command with that name.
if (command == null) {
sendMessage("That Command couldn't be found", 5, textChannel, null);
sendMessage(LanguageService.getByGuild(guild, "command.perform.notFound"), 5, textChannel, null);
return false;
}

// Check if the Command is blacklisted.
if (!Main.getInstance().getSqlConnector().getSqlWorker().getSetting(guild.getId(), "command_" + command.getClass().getAnnotation(Command.class).name().toLowerCase()).getBooleanValue() &&
command.getClass().getAnnotation(Command.class).category() != Category.HIDDEN) {
sendMessage("This Command is blocked!", 5, textChannel, null);
sendMessage(LanguageService.getByGuild(guild, "command.perform.blocked"), 5, textChannel, null);
return false;
}

Expand All @@ -270,13 +283,13 @@ private boolean performSlashCommand(MessageChannelUnion textChannel, SlashComman

// Check if there is a command with that Name.
if (command == null || slashCommandInteractionEvent.getGuild() == null || slashCommandInteractionEvent.getMember() == null) {
sendMessage("That Command couldn't be found", 5, null, slashCommandInteractionEvent.getHook().setEphemeral(true));
sendMessage(LanguageService.getByGuild(slashCommandInteractionEvent.getGuild(), "command.perform.notFound"), 5, null, slashCommandInteractionEvent.getHook().setEphemeral(true));
return false;
}

// Check if the command is blocked or not.
if (!Main.getInstance().getSqlConnector().getSqlWorker().getSetting(slashCommandInteractionEvent.getGuild().getId(), "command_" + command.getClass().getAnnotation(Command.class).name().toLowerCase()).getBooleanValue() && command.getClass().getAnnotation(Command.class).category() != Category.HIDDEN) {
sendMessage("This Command is blocked!", 5, null, slashCommandInteractionEvent.getHook().setEphemeral(true));
sendMessage(LanguageService.getByGuild(slashCommandInteractionEvent.getGuild(), "command.perform.blocked"), 5, null, slashCommandInteractionEvent.getHook().setEphemeral(true));
return false;
}

Expand Down
Loading