Change mentioning to usernames, add insert to mention to default Discord to Minecraft configuration

This commit is contained in:
Vankka 2024-07-20 18:52:12 +03:00
parent a28a55c9f0
commit 023d5d41d5
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB
2 changed files with 8 additions and 2 deletions

View File

@ -35,7 +35,7 @@ public class DiscordToMinecraftChatConfig {
public boolean enabled = true;
@Comment("The Discord to Minecraft message format for regular users and bots")
public String format = "[[color:#5865F2]Discord[color]] [hover:show_text:Username: @%user_tag%\nRoles: %user_roles:', '|text:'[color:gray][italics:on]None[color][italics]'%]%user_color%%user_effective_server_name%[color][hover]%message_reply% » %message%%message_attachments%";
public String format = "[[color:#5865F2]Discord[color]] [hover:show_text:Username: @%user_tag% [italics:on](Shift+Click to mention)[italics:off]\nRoles: %user_roles:', '|text:'[color:gray][italics:on]None[color][italics]'%][insert:@%user_tag%]%user_color%%user_effective_server_name%[color][hover]%message_reply% » %message%%message_attachments%";
@Comment("The Discord to Minecraft message format for webhook messages (if enabled)")
public String webhookFormat = "[[color:#5865F2]Discord[color]] [hover:show_text:Bot message]%user_effective_name%[hover] » %message%%message_attachments%";

View File

@ -28,6 +28,7 @@ import com.github.benmanes.caffeine.cache.Cache;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.entities.channel.concrete.Category;
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import net.dv8tion.jda.api.events.channel.ChannelCreateEvent;
import net.dv8tion.jda.api.events.channel.ChannelDeleteEvent;
@ -149,7 +150,7 @@ public class MentionCachingModule extends AbstractModule<DiscordSRV> {
private CachedMention convertMember(Member member) {
return new CachedMention(
"@" + member.getEffectiveName(),
"@" + member.getUser().getName(),
member.getAsMention(),
member.getIdLong()
);
@ -230,6 +231,11 @@ public class MentionCachingModule extends AbstractModule<DiscordSRV> {
return channelMentions.computeIfAbsent(guild.getIdLong(), key -> {
Map<Long, CachedMention> mentions = new LinkedHashMap<>();
for (GuildChannel channel : guild.getChannels()) {
if (channel instanceof Category) {
// Not mentionable
continue;
}
mentions.put(channel.getIdLong(), convertChannel(channel));
}
return mentions;