/// <summary> /// Bot exit function fired when application is closing or ctrl+c is pressed /// </summary> /// <param name="services"><see cref="IServiceProvider"> to get services from</param> private void BotExit(IServiceProvider services) { var node = services.GetRequiredService <LavaNode>(); var embedHelper = services.GetRequiredService <EmbedHelper>(); foreach (var player in node.Players) { try { node.LeaveAsync(player.VoiceChannel); BotConfig.BotEmbedMessage.ModifyAsync(async(x) => { x.Content = AudioHelper.NoSongsInQueue; x.Embed = await EmbedHelper.BuildDefaultEmbed(); }); } catch (Exception e) { var logging = services.GetRequiredService <LoggingService>(); var logger = logging.Loggers[LoggingService.LoggerEntries.Discord]; logger.LogError(e, ""); } BotConfig.BotEmbedMessage.ModifyAsync(async(x) => { x.Content = AudioHelper.NoSongsInQueue; x.Embed = await EmbedHelper.BuildDefaultEmbed(); }); ConfigHelper.UpdateConfigFile(BotConfig); } }