11using System . Threading ;
22using System . Threading . Tasks ;
33using Discord ;
4+ using Discord . WebSocket ;
45using MediatR ;
56using Modix . Bot . Notifications ;
67using Modix . Bot . Responders . MessageQuotes ;
@@ -20,6 +21,37 @@ public Task Handle(ReactionAddedNotificationV3 notification, CancellationToken c
2021 public Task Handle ( ReactionRemovedNotificationV3 notification , CancellationToken cancellationToken )
2122 => HandleReactionAsync ( notification . Message , notification . Reaction ) ;
2223
24+ private async ValueTask < bool > IsChannelIgnoredFromStarboard ( IGuildChannel channel )
25+ {
26+ if ( channel . ChannelType is ChannelType . PrivateThread )
27+ {
28+ return true ;
29+ }
30+
31+ var hasDirectDesignation = await designatedChannelService
32+ . ChannelHasDesignation ( channel . Guild . Id , channel . Id , DesignatedChannelType . IgnoredFromStarboard , default ) ;
33+
34+ if ( hasDirectDesignation )
35+ {
36+ return true ;
37+ }
38+
39+ if ( channel is SocketThreadChannel { ParentChannel : not null } threadChannel )
40+ {
41+ var parentChannelId = threadChannel . ParentChannel . Id ;
42+
43+ var parentHasDesignation = await designatedChannelService
44+ . ChannelHasDesignation ( channel . Guild . Id , parentChannelId , DesignatedChannelType . IgnoredFromStarboard , default ) ;
45+
46+ if ( parentHasDesignation )
47+ {
48+ return true ;
49+ }
50+ }
51+
52+ return false ;
53+ }
54+
2355 private async Task HandleReactionAsync ( Cacheable < IUserMessage , ulong > cachedMessage , IReaction reaction )
2456 {
2557 var emote = reaction . Emote ;
@@ -34,13 +66,15 @@ private async Task HandleReactionAsync(Cacheable<IUserMessage, ulong> cachedMess
3466 return ;
3567 }
3668
37- var isIgnoredFromStarboard = await designatedChannelService
38- . ChannelHasDesignation ( channel . Guild . Id , channel . Id , DesignatedChannelType . IgnoredFromStarboard , default ) ;
69+ if ( await IsChannelIgnoredFromStarboard ( channel ) )
70+ {
71+ return ;
72+ }
3973
4074 var starboardExists = await designatedChannelService
4175 . HasDesignatedChannelForType ( channel . GuildId , DesignatedChannelType . Starboard ) ;
4276
43- if ( isIgnoredFromStarboard || ! starboardExists )
77+ if ( ! starboardExists )
4478 {
4579 return ;
4680 }
0 commit comments