示例#1
0
        public async Task UpdateConfig(string arg = "moneyconfig")
        {
            switch (arg.ToLower())
            {
            case "moneyconfig":
                string raw = File.ReadAllText(moneyconfigPath);

                if (raw.Length == 0)
                {
                    _configs = MoneyConfig.defaultValues;
                    File.WriteAllText(moneyconfigPath,
                                      JsonConvert.SerializeObject(_configs));
                    await QuickEmbed("moneyconfig.txt is empty! Instead defaulting values");
                }

                _configs = JsonConvert.DeserializeObject <MoneyConfig>(raw);
                var embed = new EmbedBuilder {
                    Description = "Configs has successfully been updated from moneyconfig.txt"
                };

                //gets each member
                string values = UnpackValues(_configs);

                embed.AddField("Values", values);
                await ReplyAsync(embed : embed.Build());

                break;

            case "csgoconfig":
                CSGOConfigs.UpdateConfigFromJson();

                var e = new EmbedBuilder {
                    Description = "Configs has successfully been updated from moneyconfig.txt"
                };

                //gets each member
                string v = UnpackValues(CSGOConfigs.config);

                e.AddField("Values", v);
                await ReplyAsync(embed : e.Build());

                break;

            default:
                await QuickEmbed("File not recognised");

                break;
            }
        }
示例#2
0
        public async Task Flush(string str = "all")
        {
            if (!await CheckForOwner())
            {
                return;
            }

            switch (str.ToLower())
            {
            case "all":
                File.WriteAllText(userDataPath, "");
                configs = new MoneyConfig(0, 0, 0, 0, 0, 0, 0, 0, 0);
                File.WriteAllText(moneyconfigPath, "");
                users.Clear();

                await QuickEmbed("Successfully flushed **all** data");

                break;

            case "userdata":
                File.WriteAllText(userDataPath, "");
                users.Clear();

                await QuickEmbed("Successfully flushed all **userdata**");

                break;

            case "moneyconfig":
                configs = new MoneyConfig(0, 0, 0, 0, 0, 0, 0, 0, 0);
                File.WriteAllText(moneyconfigPath, "");


                await QuickEmbed("Successfully flushed **moneyconfig**");

                break;

            default:
                await QuickEmbed("String not recognised");

                break;
            }
        }