Skip to content

Commit

Permalink
use await for ready event, other minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Jan 25, 2024
1 parent 58d0011 commit c20be11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
6 changes: 2 additions & 4 deletions Events/ReadyEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@

public class ReadyEvent
{
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
public static Task OnReady(DiscordClient client, ReadyEventArgs e)
public static async Task OnReady(DiscordClient client, ReadyEventArgs e)
{
Task.Run(async () =>
await Task.Run(async () =>
{
Program.ConnectTime = DateTime.Now;

await Program.HomeChannel.SendMessageAsync(await DebugInfoHelpers.GenerateDebugInfoEmbed(true));

await CustomStatusHelpers.SetCustomStatus();
});
return Task.CompletedTask;
}
}
12 changes: 6 additions & 6 deletions Helpers/DebugInfoHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public static DebugInfo GetDebugInfo()
var commitMessage = FileHelpers.ReadFile("CommitMessage.txt",
$"Running in development mode; process started at {Program.ProcessStartTime}");

var loadTime = (Program.ConnectTime - Convert.ToDateTime(Program.ProcessStartTime)).Humanize();
var timeSinceProcessStart = (Program.ConnectTime - Convert.ToDateTime(Program.ProcessStartTime)).Humanize();

return new DebugInfo(
RuntimeInformation.FrameworkDescription,
RuntimeInformation.OSDescription,
$"DSharpPlus {Program.Discord.VersionString}",
loadTime,
timeSinceProcessStart,
commitHash,
commitTimeDescription,
commitTime,
Expand All @@ -45,7 +45,7 @@ private static Task<DiscordEmbed> GenerateDebugInfoEmbed(DebugInfo debugInfo, bo
{
DiscordEmbedBuilder embed = new()
{
Title = isOnReadyEvent ? "Connected!" : "Debug Info",
Title = isOnReadyEvent ? "Connected!" : "",
Color = Program.BotColor
};

Expand All @@ -59,7 +59,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("Load Time", debugInfo.LoadTime, true);
if (isOnReadyEvent) 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 @@ -78,7 +78,7 @@ public class DebugInfo(
string framework = null,
string platform = null,
string library = null,
string loadTime = null,
string timeSinceProcessStart = null,
string commitHash = null,
string commitTimeDescription = null,
string commitTimestamp = null,
Expand All @@ -87,7 +87,7 @@ public class DebugInfo(
public string Framework { get; } = framework;
public string Platform { get; } = platform;
public string Library { get; } = library;
public string LoadTime { get; } = loadTime;
public string TimeSinceProcessStart { get; } = timeSinceProcessStart;
public string CommitHash { get; } = commitHash;
public string CommitTimeDescription { get; } = commitTimeDescription;
public string CommitTimestamp { get; } = commitTimestamp;
Expand Down

0 comments on commit c20be11

Please sign in to comment.