mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-10-16 07:59:57 +00:00
Whitespace and style fixes
This commit is contained in:
parent
81da14a6a8
commit
2977ae61f1
10 changed files with 26 additions and 28 deletions
|
@ -14,8 +14,8 @@ public class BirthdayOverrideModule : BotModuleBase {
|
|||
// TODO possible to use a common base class for shared functionality instead?
|
||||
|
||||
[SlashCommand("set-birthday", "Set a user's birthday on their behalf.")]
|
||||
public async Task OvSetBirthday([Summary(description: HelpOptOvTarget)]SocketGuildUser target,
|
||||
[Summary(description: HelpOptDate)]string date) {
|
||||
public async Task OvSetBirthday([Summary(description: HelpOptOvTarget)] SocketGuildUser target,
|
||||
[Summary(description: HelpOptDate)] string date) {
|
||||
int inmonth, inday;
|
||||
try {
|
||||
(inmonth, inday) = ParseDate(date);
|
||||
|
@ -43,8 +43,8 @@ public class BirthdayOverrideModule : BotModuleBase {
|
|||
}
|
||||
|
||||
[SlashCommand("set-timezone", "Set a user's time zone on their behalf.")]
|
||||
public async Task OvSetTimezone([Summary(description: HelpOptOvTarget)]SocketGuildUser target,
|
||||
[Summary(description: HelpOptZone)]string zone) {
|
||||
public async Task OvSetTimezone([Summary(description: HelpOptOvTarget)] SocketGuildUser target,
|
||||
[Summary(description: HelpOptZone)] string zone) {
|
||||
using var db = new BotDatabaseContext();
|
||||
|
||||
var user = target.GetUserEntryOrNew(db);
|
||||
|
@ -68,7 +68,7 @@ public class BirthdayOverrideModule : BotModuleBase {
|
|||
}
|
||||
|
||||
[SlashCommand("remove-birthday", "Remove a user's birthday information on their behalf.")]
|
||||
public async Task OvRemove([Summary(description: HelpOptOvTarget)]SocketGuildUser target) {
|
||||
public async Task OvRemove([Summary(description: HelpOptOvTarget)] SocketGuildUser target) {
|
||||
using var db = new BotDatabaseContext();
|
||||
var user = target.GetUserEntryOrNew(db);
|
||||
if (!user.IsNew) {
|
||||
|
|
|
@ -112,7 +112,7 @@ public class ConfigModule : BotModuleBase {
|
|||
}
|
||||
|
||||
[SlashCommand("set-ping", HelpSubCmdPing)]
|
||||
public async Task CmdSetPing([Summary(description: "Set True to ping users, False to display them normally.")]bool option) {
|
||||
public async Task CmdSetPing([Summary(description: "Set True to ping users, False to display them normally.")] bool option) {
|
||||
await DoDatabaseUpdate(Context, s => s.AnnouncePing = option);
|
||||
await RespondAsync($":white_check_mark: Announcement pings are now **{(option ? "on" : "off")}**.").ConfigureAwait(false);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class ConfigModule : BotModuleBase {
|
|||
[SlashCommand("check", HelpCmdCheck)]
|
||||
public async Task CmdCheck() {
|
||||
static string DoTestFor(string label, Func<bool> test)
|
||||
=> $"{label}: { (test() ? ":white_check_mark: Yes" : ":x: No") }";
|
||||
=> $"{label}: {(test() ? ":white_check_mark: Yes" : ":x: No")}";
|
||||
|
||||
var guild = Context.Guild;
|
||||
using var db = new BotDatabaseContext();
|
||||
|
@ -141,8 +141,8 @@ public class ConfigModule : BotModuleBase {
|
|||
var result = new StringBuilder();
|
||||
|
||||
result.AppendLine($"Server ID: `{guild.Id}` | Bot shard ID: `{Shard.ShardId:00}`");
|
||||
result.AppendLine($"Number of registered birthdays: `{ guildconf.UserEntries.Count }`");
|
||||
result.AppendLine($"Server time zone: `{ guildconf.GuildTimeZone ?? "Not set - using UTC" }`");
|
||||
result.AppendLine($"Number of registered birthdays: `{guildconf.UserEntries.Count}`");
|
||||
result.AppendLine($"Server time zone: `{guildconf.GuildTimeZone ?? "Not set - using UTC"}`");
|
||||
result.AppendLine();
|
||||
|
||||
var hasMembers = Common.HasMostMembersDownloaded(guild);
|
||||
|
@ -180,7 +180,7 @@ public class ConfigModule : BotModuleBase {
|
|||
return announcech != null;
|
||||
}));
|
||||
var disp = announcech == null ? "announcement channel" : $"<#{announcech.Id}>";
|
||||
result.AppendLine(DoTestFor($"(Optional) Bot can send messages into { disp }", delegate {
|
||||
result.AppendLine(DoTestFor($"(Optional) Bot can send messages into {disp}", delegate {
|
||||
if (announcech == null) return false;
|
||||
return guild.CurrentUser.GetPermissions(announcech).SendMessages;
|
||||
}));
|
||||
|
|
|
@ -26,15 +26,14 @@ class AutoUserDownload : BackgroundService {
|
|||
.Select(g => g.Id)
|
||||
.ToHashSet();
|
||||
// ...and if the guild contains any user data
|
||||
IEnumerable<ulong> mustFetch;
|
||||
HashSet<ulong> mustFetch;
|
||||
try {
|
||||
await ConcurrentSemaphore.WaitAsync(token);
|
||||
using var db = new BotDatabaseContext();
|
||||
mustFetch = db.UserEntries.AsNoTracking()
|
||||
mustFetch = [.. db.UserEntries.AsNoTracking()
|
||||
.Where(e => incompleteCaches.Contains(e.GuildId))
|
||||
.Select(e => e.GuildId)
|
||||
.Where(e => !_skippedGuilds.Contains(e))
|
||||
.ToHashSet();
|
||||
.Where(e => !_skippedGuilds.Contains(e))];
|
||||
} finally {
|
||||
try {
|
||||
ConcurrentSemaphore.Release();
|
||||
|
|
|
@ -94,7 +94,7 @@ class BirthdayRoleUpdate : BackgroundService {
|
|||
// Special case: If user's birthday is 29-Feb and it's currently not a leap year, check against 1-Mar
|
||||
if (!DateTime.IsLeapYear(checkNow.Year) && record.BirthMonth == 2 && record.BirthDay == 29) {
|
||||
if (checkNow.Month == 3 && checkNow.Day == 1) birthdayUsers.Add(record.UserId);
|
||||
} else if (record.BirthMonth == checkNow.Month && record.BirthDay== checkNow.Day) {
|
||||
} else if (record.BirthMonth == checkNow.Month && record.BirthDay == checkNow.Day) {
|
||||
birthdayUsers.Add(record.UserId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,9 +13,8 @@ class DataRetention : BackgroundService {
|
|||
const int StaleGuildThreshold = 180;
|
||||
const int StaleUserThreashold = 360;
|
||||
|
||||
public DataRetention(ShardInstance instance) : base(instance) {
|
||||
ProcessInterval = 21600 / Shard.Config.BackgroundInterval; // Process about once per six hours
|
||||
}
|
||||
public DataRetention(ShardInstance instance) : base(instance)
|
||||
=> ProcessInterval = 21600 / Shard.Config.BackgroundInterval; // Process about once per six hours
|
||||
|
||||
public override async Task OnTick(int tickCount, CancellationToken token) {
|
||||
// Run only a subset of shards each time, each running every ProcessInterval ticks.
|
||||
|
|
|
@ -21,7 +21,7 @@ static class Common {
|
|||
|
||||
if (member.DiscriminatorValue == 0) {
|
||||
var username = escapeFormattingCharacters(member.GlobalName ?? member.Username);
|
||||
if (member.Nickname != null) {
|
||||
if (member.Nickname != null) {
|
||||
return $"{escapeFormattingCharacters(member.Nickname)} ({username})";
|
||||
}
|
||||
return username;
|
||||
|
|
Loading…
Reference in a new issue