public void Init() { ConfigTool.GetConfigSettings(cfg); client = new DiscordClient(c => { c.AppName = "sharkbot"; c.AppVersion = "1.0.0.0"; c.LogHandler = log; c.LogLevel = LogSeverity.Debug; }); client.UsingCommands(c => { c.PrefixChar = cfg.CommandPrefix; c.AllowMentionPrefix = true; }); client.MessageReceived += (s, e) => { Logger.LogInfo(e.Message.Text, e.Channel.Name); }; cmdService = client.GetService <CommandService>(); registerCommands(); Task.Factory.StartNew(() => { client.ExecuteAndWait(async() => { await client.Connect(cfg.Token, TokenType.Bot); }); }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }