mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-24 09:24:12 +00:00
Drop use of discriminator if none exists
This commit is contained in:
parent
22421f7517
commit
acb052bea3
3 changed files with 17 additions and 8 deletions
|
@ -40,7 +40,7 @@ public class ExportModule : BotModuleBase {
|
||||||
if (user == null) continue; // User disappeared in the instant between getting list and processing
|
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($"● {Common.MonthNames[item.BirthMonth]}-{item.BirthDay:00}: ");
|
||||||
writer.Write(item.UserId);
|
writer.Write(item.UserId);
|
||||||
writer.Write(" " + user.Username + "#" + user.Discriminator);
|
writer.Write(" " + user.ToString());
|
||||||
if (user.Nickname != null) writer.Write(" - Nickname: " + user.Nickname);
|
if (user.Nickname != null) writer.Write(" - Nickname: " + user.Nickname);
|
||||||
if (item.TimeZone != null) writer.Write(" | Time zone: " + item.TimeZone);
|
if (item.TimeZone != null) writer.Write(" | Time zone: " + item.TimeZone);
|
||||||
writer.WriteLine();
|
writer.WriteLine();
|
||||||
|
@ -74,9 +74,9 @@ public class ExportModule : BotModuleBase {
|
||||||
if (user == null) continue; // User disappeared in the instant between getting list and processing
|
if (user == null) continue; // User disappeared in the instant between getting list and processing
|
||||||
writer.Write(item.UserId);
|
writer.Write(item.UserId);
|
||||||
writer.Write(',');
|
writer.Write(',');
|
||||||
writer.Write(csvEscape(user.Username + "#" + user.Discriminator));
|
writer.Write(csvEscape(user.ToString()));
|
||||||
writer.Write(',');
|
writer.Write(',');
|
||||||
if (user.Nickname != null) writer.Write(user.Nickname);
|
if (user.Nickname != null) writer.Write(csvEscape(user.Nickname));
|
||||||
writer.Write(',');
|
writer.Write(',');
|
||||||
writer.Write($"{Common.MonthNames[item.BirthMonth]}-{item.BirthDay:00}");
|
writer.Write($"{Common.MonthNames[item.BirthMonth]}-{item.BirthDay:00}");
|
||||||
writer.Write(',');
|
writer.Write(',');
|
||||||
|
|
10
Common.cs
10
Common.cs
|
@ -19,11 +19,19 @@ static class Common {
|
||||||
return result.ToString();
|
return result.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
var username = escapeFormattingCharacters(member.Username);
|
||||||
if (member.Nickname != null) {
|
if (member.Nickname != null) {
|
||||||
return $"**{escapeFormattingCharacters(member.Nickname)}** ({username}#{member.Discriminator})";
|
return $"**{escapeFormattingCharacters(member.Nickname)}** ({username}#{member.Discriminator})";
|
||||||
}
|
}
|
||||||
return $"**{username}**#{member.Discriminator}";
|
return $"**{username}**" + (member.DiscriminatorValue == 0 ? $"#{member.Discriminator}" : "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<int, string> MonthNames { get; } = new() {
|
public static Dictionary<int, string> MonthNames { get; } = new() {
|
||||||
|
|
|
@ -79,7 +79,8 @@ class ShardManager : IDisposable {
|
||||||
DefaultRetryMode = RetryMode.Retry502 | RetryMode.RetryTimeouts,
|
DefaultRetryMode = RetryMode.Retry502 | RetryMode.RetryTimeouts,
|
||||||
GatewayIntents = GatewayIntents.Guilds | GatewayIntents.GuildMembers,
|
GatewayIntents = GatewayIntents.Guilds | GatewayIntents.GuildMembers,
|
||||||
SuppressUnknownDispatchWarnings = true,
|
SuppressUnknownDispatchWarnings = true,
|
||||||
LogGatewayIntentWarnings = false
|
LogGatewayIntentWarnings = false,
|
||||||
|
FormatUsersInBidirectionalUnicode = false
|
||||||
};
|
};
|
||||||
var services = new ServiceCollection()
|
var services = new ServiceCollection()
|
||||||
.AddSingleton(s => new ShardInstance(this, s))
|
.AddSingleton(s => new ShardInstance(this, s))
|
||||||
|
|
Loading…
Reference in a new issue