Пример #1
0
        // Method to check if this form should open or not.
        internal static async void CheckRunConfigurator(bool run = true)
        {
            if (!run)
            {
                return;
            }

            if (Configuration.Load().FirstTimeRun)
            {
                await new LogMessage(LogSeverity.Info, "Configurator",
                                     "Hello! It looks like your new here. We're setting things up for you.").PrintToConsole();
                await new LogMessage(LogSeverity.Info, "Configurator",
                                     "We're gonna need a few details and we'll be up and running in no time!").PrintToConsole();
            }

            await new LogMessage(LogSeverity.Info, "Configurator", "Launching Configurator.").PrintToConsole();

            FrmConfigure configurator = new FrmConfigure();

            configurator.ShowDialog();
        }
Пример #2
0
        private static async void StartBot(string[] args) // Startup Method.
        {
            // Print Application Information to Console.
            Console.Write($@"{DateTime.Now,-19} DiscordBot: [");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(@"Version " + ProgramVersion.Major + @"." + ProgramVersion.Minor + @"." +
                          ProgramVersion.Build + @"." + ProgramVersion.Revision);
            Console.ResetColor();
            Console.WriteLine(@"]    ");

            // Print Developer Information to Console.
            Console.Write($@"{DateTime.Now,-19} DiscordBot: Developed by Melissa Brennan (");
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write(@"@MythicalCuddles");
            Console.ResetColor();
            Console.WriteLine(@")");

            // Print Additional Information to the Console.
            Console.WriteLine($@"{DateTime.Now,-19} DiscordBot: Web: www.mythicalcuddles.xyz");
            Console.WriteLine($@"{DateTime.Now,-19} DiscordBot: Copyright 2017 - 2019 Melissa Brennan | Licensed under the MIT License.");

            Methods.PrintConsoleSplitLine();

            // Run the Initializer for MelissaNET.
            MelissaNet.MelissaNet.Initialize();

            Methods.PrintConsoleSplitLine();

            // Check for Updates using MelissaNet.
            CheckForUpdates();

            // Check if application configurations exist.
            Configuration.EnsureExists();
            StringConfiguration.EnsureExists();

            // Verify Settings
            bool invalidToken = false, invalidDbSettings = false;

            if (!Configuration.Load().FirstTimeRun)
            {
                Methods.PrintConsoleSplitLine();

                invalidToken      = !Methods.VerifyBotToken().GetAwaiter().GetResult();
                invalidDbSettings = !DatabaseActivity.TestDatabaseSettings().GetAwaiter().GetResult().connectionValid;
            }

            Methods.PrintConsoleSplitLine();

            // Check & Run the configurator form if the configuration has not been setup or the -config arg has been passed.
            var configArg = args.Contains("-CONFIG");

            await new LogMessage(LogSeverity.Debug, "Configurator",
                                 "Checking if the Configurator needs to run...").PrintToConsole();
            await new LogMessage(LogSeverity.Debug, "Configurator",
                                 "configArg: " + configArg.ToYesNo()).PrintToConsole();
            await new LogMessage(LogSeverity.Debug, "Configurator",
                                 "FirstTimeRun: " + Configuration.Load().FirstTimeRun.ToYesNo()).PrintToConsole();
            await new LogMessage(LogSeverity.Debug, "Configurator",
                                 "invalidToken: " + invalidToken.ToYesNo()).PrintToConsole();
            await new LogMessage(LogSeverity.Debug, "Configurator",
                                 "invalidDbSettings: " + invalidDbSettings.ToYesNo()).PrintToConsole();
            FrmConfigure.CheckRunConfigurator(configArg || Configuration.Load().FirstTimeRun || invalidToken || invalidDbSettings);

            Methods.PrintConsoleSplitLine();

            // Check to see if the database and tables exist.
            DatabaseActivity.EnsureExists();

            // Start the bot.
            DiscordBot.RunBotAsync().GetAwaiter().GetResult();
        }