Dynamically get discord.net version in !info

This commit is contained in:
runebaas 2018-05-18 00:34:45 +02:00
parent 6d708627f1
commit 74793c8ef7
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
3 changed files with 10 additions and 6 deletions

View file

@ -32,19 +32,19 @@ namespace Geekbot.net.Commands.Utils
{ {
var eb = new EmbedBuilder(); var eb = new EmbedBuilder();
var appInfo = await _client.GetApplicationInfoAsync();
eb.WithAuthor(new EmbedAuthorBuilder() eb.WithAuthor(new EmbedAuthorBuilder()
.WithIconUrl(_client.CurrentUser.GetAvatarUrl()) .WithIconUrl(appInfo.IconUrl)
.WithName($"{Constants.Name} V{Constants.BotVersion()}")); .WithName($"{Constants.Name} V{Constants.BotVersion()}"));
var botOwner = (await _client.GetApplicationInfoAsync()).Owner;
var uptime = DateTime.Now.Subtract(Process.GetCurrentProcess().StartTime); var uptime = DateTime.Now.Subtract(Process.GetCurrentProcess().StartTime);
eb.AddInlineField("Bot Name", _client.CurrentUser.Username); eb.AddInlineField("Bot Name", _client.CurrentUser.Username);
eb.AddInlineField("Bot Owner", $"{botOwner.Username}#{botOwner.Discriminator}"); eb.AddInlineField("Bot Owner", $"{appInfo.Owner.Username}#{appInfo.Owner.Discriminator}");
eb.AddInlineField("Library", "Discord.NET V1.0.2"); eb.AddInlineField("Library", $"Discord.NET {Constants.LibraryVersion()}");
eb.AddInlineField("Uptime", $"{uptime.Days}D {uptime.Hours}H {uptime.Minutes}M {uptime.Seconds}S"); 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("Servers", Context.Client.GetGuildsAsync().Result.Count);
eb.AddInlineField("Total Commands", _commands.Commands.Count()); eb.AddInlineField("Total Commands", _commands.Commands.Count());
eb.AddField("Website", "https://geekbot.pizzaandcoffee.rocks/"); eb.AddField("Website", "https://geekbot.pizzaandcoffee.rocks/");
await ReplyAsync("", false, eb.Build()); await ReplyAsync("", false, eb.Build());

View file

@ -11,6 +11,11 @@ namespace Geekbot.net.Lib
return typeof(Program).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion; return typeof(Program).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
} }
public static string LibraryVersion()
{
return typeof(Discord.WebSocket.DiscordSocketClient).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
}
public const double ApiVersion = 1; public const double ApiVersion = 1;
} }
} }

View file

@ -71,7 +71,6 @@ namespace Geekbot.net.WebApi.Logging
return NLog.LogLevel.Fatal; return NLog.LogLevel.Fatal;
case LogLevel.None: case LogLevel.None:
return NLog.LogLevel.Off; return NLog.LogLevel.Off;
break;
default: default:
throw new ArgumentOutOfRangeException(nameof(level)); throw new ArgumentOutOfRangeException(nameof(level));
} }