Tweak default uncached mention lookup and member caching

This commit is contained in:
Vankka 2024-08-10 14:12:30 +03:00
parent 803eb9af3f
commit 189d8375cd
No known key found for this signature in database
GPG Key ID: 62E48025ED4E7EBB
3 changed files with 5 additions and 4 deletions

View File

@ -33,7 +33,7 @@ public class MemberCachingConfig {
@Comment("If all members should be cached\n" @Comment("If all members should be cached\n"
+ "Requires the \"Server Members Intent\"") + "Requires the \"Server Members Intent\"")
public boolean all = false; public boolean all = true;
@Comment("If members should be cached at startup\n" @Comment("If members should be cached at startup\n"
+ "Requires the \"Server Members Intent\"") + "Requires the \"Server Members Intent\"")

View File

@ -83,8 +83,9 @@ public class MinecraftToDiscordChatConfig implements IMessageConfig {
public boolean users = true; public boolean users = true;
@Comment("If uncached users should be looked up from the Discord API when a mention (\"@something\") occurs in chat.\n" @Comment("If uncached users should be looked up from the Discord API when a mention (\"@something\") occurs in chat.\n"
+ "The player needs the discordsrv.mention.lookup.user permission for uncached members to be looked up") + "The player needs the discordsrv.mention.lookup.user permission for uncached members to be looked up\n"
public boolean uncachedUsers = true; + "This WILL cause sending messages to be delayed")
public boolean uncachedUsers = false;
@Comment("If @everyone and @here mentions should be enabled\n" @Comment("If @everyone and @here mentions should be enabled\n"
+ "The player needs the discordsrv.mention.everyone permission to render the mention and trigger a notification") + "The player needs the discordsrv.mention.everyone permission to render the mention and trigger a notification")

View File

@ -56,7 +56,7 @@ import java.util.stream.Collectors;
public class MentionCachingModule extends AbstractModule<DiscordSRV> { public class MentionCachingModule extends AbstractModule<DiscordSRV> {
private static final Pattern USER_MENTION_PATTERN = Pattern.compile("@[a-z0-9_.]{2,32}"); private static final Pattern USER_MENTION_PATTERN = Pattern.compile("(?<!<)@[a-z0-9_.]{2,32}");
private final Map<Long, Map<Long, CachedMention>> memberMentions = new ConcurrentHashMap<>(); private final Map<Long, Map<Long, CachedMention>> memberMentions = new ConcurrentHashMap<>();
private final Map<Long, Cache<String, CachedMention>> memberMentionsCache = new ConcurrentHashMap<>(); private final Map<Long, Cache<String, CachedMention>> memberMentionsCache = new ConcurrentHashMap<>();