mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-22 05:54:36 +00:00
Fix error when using check in an unconfigured guild
This commit is contained in:
parent
aebc63358d
commit
c98b99cd62
1 changed files with 6 additions and 4 deletions
|
@ -196,7 +196,7 @@ public class ConfigModule : BotModuleBase {
|
||||||
|
|
||||||
using var db = new BotDatabaseContext();
|
using var db = new BotDatabaseContext();
|
||||||
var guildconf = guild.GetConfigOrNew(db);
|
var guildconf = guild.GetConfigOrNew(db);
|
||||||
await db.Entry(guildconf).Collection(t => t.UserEntries).LoadAsync();
|
if (!guildconf.IsNew) await db.Entry(guildconf).Collection(t => t.UserEntries).LoadAsync();
|
||||||
|
|
||||||
var result = new StringBuilder();
|
var result = new StringBuilder();
|
||||||
|
|
||||||
|
@ -208,14 +208,16 @@ public class ConfigModule : BotModuleBase {
|
||||||
bool hasMembers = Common.HasMostMembersDownloaded(guild);
|
bool hasMembers = Common.HasMostMembersDownloaded(guild);
|
||||||
result.Append(DoTestFor("Bot has obtained the user list", () => hasMembers));
|
result.Append(DoTestFor("Bot has obtained the user list", () => hasMembers));
|
||||||
result.AppendLine($" - Has `{guild.DownloadedMemberCount}` of `{guild.MemberCount}` members.");
|
result.AppendLine($" - Has `{guild.DownloadedMemberCount}` of `{guild.MemberCount}` members.");
|
||||||
int bdayCount = -1;
|
int bdayCount = default;
|
||||||
result.Append(DoTestFor("Birthday processing", delegate {
|
result.Append(DoTestFor("Birthday processing", delegate {
|
||||||
if (!hasMembers) return false;
|
if (!hasMembers) return false;
|
||||||
|
if (guildconf.IsNew) return false;
|
||||||
bdayCount = BackgroundServices.BirthdayRoleUpdate.GetGuildCurrentBirthdays(guildconf.UserEntries, guildconf.TimeZone).Count;
|
bdayCount = BackgroundServices.BirthdayRoleUpdate.GetGuildCurrentBirthdays(guildconf.UserEntries, guildconf.TimeZone).Count;
|
||||||
return true;
|
return true;
|
||||||
}));
|
}));
|
||||||
if (hasMembers) result.AppendLine($" - `{bdayCount}` user(s) currently having a birthday.");
|
if (!hasMembers) result.AppendLine(" - Previous step failed.");
|
||||||
else result.AppendLine(" - Previous step failed.");
|
else if (guildconf.IsNew) result.AppendLine(" - No data.");
|
||||||
|
else result.AppendLine($" - `{bdayCount}` user(s) currently having a birthday.");
|
||||||
result.AppendLine();
|
result.AppendLine();
|
||||||
|
|
||||||
result.AppendLine(DoTestFor("Birthday role set with `bb.config role`", delegate {
|
result.AppendLine(DoTestFor("Birthday role set with `bb.config role`", delegate {
|
||||||
|
|
Loading…
Reference in a new issue