Adding Initial API support, updating readme

This commit is contained in:
Runebaas 2017-10-02 21:57:48 +02:00
parent 6732506dae
commit 92015d8880
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
27 changed files with 78 additions and 33 deletions

View file

@ -0,0 +1,49 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Discord;
using Discord.Commands;
using Geekbot.net.Lib;
using StackExchange.Redis;
namespace Geekbot.net.Commands
{
public class Info : ModuleBase
{
private readonly IDatabase _redis;
private readonly IErrorHandler _errorHandler;
public Info(IDatabase redis, IErrorHandler errorHandler)
{
_redis = redis;
_errorHandler = errorHandler;
}
[Command("info", RunMode = RunMode.Async)]
[Summary("Get Information about the bot")]
public async Task BotInfo()
{
try
{
var eb = new EmbedBuilder();
eb.WithTitle("Geekbot V3.3");
var botOwner = Context.Guild.GetUserAsync(ulong.Parse(_redis.StringGet("botOwner"))).Result;
var uptime = (DateTime.Now.Subtract(Process.GetCurrentProcess().StartTime));
eb.AddInlineField("Bot Name", Context.Client.CurrentUser.Username)
.AddInlineField("Servers", Context.Client.GetGuildsAsync().Result.Count)
.AddInlineField("Uptime", $"{uptime.Days}D {uptime.Hours}H {uptime.Minutes}M {uptime.Seconds}S")
.AddInlineField("Bot Owner", $"{botOwner.Username}#{botOwner.Discriminator}")
.AddInlineField("Website", "https://geekbot.pizzaandcoffee.rocks/");
await ReplyAsync("", false, eb.Build());
}
catch (Exception e)
{
_errorHandler.HandleCommandException(e, Context);
}
}
}
}