File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 99
1010 <ItemGroup >
1111 <PackageReference Include =" CurseForge.APIClient" Version =" 4.2.0" />
12- <PackageReference Include =" Discord.Net" Version =" 3.17.2 " />
12+ <PackageReference Include =" Discord.Net" Version =" 3.17.4 " />
1313 <PackageReference Include =" Microsoft.Extensions.Hosting" Version =" 9.0.4" />
1414 <PackageReference Include =" Microsoft.Extensions.Hosting.Abstractions" Version =" 9.0.4" />
1515 </ItemGroup >
Original file line number Diff line number Diff line change 44namespace CFDiscordBot . Commands
55{
66 [ Group ( "lookup" , "Does lookups against CurseForge" ) ]
7- public partial class Lookup ( ApiClient apiClient ) : InteractionModuleBase < ShardedInteractionContext > { }
7+ public partial class Lookup ( ApiClient apiClient , IHttpClientFactory httpClientFactory ) : InteractionModuleBase < ShardedInteractionContext > { }
88}
Original file line number Diff line number Diff line change @@ -183,6 +183,25 @@ int projectId
183183 ) ;
184184 }
185185
186+ // If the game is Minecraft Bedrock, we do an additional check if MCPEDL has the mod available through a slug lookup.
187+ if ( mod . GameId == 78022 )
188+ {
189+ var client = httpClientFactory . CreateClient ( ) ;
190+ client . DefaultRequestHeaders . TryAddWithoutValidation ( "User-Agent" , "CFLookup Discord Bot/1.0; (+cflookup@itssimple.se)" ) ;
191+ client . BaseAddress = new Uri ( "https://mcpedl.com/" ) ;
192+
193+ var res = await client . GetAsync ( mod . Slug ) ;
194+
195+ if ( res != null && res . IsSuccessStatusCode && ! res . RequestMessage ! . RequestUri ! . ToString ( ) . Contains ( "notfound" ) )
196+ {
197+ buttons . WithButton (
198+ style : ButtonStyle . Link ,
199+ label : "MCPEDL" ,
200+ url : $ "https://mcpedl.com/{ mod . Slug } "
201+ ) ;
202+ }
203+ }
204+
186205 await RespondAsync ( $ "Project `{ projectId } ` is: **[{ mod . Name } ](https://cflookup.com/{ projectId } )**\n " +
187206 $ "{ summaryText } ",
188207 embeds : new [ ] { projectEmbed . Build ( ) } ,
You can’t perform that action at this time.
0 commit comments