99using GitcgPainter . ImageCreators . Deck ;
1010using HoyolabHttpClient . Models . Interfaces ;
1111using Microsoft . Extensions . Options ;
12+ using NetCord ;
1213using NetCord . Gateway ;
1314using NetCord . Hosting . Gateway ;
1415using NetCord . Rest ;
@@ -32,10 +33,20 @@ public async ValueTask HandleAsync(Message message)
3233 return ;
3334
3435 var dbChannel = await FindDbChannelAsync ( message . ChannelId ) ;
36+
37+ var guildThread = message . Channel as GuildThread ;
3538
36- if ( dbChannel == null )
39+ if ( dbChannel == null && guildThread == null )
3740 return ;
3841
42+ if ( guildThread != null )
43+ {
44+ dbChannel = await FindDbChannelAsync ( guildThread . ParentId ) ;
45+
46+ if ( dbChannel == null )
47+ return ;
48+ }
49+
3950 var channel = message . Channel ;
4051 if ( channel == null )
4152 return ;
@@ -80,15 +91,18 @@ await message.AddReactionAsync(
8091 . WithEmbeds ( [ summaryEmbed ] )
8192 ) ;
8293
83- var id = Convert . ToBase64String (
84- BitConverter . GetBytes ( message . Id )
85- ) ;
94+ if ( guildThread == null )
95+ {
96+ var id = Convert . ToBase64String (
97+ BitConverter . GetBytes ( message . Id )
98+ ) ;
8699
87- channel = await summaryMessage . CreateGuildThreadAsync (
88- new GuildThreadFromMessageProperties (
89- name : $ "Sharing code list #{ id } "
90- )
91- ) ;
100+ channel = await summaryMessage . CreateGuildThreadAsync (
101+ new GuildThreadFromMessageProperties (
102+ name : $ "Sharing code list #{ id } "
103+ )
104+ ) ;
105+ }
92106 }
93107
94108 var deckImageCreator = deckImageCreatorCollection . GameBackground ;
@@ -183,16 +197,16 @@ await message.AddReactionAsync(
183197 // .WithEmbeds());
184198 }
185199
186- private async ValueTask < DiscordCardCodeChannel ? >
187- FindDbChannelAsync ( ulong channelId )
200+ private async ValueTask < DiscordCardCodeChannel ? >
201+ FindDbChannelAsync ( ulong ? channelId )
188202 {
189203 await using var scope = serviceScopeFactory . CreateAsyncScope ( ) ;
190204 var cardCodeChannelService = scope . ServiceProvider
191205 . GetRequiredService < DiscordCardCodeChannelService > ( ) ;
192-
206+
193207 var dbChannel = await cardCodeChannelService
194208 . FindAsync ( channelId ) ;
195-
209+
196210 return dbChannel ;
197211 }
198212
0 commit comments