Drop use of discriminator if none exists

This commit is contained in:
Noi 2023-09-04 16:58:45 -07:00
parent 22421f7517
commit acb052bea3
3 changed files with 17 additions and 8 deletions

View file

@ -40,7 +40,7 @@ public class ExportModule : BotModuleBase {
if (user == null) continue; // User disappeared in the instant between getting list and processing
writer.Write($"● {Common.MonthNames[item.BirthMonth]}-{item.BirthDay:00}: ");
writer.Write(item.UserId);
writer.Write(" " + user.Username + "#" + user.Discriminator);
writer.Write(" " + user.ToString());
if (user.Nickname != null) writer.Write(" - Nickname: " + user.Nickname);
if (item.TimeZone != null) writer.Write(" | Time zone: " + item.TimeZone);
writer.WriteLine();
@ -74,9 +74,9 @@ public class ExportModule : BotModuleBase {
if (user == null) continue; // User disappeared in the instant between getting list and processing
writer.Write(item.UserId);
writer.Write(',');
writer.Write(csvEscape(user.Username + "#" + user.Discriminator));
writer.Write(csvEscape(user.ToString()));
writer.Write(',');
if (user.Nickname != null) writer.Write(user.Nickname);
if (user.Nickname != null) writer.Write(csvEscape(user.Nickname));
writer.Write(',');
writer.Write($"{Common.MonthNames[item.BirthMonth]}-{item.BirthDay:00}");
writer.Write(',');

View file

@ -19,11 +19,19 @@ static class Common {
return result.ToString();
}
var username = escapeFormattingCharacters(member.Username);
if (member.Nickname != null) {
return $"**{escapeFormattingCharacters(member.Nickname)}** ({username}#{member.Discriminator})";
// We do a little bit of special formatting here to try to emphasize the username/nickname over the discriminator
if (member.DiscriminatorValue == 0) {
if (member.Nickname != null) {
return $"**{escapeFormattingCharacters(member.Nickname)}** ({member.Username})";
}
return member.Username;
} else {
var username = escapeFormattingCharacters(member.Username);
if (member.Nickname != null) {
return $"**{escapeFormattingCharacters(member.Nickname)}** ({username}#{member.Discriminator})";
}
return $"**{username}**" + (member.DiscriminatorValue == 0 ? $"#{member.Discriminator}" : "");
}
return $"**{username}**#{member.Discriminator}";
}
public static Dictionary<int, string> MonthNames { get; } = new() {

View file

@ -79,7 +79,8 @@ class ShardManager : IDisposable {
DefaultRetryMode = RetryMode.Retry502 | RetryMode.RetryTimeouts,
GatewayIntents = GatewayIntents.Guilds | GatewayIntents.GuildMembers,
SuppressUnknownDispatchWarnings = true,
LogGatewayIntentWarnings = false
LogGatewayIntentWarnings = false,
FormatUsersInBidirectionalUnicode = false
};
var services = new ServiceCollection()
.AddSingleton(s => new ShardInstance(this, s))