2017-09-30 01:38:10 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
2017-11-11 19:31:31 +01:00
|
|
|
|
using System.Linq;
|
2017-09-30 01:38:10 +02:00
|
|
|
|
using System.Threading.Tasks;
|
2017-09-14 22:11:19 +02:00
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.Commands;
|
2017-10-03 00:22:26 +02:00
|
|
|
|
using Discord.WebSocket;
|
2017-09-30 01:38:10 +02:00
|
|
|
|
using Geekbot.net.Lib;
|
2018-05-03 00:56:06 +02:00
|
|
|
|
using Geekbot.net.Lib.ErrorHandling;
|
2017-09-14 22:11:19 +02:00
|
|
|
|
using StackExchange.Redis;
|
|
|
|
|
|
2018-05-03 00:56:06 +02:00
|
|
|
|
namespace Geekbot.net.Commands.Utils
|
2017-09-14 22:11:19 +02:00
|
|
|
|
{
|
|
|
|
|
public class Info : ModuleBase
|
|
|
|
|
{
|
2017-10-03 00:22:26 +02:00
|
|
|
|
private readonly DiscordSocketClient _client;
|
2017-11-11 19:31:31 +01:00
|
|
|
|
private readonly CommandService _commands;
|
2017-12-29 01:53:50 +01:00
|
|
|
|
private readonly IErrorHandler _errorHandler;
|
|
|
|
|
private readonly IDatabase _redis;
|
2017-09-15 22:56:03 +02:00
|
|
|
|
|
2017-11-11 19:31:31 +01:00
|
|
|
|
public Info(IDatabase redis, IErrorHandler errorHandler, DiscordSocketClient client, CommandService commands)
|
2017-09-14 22:11:19 +02:00
|
|
|
|
{
|
2017-09-30 01:38:10 +02:00
|
|
|
|
_redis = redis;
|
|
|
|
|
_errorHandler = errorHandler;
|
2017-10-03 00:22:26 +02:00
|
|
|
|
_client = client;
|
2017-11-11 19:31:31 +01:00
|
|
|
|
_commands = commands;
|
2017-09-14 22:11:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-15 22:56:03 +02:00
|
|
|
|
[Command("info", RunMode = RunMode.Async)]
|
2017-10-12 16:34:10 +02:00
|
|
|
|
[Remarks(CommandCategories.Helpers)]
|
2017-09-15 22:56:03 +02:00
|
|
|
|
[Summary("Get Information about the bot")]
|
2017-09-14 22:11:19 +02:00
|
|
|
|
public async Task BotInfo()
|
|
|
|
|
{
|
2017-09-30 01:38:10 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var eb = new EmbedBuilder();
|
2017-12-29 01:53:50 +01:00
|
|
|
|
|
2017-10-03 00:22:26 +02:00
|
|
|
|
eb.WithAuthor(new EmbedAuthorBuilder()
|
|
|
|
|
.WithIconUrl(_client.CurrentUser.GetAvatarUrl())
|
2018-05-06 03:24:09 +02:00
|
|
|
|
.WithName($"{Constants.Name} V{Constants.BotVersion()}"));
|
2017-10-03 00:22:26 +02:00
|
|
|
|
var botOwner = await Context.Guild.GetUserAsync(ulong.Parse(_redis.StringGet("botOwner")));
|
2017-12-29 01:53:50 +01:00
|
|
|
|
var uptime = DateTime.Now.Subtract(Process.GetCurrentProcess().StartTime);
|
|
|
|
|
|
2017-10-03 00:22:26 +02:00
|
|
|
|
eb.AddInlineField("Bot Name", _client.CurrentUser.Username);
|
|
|
|
|
eb.AddInlineField("Bot Owner", $"{botOwner.Username}#{botOwner.Discriminator}");
|
2017-11-11 19:31:31 +01:00
|
|
|
|
eb.AddInlineField("Library", "Discord.NET V1.0.2");
|
|
|
|
|
eb.AddInlineField("Uptime", $"{uptime.Days}D {uptime.Hours}H {uptime.Minutes}M {uptime.Seconds}S");
|
|
|
|
|
eb.AddInlineField("Servers", Context.Client.GetGuildsAsync().Result.Count);
|
|
|
|
|
eb.AddInlineField("Total Commands", _commands.Commands.Count());
|
2017-12-29 01:53:50 +01:00
|
|
|
|
|
2017-11-11 19:31:31 +01:00
|
|
|
|
eb.AddField("Website", "https://geekbot.pizzaandcoffee.rocks/");
|
2017-09-30 01:38:10 +02:00
|
|
|
|
|
|
|
|
|
await ReplyAsync("", false, eb.Build());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2017-12-29 01:53:50 +01:00
|
|
|
|
_errorHandler.HandleCommandException(e, Context);
|
2017-09-30 01:38:10 +02:00
|
|
|
|
}
|
2017-09-14 22:11:19 +02:00
|
|
|
|
}
|
2017-12-29 01:53:50 +01:00
|
|
|
|
|
2017-10-03 00:22:26 +02:00
|
|
|
|
[Command("uptime", RunMode = RunMode.Async)]
|
2017-10-12 16:34:10 +02:00
|
|
|
|
[Remarks(CommandCategories.Helpers)]
|
2017-10-03 00:22:26 +02:00
|
|
|
|
[Summary("Get the Bot Uptime")]
|
|
|
|
|
public async Task BotUptime()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-12-29 01:53:50 +01:00
|
|
|
|
var uptime = DateTime.Now.Subtract(Process.GetCurrentProcess().StartTime);
|
2017-10-03 00:22:26 +02:00
|
|
|
|
await ReplyAsync($"{uptime.Days}D {uptime.Hours}H {uptime.Minutes}M {uptime.Seconds}S");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2017-12-29 01:53:50 +01:00
|
|
|
|
_errorHandler.HandleCommandException(e, Context);
|
2017-10-03 00:22:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-14 22:11:19 +02:00
|
|
|
|
}
|
2017-04-17 23:58:43 +02:00
|
|
|
|
}
|