Skip to content

Commit

Permalink
Move startup msg from ready event to startup
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Oct 20, 2024
1 parent a26aedc commit 8d97fc1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 0 additions & 3 deletions Events/ReadyEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ public static async Task OnReady(DiscordClient client, SessionCreatedEventArgs e
await Task.Run(async () =>
{
Program.ConnectTime = DateTime.Now;
await Program.HomeChannel.SendMessageAsync(await DebugInfoHelpers.GenerateDebugInfoEmbed(true));
await ActivityTasks.SetActivityAsync();
});
}
Expand Down
10 changes: 5 additions & 5 deletions Helpers/DebugInfoHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static DebugInfo GetDebugInfo()
}

// If provided a DebugInfo object, use that...
private static Task<DiscordEmbed> GenerateDebugInfoEmbed(DebugInfo debugInfo, bool isOnReadyEvent)
private static Task<DiscordEmbed> GenerateDebugInfoEmbed(DebugInfo debugInfo, bool isOnStartup)
{
// Check whether GuildDownloadCompleted has been fired yet
// If not, wait until it has
Expand All @@ -50,7 +50,7 @@ private static Task<DiscordEmbed> GenerateDebugInfoEmbed(DebugInfo debugInfo, bo

DiscordEmbedBuilder embed = new()
{
Title = isOnReadyEvent ? "Connected!" : "",
Title = isOnStartup ? "Connected!" : "",
Color = Program.BotColor
};

Expand All @@ -64,7 +64,7 @@ private static Task<DiscordEmbed> GenerateDebugInfoEmbed(DebugInfo debugInfo, bo
embed.AddField("Library", debugInfo.Library, true);
embed.AddField("Server Count", Program.Discord.Guilds.Count.ToString(), true);
embed.AddField("Command Count", Program.ApplicationCommands.Count.ToString(), true);
if (isOnReadyEvent) embed.AddField("Time Since Process Start", debugInfo.TimeSinceProcessStart, true);
if (isOnStartup) embed.AddField("Time Since Process Start", debugInfo.TimeSinceProcessStart, true);
embed.AddField("Commit Hash", commitHash, true);
embed.AddField(debugInfo.CommitTimeDescription, debugInfo.CommitTimestamp, true);
embed.AddField("Commit Message", debugInfo.CommitMessage);
Expand All @@ -73,9 +73,9 @@ private static Task<DiscordEmbed> GenerateDebugInfoEmbed(DebugInfo debugInfo, bo
}

// ...otherwise, get debug info manually
public static async Task<DiscordEmbed> GenerateDebugInfoEmbed(bool isOnReadyEvent)
public static async Task<DiscordEmbed> GenerateDebugInfoEmbed(bool isOnStartup)
{
return await GenerateDebugInfoEmbed(GetDebugInfo(), isOnReadyEvent);
return await GenerateDebugInfoEmbed(GetDebugInfo(), isOnStartup);
}


Expand Down
3 changes: 3 additions & 0 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ internal static async Task Main()
#if !DEBUG
await EvalCommands.RunCommand("cat /app/id_ed25519 > ~/.ssh/id_ed25519 && chmod 700 ~/.ssh/id_ed25519");
#endif

// Send startup message
await Program.HomeChannel.SendMessageAsync(await DebugInfoHelpers.GenerateDebugInfoEmbed(true));

// Run tasks

Expand Down

0 comments on commit 8d97fc1

Please sign in to comment.