public static void Run(Func <BotBitsClient, BotBase> callback) { Exception exception = null; var oldClient = _client; BotServices.Run(bot => WithStarting(() => { _client = bot; try { callback(bot).MainBot = true; new CakeStartedEvent().RaiseIn(bot); } catch (Exception ex) { exception = ex; bot.Dispose(); } })); _client = oldClient; if (exception != null) { throw exception; } }