Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
I think now it works
Browse files Browse the repository at this point in the history
  • Loading branch information
GianniKoch authored and ErisApps committed Jul 22, 2023
1 parent d066767 commit 5048467
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
9 changes: 4 additions & 5 deletions source/POI.DiscordDotNet/POI.DiscordDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DSharpPlus" Version="4.4.2" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.4.2" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.4.2" />
<PackageReference Include="DSharpPlus.Rest" Version="4.4.2" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="4.4.2" />
<PackageReference Include="DSharpPlus" Version="5.0.0-nightly-01663" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="5.0.0-nightly-01663" />
<PackageReference Include="DSharpPlus.Interactivity" Version="5.0.0-nightly-01663" />
<PackageReference Include="DSharpPlus.SlashCommands" Version="5.0.0-nightly-01663" />
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="13.1.3" />
<PackageReference Include="Magick.NET.Core" Version="13.1.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 99 in source/POI.DiscordDotNet/Services/Implementations/DiscordStarboardService.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 99 in source/POI.DiscordDotNet/Services/Implementations/DiscordStarboardService.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.

Check warning on line 99 in source/POI.DiscordDotNet/Services/Implementations/DiscordStarboardService.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
{
_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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5048467

Please sign in to comment.