예제 #1
0
    public async Task GetLostArkRolesChartAsync(ChartType chartType)
    {
        await DeferAsync();

        try
        {
            Func <Stream> getImage = chartType switch
            {
                ChartType.Classes => () => _imageProvider.CreateLostArkClassDistributionImage(),
                ChartType.PlayStyles => () => _imageProvider.CreateLostArkPlayStyleDistributionImage(),
                _ => 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 Lost Ark class distribution chart.");
            await FollowupAsync("Failed to create chart.");
        }
    }