reworked blocked raids and polls
This commit is contained in:
parent
ac3cc69b68
commit
d3e69d4be7
2 changed files with 16 additions and 10 deletions
|
@ -73,6 +73,7 @@ namespace Lieb.Data
|
||||||
.FirstOrDefault(r => r.RaidId == raidId);
|
.FirstOrDefault(r => r.RaidId == raidId);
|
||||||
|
|
||||||
if (raid == null) return 0;
|
if (raid == null) return 0;
|
||||||
|
poll.Question = $"{raid.Title}: {poll.Question}";
|
||||||
HashSet<ulong> users = raid.SignUps.Where(s => s.LiebUserId != null && s.IsMessageSignUp).Select(s => (ulong)s.LiebUserId).ToHashSet();
|
HashSet<ulong> users = raid.SignUps.Where(s => s.LiebUserId != null && s.IsMessageSignUp).Select(s => (ulong)s.LiebUserId).ToHashSet();
|
||||||
return await CreatePoll(poll, users, raidId, isAutoPoll);
|
return await CreatePoll(poll, users, raidId, isAutoPoll);
|
||||||
}
|
}
|
||||||
|
|
|
@ -721,19 +721,24 @@ namespace Lieb.Data
|
||||||
Poll poll = _pollService.GetPoll(raid.MinUserPollId.Value);
|
Poll poll = _pollService.GetPoll(raid.MinUserPollId.Value);
|
||||||
|
|
||||||
if (poll.Answers.Count == 0) continue;
|
if (poll.Answers.Count == 0) continue;
|
||||||
if (poll.Answers.Where(a => string.IsNullOrEmpty(a.Answer)).Any()) continue;
|
|
||||||
|
|
||||||
if(poll.Answers.Where(a => a.Answer == Constants.Polls.NO).Any())
|
//continue if not everything is answered and the poll is not older than 1 day
|
||||||
|
if (poll.Answers.Where(a => string.IsNullOrEmpty(a.Answer)).Any()
|
||||||
|
&& poll.CreatedAt > DateTimeOffset.UtcNow.AddDays(-1)) continue;
|
||||||
|
|
||||||
|
//sign off users that answered "No"
|
||||||
|
HashSet<ulong> signedOffUsers = poll.Answers.Where(a => a.Answer == Constants.Polls.NO || string.IsNullOrEmpty(a.Answer)).Select(a => a.UserId).ToHashSet();
|
||||||
|
foreach(ulong user in signedOffUsers)
|
||||||
{
|
{
|
||||||
await _discordService.SendMessageToRaidUsers("The raid is canceled.", raid);
|
await SignOff(raid.RaidId, user);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
raid.MinUsers = 0;
|
|
||||||
await context.SaveChangesAsync();
|
|
||||||
await _discordService.SendMessageToRaidUsers("The raid will take place. Signing up is allowed again.", raid);
|
|
||||||
await _discordService.PostRaidMessage(raid.RaidId);
|
|
||||||
}
|
}
|
||||||
|
await _discordService.SendMessageToUsers("You have been signed off.", raid.Title, signedOffUsers);
|
||||||
|
|
||||||
|
//reopen the raid
|
||||||
|
raid.MinUsers = 0;
|
||||||
|
await context.SaveChangesAsync();
|
||||||
|
await _discordService.SendMessageToRaidUsers("People who have voted \"No\" have been signed off. Signing up is allowed again.", raid);
|
||||||
|
await _discordService.PostRaidMessage(raid.RaidId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue