/// <summary> /// Deletes a channel by name /// </summary> /// <returns></returns> public override async Task <int> ExecuteAsync() { try { IRemote remote = RemoteFactory.GetBarOnlyRemote(_options, Logger); // Get the ID of the channel with the specified name. Channel existingChannel = (await remote.GetChannelsAsync()).Where(channel => channel.Name.Equals(_options.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (existingChannel == null) { Logger.LogError($"Could not find channel with name '{_options.Name}'"); return(Constants.ErrorCode); } await remote.DeleteChannelAsync(existingChannel.Id); Console.WriteLine($"Successfully deleted channel '{existingChannel.Name}'."); return(Constants.SuccessCode); } catch (AuthenticationException e) { Console.WriteLine(e.Message); return(Constants.ErrorCode); } catch (Exception e) { Logger.LogError(e, "Error: Failed to delete channel."); return(Constants.ErrorCode); } }