Beispiel #1
0
        public bool RedeemToken(ulong guildId, string token)
        {
            var model = GetTokenModel();
            var match = model.TokenList.FirstOrDefault(x => x.Token == token);

            if (match == null)
            {
                return(false);
            }

            var configSave = Legacy.GetPremiumConfig(guildId) ?? new LegacyIntegration.LegacyPremium
            {
                GuildId    = guildId,
                ExpiryDate = DateTime.UtcNow - TimeSpan.FromMinutes(5)
            };

            if (configSave.ExpiryDate < DateTime.UtcNow - TimeSpan.FromHours(1))
            {
                configSave.ExpiryDate = DateTime.UtcNow - TimeSpan.FromMinutes(5);
            }
            configSave.ExpiryDate = configSave.ExpiryDate + TimeSpan.FromDays(match.Days);
            Legacy.SaveConfig(configSave);
            model.TokenList.Remove(match);
            SaveTokenModel(model);
            return(true);
        }