Skip to content

Commit

Permalink
Add real stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Sella-GH committed May 18, 2024
1 parent f783cad commit 3cf7a93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 5 additions & 2 deletions AzzyBot-Next/Commands/CoreCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ namespace AzzyBot.Commands;
internal sealed class CoreCommands
{
[Command("core"), RequireGuild]
internal sealed class Core(AzzyBotSettingsRecord settings, DbActions dbActions, ILogger<Core> logger)
internal sealed class Core(AzzyBotSettingsRecord settings, AzzyBotStatsRecord stats, DbActions dbActions, ILogger<Core> logger)
{
private readonly AzzyBotSettingsRecord _settings = settings;
private readonly AzzyBotStatsRecord _stats = stats;
private readonly DbActions _dbActions = dbActions;
private readonly ILogger<Core> _logger = logger;

Expand Down Expand Up @@ -107,7 +108,9 @@ public async ValueTask CoreInfoStatsAsync(CommandContext context)
Uri avaUrl = new(context.Client.CurrentUser.AvatarUrl);
string dspVersion = context.Client.VersionString.Split('+')[0];

await context.EditResponseAsync(EmbedBuilder.BuildAzzyInfoStatsEmbed(avaUrl, dspVersion));
DiscordEmbed embed = EmbedBuilder.BuildAzzyInfoStatsEmbed(avaUrl, dspVersion, _stats.Commit, _stats.CompilationDate, _stats.LocCs);

await context.EditResponseAsync(embed);
}

[Command("ping"), Description("Ping the bot and get the latency to discord.")]
Expand Down
7 changes: 3 additions & 4 deletions AzzyBot-Next/Utilities/EmbedBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,15 @@ internal static DiscordEmbed BuildAzzyHelpEmbed(List<AzzyHelpRecord> commands)
return CreateBasicEmbed(title, null, DiscordColor.Blurple, null, null, null, fields);
}

internal static DiscordEmbed BuildAzzyInfoStatsEmbed(Uri avaUrl, string dspVersion)
internal static DiscordEmbed BuildAzzyInfoStatsEmbed(Uri avaUrl, string dspVersion, string commit, in DateTime compileDate, int loc)
{
const string title = "AzzyBot Informational Stats";
const string githubUrl = "https://github.com/Sella-GH";
const string botUrl = $"{githubUrl}/AzzyBot";
const string commitUrl = $"{botUrl}/commit";
const string contribUrl = $"{botUrl}/graphs/contributors";
string[] authors = AzzyStatsSoftware.GetBotAuthors.Split(',');
string commit = "Testcommit";
string sourceCode = $"{string.Empty} lines";
string sourceCode = $"{loc} lines";
string formattedAuthors = $"- [{authors[0].Trim()}]({githubUrl})\n- [{authors[1].Trim()}]({contribUrl})";
string formattedCommit = $"[{commit}]({commitUrl}/{commit})";

Expand Down Expand Up @@ -164,7 +163,7 @@ internal static DiscordEmbed BuildAzzyInfoStatsEmbed(Uri avaUrl, string dspVersi
["Memory Usage"] = new($"{AzzyStatsSoftware.GetBotMemoryUsage()} GB", true),

// Row 6
["Compilation Date"] = new($"<t:{Converter.ConvertToUnixTime(DateTime.Now)}>", false),
["Compilation Date"] = new($"<t:{Converter.ConvertToUnixTime(compileDate)}>", false),

// Row 7
["AzzyBot GitHub Commit"] = new(formattedCommit, false)
Expand Down

0 comments on commit 3cf7a93

Please sign in to comment.