Show country flag when !corona has a country code parameter
This commit is contained in:
parent
bbb9b89422
commit
644d877e29
2 changed files with 16 additions and 2 deletions
|
@ -1,10 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Geekbot.Core;
|
using Geekbot.Core;
|
||||||
|
using Geekbot.Core.Converters;
|
||||||
using Geekbot.Core.ErrorHandling;
|
using Geekbot.Core.ErrorHandling;
|
||||||
using Geekbot.Core.Extensions;
|
using Geekbot.Core.Extensions;
|
||||||
|
|
||||||
|
@ -13,10 +15,12 @@ namespace Geekbot.Bot.Commands.Utils.Corona
|
||||||
public class CoronaStats : ModuleBase
|
public class CoronaStats : ModuleBase
|
||||||
{
|
{
|
||||||
private readonly IErrorHandler _errorHandler;
|
private readonly IErrorHandler _errorHandler;
|
||||||
|
private readonly IEmojiConverter _emojiConverter;
|
||||||
|
|
||||||
public CoronaStats(IErrorHandler errorHandler)
|
public CoronaStats(IErrorHandler errorHandler, IEmojiConverter emojiConverter)
|
||||||
{
|
{
|
||||||
_errorHandler = errorHandler;
|
_errorHandler = errorHandler;
|
||||||
|
_emojiConverter = emojiConverter;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("corona", RunMode = RunMode.Async)]
|
[Command("corona", RunMode = RunMode.Async)]
|
||||||
|
@ -45,11 +49,19 @@ namespace Geekbot.Bot.Commands.Utils.Corona
|
||||||
var recoveredFormatted = summary.Recovered.ToString(numberFormat);
|
var recoveredFormatted = summary.Recovered.ToString(numberFormat);
|
||||||
var deathsFormatted = summary.Deaths.ToString(numberFormat);
|
var deathsFormatted = summary.Deaths.ToString(numberFormat);
|
||||||
|
|
||||||
|
var embedTitleBuilder = new StringBuilder();
|
||||||
|
embedTitleBuilder.Append("Confirmed Corona Cases");
|
||||||
|
if (!string.IsNullOrEmpty(summary.Country))
|
||||||
|
{
|
||||||
|
embedTitleBuilder.Append(" - ");
|
||||||
|
embedTitleBuilder.Append(_emojiConverter.CountryCodeToEmoji(summary.Country));
|
||||||
|
}
|
||||||
|
|
||||||
var eb = new EmbedBuilder
|
var eb = new EmbedBuilder
|
||||||
{
|
{
|
||||||
Author = new EmbedAuthorBuilder
|
Author = new EmbedAuthorBuilder
|
||||||
{
|
{
|
||||||
Name = "Confirmed Corona Cases",
|
Name = embedTitleBuilder.ToString(),
|
||||||
IconUrl = "https://www.redcross.org/content/dam/icons/disasters/virus/Virus-1000x1000-R-Pl.png"
|
IconUrl = "https://www.redcross.org/content/dam/icons/disasters/virus/Virus-1000x1000-R-Pl.png"
|
||||||
},
|
},
|
||||||
Footer = new EmbedFooterBuilder
|
Footer = new EmbedFooterBuilder
|
||||||
|
@ -103,6 +115,7 @@ namespace Geekbot.Bot.Commands.Utils.Corona
|
||||||
|
|
||||||
return new CoronaTotalDto()
|
return new CoronaTotalDto()
|
||||||
{
|
{
|
||||||
|
Country = upcasedCountryCode,
|
||||||
Cases = countryStats.Cases,
|
Cases = countryStats.Cases,
|
||||||
Deaths = countryStats.Deaths,
|
Deaths = countryStats.Deaths,
|
||||||
Recovered = countryStats.Recovered,
|
Recovered = countryStats.Recovered,
|
||||||
|
|
|
@ -2,6 +2,7 @@ namespace Geekbot.Bot.Commands.Utils.Corona
|
||||||
{
|
{
|
||||||
public record CoronaTotalDto
|
public record CoronaTotalDto
|
||||||
{
|
{
|
||||||
|
public string Country { get; set; }
|
||||||
public decimal Cases { get; set; }
|
public decimal Cases { get; set; }
|
||||||
public decimal Deaths { get; set; }
|
public decimal Deaths { get; set; }
|
||||||
public decimal Recovered { get; set; }
|
public decimal Recovered { get; set; }
|
||||||
|
|
Loading…
Reference in a new issue