Esempio n. 1
0
        public async Task LoadDeathMessages(CommandContext ctx)
        {
            if (File.Exists(s_fileName))
            {
                // set some JSON text to blank.
                string json = "";
                using (FileStream fs = File.OpenRead(s_fileName))
                    using (StreamReader sr = new StreamReader(fs, new UTF8Encoding(false)))
                        json = sr.ReadToEnd();
                // Decode the JSON and set it to dmLines.
                _dmLines = JsonConvert.DeserializeObject <DeathMessageLines>(json);
                // Enable all the commands.
                _isEnabled = true;
                await ctx.RespondAsync(StartEmbed("Loading Death Messages successul."));
            }
            else
            {
                // Echo out that we're missing a file. Disable the commands due to that.
                await ctx.RespondAsync(StartEmbed("Can't load Death Messages. File missing."));

                _isEnabled = false;
            }
        }
Esempio n. 2
0
 public DeathMessages()
 {
     Console.WriteLine("Death Message Commands Loaded.");
     // If the DeathMessages file exists, load it. And enable the commands.
     // Otherwise disable all the commands.
     if (File.Exists(s_fileName))
     {
         // set some JSON text to blank.
         string json = "";
         using (FileStream fs = File.OpenRead(s_fileName))
             using (StreamReader sr = new StreamReader(fs, new UTF8Encoding(false)))
                 json = sr.ReadToEnd();
         // Decode the JSON and set it to dmLines.
         _dmLines = JsonConvert.DeserializeObject <DeathMessageLines>(json);
         // Enable all the commands.
         _isEnabled = true;
     }
     else
     {
         // Echo out that we're missing a file. Disable the commands due to that.
         Console.WriteLine($" --- --- --- --- {s_fileName} is missing");
         _isEnabled = false;
     }
 }