Add version command
This commit is contained in:
parent
b6ebda7b37
commit
7a18e4a14b
49
ChaosBot/Discord/Modules/User/Info.cs
Normal file
49
ChaosBot/Discord/Modules/User/Info.cs
Normal 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}]>.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user