mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-12-22 22:44:58 +00:00
Add replies
This commit is contained in:
parent
0a74b422a0
commit
35dec7ce8d
1 changed files with 10 additions and 1 deletions
|
@ -15,6 +15,7 @@ import org.bukkit.ChatColor;
|
|||
import org.javacord.api.DiscordApi;
|
||||
import org.javacord.api.DiscordApiBuilder;
|
||||
import org.javacord.api.entity.channel.TextChannel;
|
||||
import org.javacord.api.entity.message.Message;
|
||||
import org.javacord.api.entity.message.MessageAttachment;
|
||||
import org.javacord.api.entity.message.MessageAuthor;
|
||||
import org.javacord.api.entity.server.Server;
|
||||
|
@ -65,11 +66,19 @@ public class DiscordBridge {
|
|||
if (content.toLowerCase().startsWith(prefix)) {
|
||||
COMMAND_MANAGER.parse(content, user.get(), server.get(), message.getChannel(), prefix);
|
||||
} else {
|
||||
Optional<Message> referenced = message.getMessage().getReferencedMessage();
|
||||
|
||||
String reply = "";
|
||||
if(referenced.isPresent()) {
|
||||
Message replyingTo = referenced.get();
|
||||
reply = String.format("┌ %s\t%s\n", replyingTo.getAuthor().getDiscriminatedName(), replyingTo.getReadableContent());
|
||||
}
|
||||
|
||||
String format = MainConfig.getString((isAdmin) ? ConfigurationEntry.DISCORD_ADMIN_FORMAT : ConfigurationEntry.DISCORD_FORMAT);
|
||||
format = format.replace("{TAG}", author.getDiscriminatedName());
|
||||
format = format.replace("{USERNAME}", author.getName());
|
||||
BaseComponent[] components = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', String.format(format, content)));
|
||||
TextComponent component = new TextComponent("");
|
||||
TextComponent component = new TextComponent(reply);
|
||||
|
||||
for (BaseComponent baseComponent : components) {
|
||||
component.addExtra(baseComponent);
|
||||
|
|
Loading…
Reference in a new issue