Add version command

This commit is contained in:
Daniel_I_Am 2020-08-06 16:11:27 +02:00
parent b6ebda7b37
commit 7a18e4a14b
No known key found for this signature in database
GPG Key ID: 80C428FCC9743E84

View File

@ -0,0 +1,49 @@
using System;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using ChaosBot.Discord.PreConditions;
using ChaosBot.Repositories;
using Discord;
using Discord.Commands;
using Microsoft.Extensions.Configuration;
using NLog;
namespace ChaosBot.Discord.Modules.User
{
public class Info : ModuleBase
{
private static readonly ILogger Logger = Program.Logger;
[Command("info")]
[Alias("version")]
[CheckCommandPerm("User")]
public async Task ShowInfo()
{
try
{
var sb = new StringBuilder();
var embed = new EmbedBuilder();
embed.WithColor(new Color(255, 255, 0));
embed.Title = $"Information {Program.AppSettingsHandler.GetValue<string>("Bot:Name")} v{Program.AppSettingsHandler.GetValue<string>("Bot:Version")}";
sb.AppendLine($"Prefix: {ConfigurationRepository.GetValue<string>("Discord:Prefix", Context.Guild.Id)}");
/*
* 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}]>.");
}
}
}
}