Ejemplo n.º 1
0
        private void Migrate(DbConnection conn)
        {
            using (var checkTableCommand = conn.CreateCommand())
            {
                // make sure table still exists
                checkTableCommand.CommandText =
                    "SELECT name FROM sqlite_master WHERE type='table' AND name='BotConfig';";
                var checkReader = checkTableCommand.ExecuteReader();
                if (!checkReader.HasRows)
                {
                    return;
                }
            }

            using (var checkMigratedCommand = conn.CreateCommand())
            {
                checkMigratedCommand.CommandText =
                    "UPDATE BotConfig SET HasMigratedGamblingSettings = 1 WHERE HasMigratedGamblingSettings = 0;";
                var changedRows = checkMigratedCommand.ExecuteNonQuery();
                if (changedRows == 0)
                {
                    return;
                }
            }

            Log.Information("Migrating gambling settings...");

            using var com   = conn.CreateCommand();
            com.CommandText = $@"SELECT CurrencyGenerationChance, CurrencyGenerationCooldown,
CurrencySign, CurrencyName, CurrencyGenerationPassword, MinBet, MaxBet, BetflipMultiplier,
TimelyCurrency, TimelyCurrencyPeriod, CurrencyDropAmount, CurrencyDropAmountMax, DailyCurrencyDecay,
DivorcePriceMultiplier, PatreonCurrencyPerCent, MinWaifuPrice, WaifuGiftMultiplier
FROM BotConfig";

            using var reader = com.ExecuteReader();
            if (!reader.Read())
            {
                return;
            }


            using (var itemsCommand = conn.CreateCommand())
            {
                itemsCommand.CommandText = WaifuItemUpdateQuery;
                itemsCommand.ExecuteNonQuery();
            }


            _gss.ModifyConfig(ModifyAction(reader));

            Log.Information("Data written to data/gambling.yml");
        }
Ejemplo n.º 2
0
        public async Task TimelySet(int amount, int period = 24)
        {
            if (amount < 0 || period < 0)
            {
                return;
            }

            _configService.ModifyConfig(gs =>
            {
                gs.Timely.Amount   = amount;
                gs.Timely.Cooldown = period;
            });

            if (amount == 0)
            {
                await ReplyConfirmLocalizedAsync("timely_set_none").ConfigureAwait(false);
            }
            else
            {
                await ReplyConfirmLocalizedAsync("timely_set", Format.Bold(n(amount) + CurrencySign), Format.Bold(period.ToString())).ConfigureAwait(false);
            }
        }