Fix various issues with ScheduledEventUpdateService (#89)
This PR closes #85. This PR fixes many issues related to scheduled events. Most importantly, scheduled events that are no longer present in the guild, but still have data related to them, won't be left rotting. This requires deletion of `ScheduledEvents.json` files in all guilds. Maybe I'll start writing datafixers one day... Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
501c51b865
commit
4252613dd3
6 changed files with 190 additions and 112 deletions
|
@ -50,6 +50,21 @@ public class GuildLoadedResponder : IResponder<IGuildCreate>
|
|||
data.GetOrCreateMemberData(member.User.Value.ID);
|
||||
}
|
||||
|
||||
foreach (var schEvent in guild.GuildScheduledEvents)
|
||||
{
|
||||
if (!data.ScheduledEvents.TryGetValue(schEvent.ID.Value, out var eventData))
|
||||
{
|
||||
data.ScheduledEvents.Add(schEvent.ID.Value, new ScheduledEventData(schEvent.ID.Value,
|
||||
schEvent.Name, schEvent.Status, schEvent.ScheduledStartTime));
|
||||
continue;
|
||||
}
|
||||
|
||||
eventData.Name = schEvent.Name;
|
||||
eventData.ScheduledStartTime = schEvent.ScheduledStartTime;
|
||||
eventData.ScheduleOnStatusUpdated = eventData.Status != schEvent.Status;
|
||||
eventData.Status = schEvent.Status;
|
||||
}
|
||||
|
||||
if (!GuildSettings.ReceiveStartupMessages.Get(cfg))
|
||||
{
|
||||
return Result.FromSuccess();
|
||||
|
|
Reference in a new issue