Add discriminators back for users who still have them

This commit is contained in:
Vankka 2023-06-22 20:03:03 +03:00
parent e45e7c921c
commit 2f2b852b0d
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0
2 changed files with 11 additions and 6 deletions

View File

@ -90,12 +90,17 @@ public interface DiscordUser extends JDAEntity<User>, Snowflake, Mentionable {
String getEffectiveAvatarUrl();
/**
* Gets the Discord user's username followed by a {@code #} and their discriminator.
* @return the Discord user's username and discriminator in the following format {@code Username#1234}
* Gets the Discord user's username, including discriminator if any.
* @return the Discord user's username
*/
@Deprecated
@Placeholder("user_tag")
default String getAsTag() {
return getUsername() + "#" + getDiscriminator();
String username = getUsername();
String discriminator = getDiscriminator();
if (!discriminator.replace("0", "").isEmpty()) {
username = username + "#" + discriminator;
}
return username;
}
/**

View File

@ -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 = "[&#5865F2Discord&r] [hover:show_text:Username: @%user_name%&r\nRoles: %user_roles:', '|text:'&7&oNone'%]%user_color%%user_effective_server_name%&r%message_reply% » %message%%message_attachments%";
public String format = "[&#5865F2Discord&r] [hover:show_text:Username: @%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)
@ -64,7 +64,7 @@ public class DiscordToMinecraftChatConfig {
public Format role = new Format("&#5865f2@%role_name%", "&#5865f2@deleted-role");
public Format channel = new Format("[hover:show_text:Click to go to channel][click:open_url:%channel_jump_url%]&#5865f2#%channel_name%", "&#5865f2#Unknown");
public Format user = new Format("[hover:show_text:Username: @%user_name%&r\nRoles: %user_roles:', '|text:'&7&oNone'%]&#5865f2@%user_effective_server_name|user_effective_name%", "&#5865f2@Unknown user");
public Format user = new Format("[hover:show_text:Username: @%user_tag%&r\nRoles: %user_roles:', '|text:'&7&oNone'%]&#5865f2@%user_effective_server_name|user_effective_name%", "&#5865f2@Unknown user");
public String messageUrl = "[hover:show_text:Click to go to message][click:open_url:%jump_url%]&#5865f2#%channel_name% > ...";