public async Task GetAocRolesChartAsync(ChartType chartType) { await DeferAsync(); try { Func <Stream> getImage = chartType switch { ChartType.Classes => () => _imageProvider.CreateAocClassDistributionImage(), ChartType.Races => () => _imageProvider.CreateAocRaceDistributionImage(), ChartType.PlayStyles => () => _imageProvider.CreateAocPlayStyleDistributionImage(), ChartType.GuildPreference => () => _imageProvider.CreateAocGuildPreferenceDistributionImage(), _ => throw new NotSupportedException($"Chart type {chartType} is not supported.") }; await using var imageStream = getImage(); await Context.Interaction.FollowupWithFileAsync(imageStream, "chart.png"); } catch (Exception e) { _logger.LogError(e, "Failed to create {ChartType} chart.", chartType); await FollowupAsync("Failed to create chart."); } }