static void Main(string[] args) { //Register Callbacks Common.loggerFunc = discordLog; Common.Populate(); //Add ranks and other defaults DiscordDataService _data = new DiscordDataService(); _data.setTournament(new Tournament()); //Setup Bot Bot _bot = new Bot(_data); //Start Discord Bot _bot.MainAsync(); //Start Server Listening Thread Server _server = new Server(); Thread t = new Thread(_server.Main); t.Start(); bool exit = false; while (true) { Thread.Sleep(10000); //Let the main thread sleep indefinitely the bot the main thread is forcefully terminated /* * Console.WriteLine("Type something"); * string input = Console.ReadLine(); * * switch (input) * { * case "Q": * exit = true; * break; * } */ } t.Abort(); _bot.Close(); }
public Bot(DiscordDataService t) { //Get Token from disk _token = System.IO.File.ReadAllText("token.txt"); //Bind Data _dataService = t; //Generate Config _conf = new BotConfig(); _conf.Prefix = '!'; //Set Bot Prefix _tchannelMgr = new TournamentChannelManager(); _client = new DiscordSocketClient(new DiscordSocketConfig { //WebSocketProvider = Discord.Providers., //UdpSocketProvider = UDPClientProvider.Instance, LogLevel = LogSeverity.Verbose }); _commands = new CommandService(new CommandServiceConfig { // Again, log level: LogLevel = LogSeverity.Info, // There's a few more properties you can set, // for example, case-insensitive commands. CaseSensitiveCommands = false, }); //Add Tournament as a service _services = new ServiceCollection().AddSingleton(_dataService). AddSingleton(_commands). AddSingleton(_conf). AddSingleton(_tchannelMgr). BuildServiceProvider(); //Init Requests List _requests = new Queue <BotRequest>(); }