mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-11-25 12:25:15 +01:00
Add showing replies in Discord -> Minecraft
This commit is contained in:
parent
9c7b065d62
commit
aa8b0a9660
@ -30,6 +30,7 @@ import com.discordsrv.api.discord.entity.channel.DiscordMessageChannel;
|
||||
import com.discordsrv.api.discord.entity.channel.DiscordTextChannel;
|
||||
import com.discordsrv.api.discord.entity.guild.DiscordGuild;
|
||||
import com.discordsrv.api.discord.entity.guild.DiscordGuildMember;
|
||||
import com.discordsrv.api.placeholder.annotation.Placeholder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
@ -71,6 +72,7 @@ public interface ReceivedDiscordMessage extends Snowflake {
|
||||
* @return the jump url
|
||||
*/
|
||||
@NotNull
|
||||
@Placeholder("message_jump_url")
|
||||
String getJumpUrl();
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ public class DiscordToMinecraftChatConfig {
|
||||
|
||||
@Comment("The Discord to Minecraft message format for regular users and bots")
|
||||
@Untranslated(Untranslated.Type.VALUE)
|
||||
public String format = "[ᛩF2Discord&r] [hover:show_text:Tag: %user_tag%&r\nRoles: %user_roles:', '|text:'&7&oNone'%]%user_color%%user_effective_server_name%&r » %message%%message_attachments%";
|
||||
public String format = "[ᛩF2Discord&r] [hover:show_text:Tag: %user_tag%&r\nRoles: %user_roles:', '|text:'&7&oNone'%]%user_color%%user_effective_server_name%&r%message_reply% » %message%%message_attachments%";
|
||||
|
||||
@Comment("The Discord to Minecraft message format for webhook messages (if enabled)")
|
||||
@Untranslated(Untranslated.Type.VALUE)
|
||||
@ -44,6 +44,10 @@ public class DiscordToMinecraftChatConfig {
|
||||
@Untranslated(Untranslated.Type.VALUE)
|
||||
public String attachmentFormat = " [hover:show_text:Open %file_name% in browser][click:open_url:%file_url%]&a[&f%file_name%&a]&r";
|
||||
|
||||
@Comment("Reply format")
|
||||
@Untranslated(Untranslated.Type.VALUE)
|
||||
public String replyFormat = " [hover:show_text:%message%][click:open_url:%message_jump_url%]replying to %user_color|text:''%%user_effective_server_name|user_effective_name%&r";
|
||||
|
||||
// TODO: more info on regex pairs (String#replaceAll)
|
||||
@Comment("Regex filters for Discord message contents (this is the %message% part of the \"format\" option)")
|
||||
@Untranslated(Untranslated.Type.VALUE)
|
||||
|
@ -257,6 +257,29 @@ public class ReceivedDiscordMessageImpl implements ReceivedDiscordMessage {
|
||||
// Placeholders
|
||||
//
|
||||
|
||||
@Placeholder("message_reply")
|
||||
public Component _reply(BaseChannelConfig config, @PlaceholderRemainder String suffix) {
|
||||
if (replyingTo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String content = replyingTo.getContent();
|
||||
if (content == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Component component = discordSRV.componentFactory().minecraftSerializer().serialize(content);
|
||||
|
||||
String replyFormat = config.discordToMinecraft.replyFormat;
|
||||
return ComponentUtil.fromAPI(
|
||||
discordSRV.componentFactory().textBuilder(replyFormat)
|
||||
.applyPlaceholderService()
|
||||
.addPlaceholder("message", component)
|
||||
.addContext(replyingTo.getMember(), replyingTo.getAuthor(), replyingTo)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@Placeholder("message_attachments")
|
||||
public Component _attachments(BaseChannelConfig config, @PlaceholderRemainder String suffix) {
|
||||
String attachmentFormat = config.discordToMinecraft.attachmentFormat;
|
||||
|
Loading…
Reference in New Issue
Block a user