mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-11-01 00:29:24 +00:00
Add replies
This commit is contained in:
parent
0a74b422a0
commit
35dec7ce8d
|
@ -15,6 +15,7 @@ import org.bukkit.ChatColor;
|
||||||
import org.javacord.api.DiscordApi;
|
import org.javacord.api.DiscordApi;
|
||||||
import org.javacord.api.DiscordApiBuilder;
|
import org.javacord.api.DiscordApiBuilder;
|
||||||
import org.javacord.api.entity.channel.TextChannel;
|
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.MessageAttachment;
|
||||||
import org.javacord.api.entity.message.MessageAuthor;
|
import org.javacord.api.entity.message.MessageAuthor;
|
||||||
import org.javacord.api.entity.server.Server;
|
import org.javacord.api.entity.server.Server;
|
||||||
|
@ -65,11 +66,19 @@ public class DiscordBridge {
|
||||||
if (content.toLowerCase().startsWith(prefix)) {
|
if (content.toLowerCase().startsWith(prefix)) {
|
||||||
COMMAND_MANAGER.parse(content, user.get(), server.get(), message.getChannel(), prefix);
|
COMMAND_MANAGER.parse(content, user.get(), server.get(), message.getChannel(), prefix);
|
||||||
} else {
|
} 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);
|
String format = MainConfig.getString((isAdmin) ? ConfigurationEntry.DISCORD_ADMIN_FORMAT : ConfigurationEntry.DISCORD_FORMAT);
|
||||||
format = format.replace("{TAG}", author.getDiscriminatedName());
|
format = format.replace("{TAG}", author.getDiscriminatedName());
|
||||||
format = format.replace("{USERNAME}", author.getName());
|
format = format.replace("{USERNAME}", author.getName());
|
||||||
BaseComponent[] components = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', String.format(format, content)));
|
BaseComponent[] components = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', String.format(format, content)));
|
||||||
TextComponent component = new TextComponent("");
|
TextComponent component = new TextComponent(reply);
|
||||||
|
|
||||||
for (BaseComponent baseComponent : components) {
|
for (BaseComponent baseComponent : components) {
|
||||||
component.addExtra(baseComponent);
|
component.addExtra(baseComponent);
|
||||||
|
|
Loading…
Reference in a new issue