2017-10-15 07:39:46 +00:00
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.Commands;
|
|
|
|
|
using NadekoBot.Extensions;
|
|
|
|
|
using NadekoBot.Modules.Searches.Services;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using NadekoBot.Common.Attributes;
|
2017-11-06 09:01:38 +00:00
|
|
|
|
using NadekoBot.Core.Common.Pokemon;
|
|
|
|
|
using NadekoBot.Core.Services;
|
2017-10-15 07:39:46 +00:00
|
|
|
|
|
|
|
|
|
namespace NadekoBot.Modules.Searches
|
|
|
|
|
{
|
|
|
|
|
public partial class Searches
|
|
|
|
|
{
|
|
|
|
|
[Group]
|
|
|
|
|
public class PokemonSearchCommands : NadekoSubmodule<SearchesService>
|
|
|
|
|
{
|
2017-11-06 09:01:38 +00:00
|
|
|
|
private readonly IDataCache _cache;
|
|
|
|
|
|
|
|
|
|
public IReadOnlyDictionary<string, SearchPokemon> Pokemons => _cache.LocalData.Pokemons;
|
|
|
|
|
public IReadOnlyDictionary<string, SearchPokemonAbility> PokemonAbilities => _cache.LocalData.PokemonAbilities;
|
|
|
|
|
|
|
|
|
|
public PokemonSearchCommands(IDataCache cache)
|
|
|
|
|
{
|
|
|
|
|
_cache = cache;
|
|
|
|
|
}
|
2017-10-15 07:39:46 +00:00
|
|
|
|
|
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
|
|
|
public async Task Pokemon([Remainder] string pokemon = null)
|
|
|
|
|
{
|
|
|
|
|
pokemon = pokemon?.Trim().ToUpperInvariant();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(pokemon))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
foreach (var kvp in Pokemons)
|
|
|
|
|
{
|
|
|
|
|
if (kvp.Key.ToUpperInvariant() == pokemon.ToUpperInvariant())
|
|
|
|
|
{
|
|
|
|
|
var p = kvp.Value;
|
|
|
|
|
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
|
|
|
|
.WithTitle(kvp.Key.ToTitleCase())
|
|
|
|
|
.WithDescription(p.BaseStats.ToString())
|
|
|
|
|
.AddField(efb => efb.WithName(GetText("types")).WithValue(string.Join(",\n", p.Types)).WithIsInline(true))
|
|
|
|
|
.AddField(efb => efb.WithName(GetText("height_weight")).WithValue(GetText("height_weight_val", p.HeightM, p.WeightKg)).WithIsInline(true))
|
|
|
|
|
.AddField(efb => efb.WithName(GetText("abilities")).WithValue(string.Join(",\n", p.Abilities.Select(a => a.Value))).WithIsInline(true)));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await ReplyErrorLocalized("pokemon_none").ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[NadekoCommand, Usage, Description, Aliases]
|
|
|
|
|
public async Task PokemonAbility([Remainder] string ability = null)
|
|
|
|
|
{
|
|
|
|
|
ability = ability?.Trim().ToUpperInvariant().Replace(" ", "");
|
|
|
|
|
if (string.IsNullOrWhiteSpace(ability))
|
|
|
|
|
return;
|
|
|
|
|
foreach (var kvp in PokemonAbilities)
|
|
|
|
|
{
|
|
|
|
|
if (kvp.Key.ToUpperInvariant() == ability)
|
|
|
|
|
{
|
|
|
|
|
await Context.Channel.EmbedAsync(new EmbedBuilder().WithOkColor()
|
|
|
|
|
.WithTitle(kvp.Value.Name)
|
|
|
|
|
.WithDescription(string.IsNullOrWhiteSpace(kvp.Value.Desc)
|
|
|
|
|
? kvp.Value.ShortDesc
|
|
|
|
|
: kvp.Value.Desc)
|
|
|
|
|
.AddField(efb => efb.WithName(GetText("rating"))
|
|
|
|
|
.WithValue(kvp.Value.Rating.ToString(_cultureInfo)).WithIsInline(true))
|
|
|
|
|
).ConfigureAwait(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await ReplyErrorLocalized("pokemon_ability_none").ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|