Beispiel #1
0
        public async Task Start()
        {
            Console.Title = $"PassiveBOT v{Load.Version}";
            Console.WriteLine(
                "██████╗  █████╗ ███████╗███████╗██╗██╗   ██╗███████╗██████╗  ██████╗ ████████╗\n" +
                "██╔══██╗██╔══██╗██╔════╝██╔════╝██║██║   ██║██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝\n" +
                "██████╔╝███████║███████╗███████╗██║██║   ██║█████╗  ██████╔╝██║   ██║   ██║   \n" +
                "██╔═══╝ ██╔══██║╚════██║╚════██║██║╚██╗ ██╔╝██╔══╝  ██╔══██╗██║   ██║   ██║   \n" +
                "██║     ██║  ██║███████║███████║██║ ╚████╔╝ ███████╗██████╔╝╚██████╔╝   ██║   \n" +
                "╚═╝     ╚═╝  ╚═╝╚══════╝╚══════╝╚═╝  ╚═══╝  ╚══════╝╚═════╝  ╚═════╝    ╚═╝   \n" +
                "/--------------------------------------------------------------------------\\ \n" +
                "| Designed by PassiveModding - PassiveNation.com  ||   Status: Connected   | \n" +
                "\\--------------------------------------------------------------------------/ \n");

            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "setup/")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "setup/"));
            }
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "setup/config/")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "setup/config/"));
            }
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "setup/server/")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "setup/server/"));
            }
            if (!File.Exists(Path.Combine(AppContext.BaseDirectory, "setup/config/home.json")))
            {
                File.Create(Path.Combine(AppContext.BaseDirectory, "setup/config/home.json")).Dispose();
            }
            Config.CheckExistence();
            var prefix = Config.Load().Prefix;
            var debug  = Config.Load().Debug.ToUpper();
            var token  = Config.Load().Token;

            var ll = LogSeverity.Info;

            switch (debug)
            {
            case "Y":
                ll = LogSeverity.Debug;
                break;

            case "N":
                ll = LogSeverity.Info;
                break;

            default:
                await ColourLog.In1Run($"Error Loading Debug Config, Set to default (Entry = {debug})");

                break;
            }


            Client = new DiscordShardedClient(new DiscordSocketConfig
            {
                LogLevel         = ll,
                MessageCacheSize = 500
            });

            try
            {
                await Client.LoginAsync(TokenType.Bot, token);

                await Client.StartAsync();
            }
            catch (Exception e)
            {
                await ColourLog.In1Run("Token was rejected by Discord (Invalid Token or Connection Error)\n" +
                                       $"{e}");
            }

            var serviceProvider = ConfigureServices();

            _handler = new CommandHandler(serviceProvider);
            var _ = new EventHandler(serviceProvider);
            await _handler.ConfigureAsync();

            //checks if the user wants to log debug info or not
            if (ll == LogSeverity.Debug)
            {
                Client.Log += LogDebug;
            }
            else
            {
                Client.Log += LogMessageInfo;
            }

            //var application = await Client.GetApplicationInfoAsync();
            //await ColourLog.In1Run(
            //    $"Invite: https://discordapp.com/oauth2/authorize?client_id={application.Id}&scope=bot&permissions=2146958591");

            /*if (File.Exists(Path.Combine(AppContext.BaseDirectory, "setup/keys.json")))
             * {
             *   var k = JsonConvert.DeserializeObject<List<string>>(
             *      File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "setup/keys.json")));
             *  if (k.Count > 0)
             *      Keys = k;
             * }*/


            //setgame loop
            await Task.Delay(5000);

            string[] gametitle =
            {
                $"{prefix}help / Heap: {GetHeapSize()}MB",
                $"{prefix}help / {Load.Gamesite}",
                $"{prefix}help / v{Load.Version}"
            };
            while (true)
            {
                var rnd    = new Random();
                var result = rnd.Next(0, gametitle.Length);
                await Client.SetGameAsync($"{gametitle[result]}");

                await ColourLog.In3("PassiveBOT", 'B', "SetGame", 'R', $"{gametitle[result]}",
                                    Color.GreenYellow);

                await Task.Delay(3600000);
            }
            // ReSharper disable once FunctionNeverReturns
        }
Beispiel #2
0
        public async Task Start()
        {
            Console.Title = $"PassiveBOT";
            Console.WriteLine(
                "██████╗  █████╗ ███████╗███████╗██╗██╗   ██╗███████╗██████╗  ██████╗ ████████╗\n" +
                "██╔══██╗██╔══██╗██╔════╝██╔════╝██║██║   ██║██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝\n" +
                "██████╔╝███████║███████╗███████╗██║██║   ██║█████╗  ██████╔╝██║   ██║   ██║   \n" +
                "██╔═══╝ ██╔══██║╚════██║╚════██║██║╚██╗ ██╔╝██╔══╝  ██╔══██╗██║   ██║   ██║   \n" +
                "██║     ██║  ██║███████║███████║██║ ╚████╔╝ ███████╗██████╔╝╚██████╔╝   ██║   \n" +
                "╚═╝     ╚═╝  ╚═╝╚══════╝╚══════╝╚═╝  ╚═══╝  ╚══════╝╚═════╝  ╚═════╝    ╚═╝   \n" +
                "/--------------------------------------------------------------------------\\ \n" +
                "| Designed by PassiveModding - PassiveNation.com  ||   Status: Connected   | \n" +
                "\\--------------------------------------------------------------------------/ \n");

            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "setup/")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "setup/"));
            }
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "setup/config/")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "setup/config/"));
            }
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "setup/server/")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "setup/server/"));
            }
            //if (!File.Exists(Path.Combine(AppContext.BaseDirectory, "setup/config/home.json")))
            //    File.Create(Path.Combine(AppContext.BaseDirectory, "setup/config/home.json")).Dispose();
            Config.CheckExistence();
            Homeserver.CheckExistence();
            Tokens.CheckExistence();
            var debug = Config.Load().Debug.ToUpper();
            var token = Config.Load().Token;

            var ll = LogSeverity.Info;

            switch (debug)
            {
            case "Y":
                ll = LogSeverity.Debug;
                break;

            case "N":
                ll = LogSeverity.Info;
                break;

            default:
                await LogHandler.In1Run($"Error Loading Debug Config, Set to default (Entry = {debug})");

                break;
            }


            Client = new DiscordSocketClient(new DiscordSocketConfig
            {
                LogLevel         = ll,
                MessageCacheSize = 50
            });

            try
            {
                await Client.LoginAsync(TokenType.Bot, token);

                await Client.StartAsync();
            }
            catch (Exception e)
            {
                await LogHandler.In1Run("Token was rejected by Discord (Invalid Token or Connection Error)\n" +
                                        $"{e}");
            }

            var serviceProvider = ConfigureServices();

            _handler = new CommandHandler(serviceProvider);
            var _ = new EventHandler(serviceProvider);
            await _handler.ConfigureAsync();

            //checks if the user wants to log debug info or not
            if (ll == LogSeverity.Debug)
            {
                Client.Log += LogDebug;
            }
            else
            {
                Client.Log += LogMessageInfo;
            }

            await Task.Delay(-1);
        }