Exemplo n.º 1
0
        private void EventAdded(ulong guildId, ScheduledEvent se)
        {
            lock (_sync)
            {
                try
                {
                    DateTime earliest = se.ActualPingDates.First();

                    // If ping is not present - create
                    // Else if ping is present:
                    //   If ping is later than event earliest date - recreate ping with added event
                    //   If ping date is the same with event earliest date - add/update event in ping
                    if (_nextPing == null || earliest < _nextPing.Date)
                    {
                        _nextPing = new ScheduledPing(earliest);
                        _nextPing.SetEvent(guildId, se);
                        RecycleTimer();
                    }
                    else if (_nextPing != null && earliest == _nextPing.Date)
                    {
                        _nextPing.SetEvent(guildId, se);
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        private void EventChanged(ulong guildId, ScheduledEvent se)
        {
            lock (_sync)
            {
                try
                {
                    DateTime earliest = se.ActualPingDates.First();

                    // If ping is not present - create
                    // Else if ping is present:
                    //   If ping is later than event earliest date - recreate ping with updated event
                    //   If ping date is the same with event earliest date - add/update event in ping
                    //   If ping contains event and event earliest date is later - remove it from ping
                    if (_nextPing == null || earliest < _nextPing.Date)
                    {
                        _nextPing = new ScheduledPing(earliest);
                        _nextPing.SetEvent(guildId, se);
                        RecycleTimer();
                    }
                    else if (_nextPing != null)
                    {
                        if (earliest == _nextPing.Date)
                        {
                            _nextPing.SetEvent(guildId, se);
                        }
                        else if (_nextPing.HasEvent(guildId, se) && earliest > _nextPing.Date)
                        {
                            _nextPing.RemoveEvent(guildId, se);
                            if (_nextPing.IsEmpty)
                            {
                                FullUpdate();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex, ex.Message);
                }
            }
        }