示例#1
0
        public async Task SetMOTDIntervalCmd([Remainder] string intervalinminutes)
        {
            double chk = 0;

            if (!double.TryParse(intervalinminutes, out chk))
            {
                await ReplyAsync("Invalid interval. Please enter a number.\n");

                return;
            }

            // make sure it's high enough so we dont get rate limit banned (which is actually like 10-15 seconds or so)
            if (chk < 1)
            {
                await ReplyAsync("Please enter a number that is 1+ to prevent getting rate limit banned by Discord.\n");

                return;
            }

            // recreate the motd config
            var config = new MOTDConfiguration();

            // use the existing motd message
            config.Message = Globals.CURRENTMOTDMESSAGE;
            // update the interval with our new one
            config.IntervalInMinutes = intervalinminutes;
            // save it
            config.Save();
            // reload the global interval setting
            Globals.CURRENTMOTDINTERVAL = config.IntervalInMinutes;

            bool ret = false;

            if (Globals.TIMERRUNNING)
            {
                // the timer is running so try to change it's interval
                ret = _service.SetInterval(double.Parse(Globals.CURRENTMOTDINTERVAL));

                if (ret)
                {
                    await ReplyAsync("MOTD interval in minutes changed to: " + config.IntervalInMinutes + " minutes.\n");
                }
                else
                {
                    await ReplyAsync("MOTD interval in minutes **NOT CHANGED** to: " + config.IntervalInMinutes + " minutes.\n");
                }
            }
            else
            {
                await ReplyAsync("MOTD timer isn't running but interval in minutes changed to: " + config.IntervalInMinutes + " minutes in the config.\n");
            }
        }
示例#2
0
        public async Task SetMOTDCmd([Remainder] string message)
        {
            var config = new MOTDConfiguration();                           // Create a new configuration object.

            // Set the default message.
            config.Message = message;
            // use the global interval
            config.IntervalInMinutes = Globals.CURRENTMOTDINTERVAL;
            // save the config
            config.Save();
            // reload the global motd message setting
            Globals.CURRENTMOTDMESSAGE = config.Message;

            await ReplyAsync("MOTD set to:\n\n");
            await ReplyAsync(config.Message + "\n");
        }
示例#3
0
        /// <summary>
        /// Ensures the MOTD configuration file exists, creating a default one if it doesn't.
        /// </summary>
        public static void EnsureMOTDConfigExists()
        {
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "data")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "data"));
            }

            string loc = Path.Combine(AppContext.BaseDirectory, "data/motdconfiguration.json");

            if (!File.Exists(loc))                                      // Check if the configuration file exists.
            {
                var config = new MOTDConfiguration();                   // Create a new configuration object.

                config.Message           = "Default MOTD message.";     // Set the default message.
                config.IntervalInMinutes = "5";                         // set the default timer to 5 minutes.

                config.Save();                                          // Save the new configuration object to file.
            }
            Console.WriteLine("MOTD configuration Loaded...");
        }
示例#4
0
        public async Task GetMOTDIntervalCmd()
        {
            await ReplyAsync("MOTD interval in minutes set to " + MOTDConfiguration.Load().IntervalInMinutes + "\n");

            //await ReplyAsync("MOTD interval in minutes set to " + Globals.CURRENTMOTDINTERVAL + "\n");
        }
示例#5
0
        public async Task GetMOTDCmd()
        {
            await ReplyAsync("MOTD message is set to:\n" + MOTDConfiguration.Load().Message + "\n");

            //await ReplyAsync("MOTD message is set to:\n" + Globals.CURRENTMOTDMESSAGE + "\n");
        }