* Init * Clearing up comment on config entry. * Update user entities to remove storage of the setting Co-authored-by: Quin Lynch <lynchquin@gmail.com>pull/2228/head
@@ -187,5 +187,15 @@ namespace Discord | |||||
/// <b>This will still require a stable clock on your system.</b> | /// <b>This will still require a stable clock on your system.</b> | ||||
/// </remarks> | /// </remarks> | ||||
public bool UseInteractionSnowflakeDate { get; set; } = true; | public bool UseInteractionSnowflakeDate { get; set; } = true; | ||||
/// <summary> | |||||
/// Gets or sets if the Rest/Socket user <see cref="object.ToString"/> override formats the string in respect to bidirectional unicode. | |||||
/// </summary> | |||||
/// <remarks> | |||||
/// By default, the returned value will be "?Discord?#1234", to work with bidirectional usernames. | |||||
/// <br/> | |||||
/// If set to <see langword="false"/>, this value will be "Discord#1234". | |||||
/// </remarks> | |||||
public bool FormatUsersInBidirectionalUnicode { get; set; } = true; | |||||
} | } | ||||
} | } |
@@ -107,13 +107,16 @@ namespace Discord | |||||
} | } | ||||
/// <summary> | /// <summary> | ||||
/// Formats a user's username + discriminator while maintaining bidirectional unicode | |||||
/// Formats a user's username + discriminator. | |||||
/// </summary> | /// </summary> | ||||
/// <param name="doBidirectional">To format the string in bidirectional unicode or not</param> | |||||
/// <param name="user">The user whos username and discriminator to format</param> | /// <param name="user">The user whos username and discriminator to format</param> | ||||
/// <returns>The username + discriminator</returns> | /// <returns>The username + discriminator</returns> | ||||
public static string UsernameAndDiscriminator(IUser user) | |||||
public static string UsernameAndDiscriminator(IUser user, bool doBidirectional) | |||||
{ | { | ||||
return $"\u2066{user.Username}\u2069#{user.Discriminator}"; | |||||
return doBidirectional | |||||
? $"\u2066{user.Username}\u2069#{user.Discriminator}" | |||||
: $"{user.Username}#{user.Discriminator}"; | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -36,6 +36,7 @@ namespace Discord.Rest | |||||
/// <inheritdoc /> | /// <inheritdoc /> | ||||
public TokenType TokenType => ApiClient.AuthTokenType; | public TokenType TokenType => ApiClient.AuthTokenType; | ||||
internal bool UseInteractionSnowflakeDate { get; private set; } | internal bool UseInteractionSnowflakeDate { get; private set; } | ||||
internal bool FormatUsersInBidirectionalUnicode { get; private set; } | |||||
/// <summary> Creates a new REST-only Discord client. </summary> | /// <summary> Creates a new REST-only Discord client. </summary> | ||||
internal BaseDiscordClient(DiscordRestConfig config, API.DiscordRestApiClient client) | internal BaseDiscordClient(DiscordRestConfig config, API.DiscordRestApiClient client) | ||||
@@ -49,6 +50,7 @@ namespace Discord.Rest | |||||
_isFirstLogin = config.DisplayInitialLog; | _isFirstLogin = config.DisplayInitialLog; | ||||
UseInteractionSnowflakeDate = config.UseInteractionSnowflakeDate; | UseInteractionSnowflakeDate = config.UseInteractionSnowflakeDate; | ||||
FormatUsersInBidirectionalUnicode = config.FormatUsersInBidirectionalUnicode; | |||||
ApiClient.RequestQueue.RateLimitTriggered += async (id, info, endpoint) => | ApiClient.RequestQueue.RateLimitTriggered += async (id, info, endpoint) => | ||||
{ | { | ||||
@@ -129,8 +129,10 @@ namespace Discord.Rest | |||||
/// <returns> | /// <returns> | ||||
/// A string that resolves to Username#Discriminator of the user. | /// A string that resolves to Username#Discriminator of the user. | ||||
/// </returns> | /// </returns> | ||||
public override string ToString() => Format.UsernameAndDiscriminator(this); | |||||
private string DebuggerDisplay => $"{Format.UsernameAndDiscriminator(this)} ({Id}{(IsBot ? ", Bot" : "")})"; | |||||
public override string ToString() | |||||
=> Format.UsernameAndDiscriminator(this, Discord.FormatUsersInBidirectionalUnicode); | |||||
private string DebuggerDisplay => $"{Format.UsernameAndDiscriminator(this, Discord.FormatUsersInBidirectionalUnicode)} ({Id}{(IsBot ? ", Bot" : "")})"; | |||||
#endregion | #endregion | ||||
#region IUser | #region IUser | ||||
@@ -117,8 +117,8 @@ namespace Discord.WebSocket | |||||
/// <returns> | /// <returns> | ||||
/// The full name of the user. | /// The full name of the user. | ||||
/// </returns> | /// </returns> | ||||
public override string ToString() => Format.UsernameAndDiscriminator(this); | |||||
private string DebuggerDisplay => $"{Format.UsernameAndDiscriminator(this)} ({Id}{(IsBot ? ", Bot" : "")})"; | |||||
public override string ToString() => Format.UsernameAndDiscriminator(this, Discord.FormatUsersInBidirectionalUnicode); | |||||
private string DebuggerDisplay => $"{Format.UsernameAndDiscriminator(this, Discord.FormatUsersInBidirectionalUnicode)} ({Id}{(IsBot ? ", Bot" : "")})"; | |||||
internal SocketUser Clone() => MemberwiseClone() as SocketUser; | internal SocketUser Clone() => MemberwiseClone() as SocketUser; | ||||
} | } | ||||
} | } |