diff --git a/source/POI.DiscordDotNet/POI.DiscordDotNet.csproj b/source/POI.DiscordDotNet/POI.DiscordDotNet.csproj index afd3d6fc..63f5bb13 100644 --- a/source/POI.DiscordDotNet/POI.DiscordDotNet.csproj +++ b/source/POI.DiscordDotNet/POI.DiscordDotNet.csproj @@ -9,11 +9,10 @@ - - - - - + + + + diff --git a/source/POI.DiscordDotNet/Services/Implementations/DiscordStarboardService.cs b/source/POI.DiscordDotNet/Services/Implementations/DiscordStarboardService.cs index 49755e8c..ae59cefc 100644 --- a/source/POI.DiscordDotNet/Services/Implementations/DiscordStarboardService.cs +++ b/source/POI.DiscordDotNet/Services/Implementations/DiscordStarboardService.cs @@ -95,7 +95,14 @@ private async Task OnReactionAdded(DiscordClient sender, MessageReactionAddEvent // If the message is not in the database, create a new starboard message if (foundMessage == null) { - var embed = GetStarboardEmbed(message.Author.Username, message.Channel.Name, message.Content, message.JumpLink, message.Timestamp, (uint) messageStarCount, + var user = await guild.GetMemberAsync(message.Author.Id); + if (user == null) + { + _logger.LogError("User with id {UserId} not found in guild {GuildId}!", message.Author.Id, guild.Id); + return; + } + + var embed = GetStarboardEmbed(user.DisplayName, message.Channel.Name, message.Content, message.JumpLink, message.Timestamp, (uint) messageStarCount, message.Attachments.FirstOrDefault()?.Url); var embedMessage = await starboardChannel.SendMessageAsync(embed); diff --git a/source/POI.DiscordDotNet/Services/Implementations/UptimeManagementService.cs b/source/POI.DiscordDotNet/Services/Implementations/UptimeManagementService.cs index 5e93c3ed..48006071 100644 --- a/source/POI.DiscordDotNet/Services/Implementations/UptimeManagementService.cs +++ b/source/POI.DiscordDotNet/Services/Implementations/UptimeManagementService.cs @@ -21,18 +21,18 @@ public void Setup(IDiscordClientProvider discordClientProvider) { var client = discordClientProvider.Client!; - client.Ready -= ClientOnReady; - client.Ready += ClientOnReady; + client.SessionCreated -= ClientOnReady; + client.SessionCreated += ClientOnReady; } public void Cleanup(IDiscordClientProvider discordClientProvider) { - discordClientProvider.Client!.Ready -= ClientOnReady; + discordClientProvider.Client!.SessionCreated -= ClientOnReady; UpSince = null; } - private Task ClientOnReady(DiscordClient sender, ReadyEventArgs e) + private Task ClientOnReady(DiscordClient sender, SessionReadyEventArgs e) { _logger.LogDebug("Client OnReady event received. (Re)setting time since start"); UpSince = DateTimeOffset.Now.ToInstant();