Adding Character Checks
This commit is contained in:
parent
9c7bd0d11c
commit
663361f39e
@ -8,6 +8,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using ChaosBot.Discord.PreConditions;
|
||||
using ChaosBot.Lodestone;
|
||||
using ChaosBot.Repositories;
|
||||
using ChaosBot.Services;
|
||||
using Discord.Net;
|
||||
using NLog;
|
||||
@ -31,10 +32,25 @@ namespace ChaosBot.Discord.Modules.User
|
||||
{
|
||||
await GetFreeCompany(args[0], string.Join(" ", args.Skip(1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
await LodestoneHelp();
|
||||
}
|
||||
}
|
||||
else if ((cmd.ToLower() == "c") || (cmd.ToLower() == "character")|| (cmd.ToLower() == "char")|| (cmd.ToLower() == "toon"))
|
||||
{
|
||||
if(args.Length >= 1)
|
||||
{
|
||||
await GetFreeCompany(args[0], string.Join(" ", args.Skip(1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
await LodestoneHelp();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Check me out");
|
||||
await LodestoneHelp();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -44,8 +60,48 @@ namespace ChaosBot.Discord.Modules.User
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GetFreeCompany(string value, [Remainder] string name)
|
||||
public async Task LodestoneHelp()
|
||||
{
|
||||
try
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var embed = new EmbedBuilder();
|
||||
|
||||
embed.WithColor(new Color(255, 255, 0));
|
||||
embed.Title = $"Lodestone API Help";
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("To get FreeCompany Info:");
|
||||
sb.AppendLine($"By Id: {ConfigurationRepository.GetValue<string>("Discord:Prefix", Context.Guild.Id, "!")}lodestone freecompany 9231394073691143535");
|
||||
sb.AppendLine($"By Name: {ConfigurationRepository.GetValue<string>("Discord:Prefix", Context.Guild.Id, "!")}lodestone freecompany Siren Helix");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("To get Character Info:");
|
||||
sb.AppendLine($"By Id: {ConfigurationRepository.GetValue<string>("Discord:Prefix", Context.Guild.Id, "!")}lodestone character 9231394073691143535");
|
||||
sb.AppendLine($"By Name: {ConfigurationRepository.GetValue<string>("Discord:Prefix", Context.Guild.Id, "!")}lodestone character Siren Luna Kaisar");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("To view this help:");
|
||||
sb.AppendLine($"{ConfigurationRepository.GetValue<string>("Discord:Prefix", Context.Guild.Id, "!")}config help");
|
||||
|
||||
/*
|
||||
* Add the string to the Embed
|
||||
*/
|
||||
embed.Description = sb.ToString();
|
||||
|
||||
/*
|
||||
* Reply with the Embed created above
|
||||
*/
|
||||
await ReplyAsync(null, false, embed.Build());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(
|
||||
$"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GetFreeCompany(string value, [Remainder] string name)
|
||||
{
|
||||
FreeCompanyDetailed freeCompany;
|
||||
try
|
||||
{
|
||||
@ -67,7 +123,34 @@ namespace ChaosBot.Discord.Modules.User
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error($"InfoCommands.InfoCommand: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
||||
_logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task GetCharacter(string value, [Remainder] string name)
|
||||
{
|
||||
CharacterDetailed character;
|
||||
try
|
||||
{
|
||||
await Context.Channel.TriggerTypingAsync();
|
||||
|
||||
if (name.Length == 0)
|
||||
character = LodestoneManager.GetCharacter(Convert.ToInt64(value));
|
||||
else
|
||||
{
|
||||
character = LodestoneManager.GetCharacter(value, string.Join(" ", name));
|
||||
}
|
||||
|
||||
var embed = BuildEmbedFromCharacter(character);
|
||||
|
||||
/*
|
||||
* Reply with the Embed created above
|
||||
*/
|
||||
await ReplyAsync(null, false, embed.Build());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error($"{MethodBase.GetCurrentMethod().ReflectedType.FullName}: Exception [{ex}] thrown, <[{ex.Message}]>.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user