@@ -14,13 +14,17 @@ int fileId
1414 )
1515 {
1616 CurseForge . APIClient . Models . Mods . Mod ? mod = null ;
17+ CurseForge . APIClient . Models . Files . File ? file = null ;
1718 var projectId = 0 ;
1819 try
1920 {
20- var projectFiles = await apiClient . GetFilesAsync ( new CurseForge . APIClient . Models . Files . GetModFilesRequestBody { FileIds = [ fileId ] } ) ;
21+ var projectFiles =
22+ await apiClient . GetFilesAsync ( new CurseForge . APIClient . Models . Files . GetModFilesRequestBody
23+ { FileIds = [ fileId ] } ) ;
2124 if ( projectFiles . Data . Count > 0 )
2225 {
23- var project = await apiClient . GetModAsync ( projectFiles . Data . First ( ) . ModId ) ;
26+ file = projectFiles . Data . First ( ) ;
27+ var project = await apiClient . GetModAsync ( file . ModId ) ;
2428 mod = project . Data ;
2529 projectId = project . Data . Id ;
2630 }
@@ -68,14 +72,23 @@ int fileId
6872
6973 var categories = string . Join ( ", " , mod . Categories . Select ( c => $ "[{ c . Name } ]({ c . Url } )") ) ;
7074
71- var fields = new List < EmbedFieldBuilder > {
72- new ( ) { Name = "Author" , Value = string . Join ( ", " , mod . Authors . Select ( c => $ "[{ c . Name } ]({ c . Url } )") ) , IsInline = true } ,
75+ var fields = new List < EmbedFieldBuilder >
76+ {
77+ new ( )
78+ {
79+ Name = "Author" , Value = string . Join ( ", " , mod . Authors . Select ( c => $ "[{ c . Name } ]({ c . Url } )") ) ,
80+ IsInline = true
81+ } ,
7382 new ( ) { Name = "Status" , Value = mod . Status . ToString ( ) , IsInline = true } ,
7483 new ( ) { Name = "Created" , Value = $ "<t:{ mod . DateCreated . ToUnixTimeSeconds ( ) } :F>", IsInline = true } ,
7584 new ( ) { Name = "Modified" , Value = $ "<t:{ mod . DateModified . ToUnixTimeSeconds ( ) } :F>", IsInline = true } ,
7685 new ( ) { Name = "Released" , Value = $ "<t:{ mod . DateReleased . ToUnixTimeSeconds ( ) } :F>", IsInline = true } ,
7786 new ( ) { Name = "Downloads" , Value = mod . DownloadCount . ToString ( "n0" ) , IsInline = true } ,
78- new ( ) { Name = "Mod Distribution" , Value = mod . AllowModDistribution ?? true ? "Allowed" : "Not allowed" , IsInline = true } ,
87+ new ( )
88+ {
89+ Name = "Mod Distribution" , Value = mod . AllowModDistribution ?? true ? "Allowed" : "Not allowed" ,
90+ IsInline = true
91+ } ,
7992 new ( ) { Name = "Is available" , Value = mod . IsAvailable ? "Yes" : "No" , IsInline = true }
8093 } ;
8194
@@ -84,11 +97,24 @@ int fileId
8497 fields . Add ( new EmbedFieldBuilder { Name = "Categories" , Value = categories , IsInline = false } ) ;
8598 }
8699
100+ if ( file is { GameId : 1 } )
101+ {
102+ fields . Add ( new EmbedFieldBuilder
103+ {
104+ Name = "Installable" ,
105+ Value = file . Modules . Any ( m => m . Name . EndsWith ( ".toc" ) )
106+ ? "No, potentially invalid file structure"
107+ : "Yes" ,
108+ IsInline = false
109+ } ) ;
110+ }
111+
87112 projectEmbed . Fields . AddRange ( fields ) ;
88113
89114 projectEmbed . Footer = new EmbedFooterBuilder
90115 {
91- IconUrl = "https://cdn.discordapp.com/avatars/1199770925025984513/3f52d33635a688cfd24f0d78272aaf00.png?size=256" ,
116+ IconUrl =
117+ "https://cdn.discordapp.com/avatars/1199770925025984513/3f52d33635a688cfd24f0d78272aaf00.png?size=256" ,
92118 Text = "CurseForge"
93119 } ;
94120
@@ -148,26 +174,28 @@ int fileId
148174 if ( mod . GameId == 78022 && mod . AllowModDistribution . HasValue && mod . AllowModDistribution . Value )
149175 {
150176 var client = httpClientFactory . CreateClient ( ) ;
151- client . DefaultRequestHeaders . TryAddWithoutValidation ( "User-Agent" , "CFLookup Discord Bot/1.0; (+cflookup@itssimple.se)" ) ;
177+ client . DefaultRequestHeaders . TryAddWithoutValidation ( "User-Agent" ,
178+ "CFLookup Discord Bot/1.0; (+cflookup@itssimple.se)" ) ;
152179 client . BaseAddress = new Uri ( "https://mcpedl.com/" ) ;
153180
154181 var res = await client . GetAsync ( mod . Slug ) ;
155182
156- if ( res != null && res . IsSuccessStatusCode && ! res . RequestMessage ! . RequestUri ! . ToString ( ) . Contains ( "notfound" ) )
183+ if ( res != null && res . IsSuccessStatusCode &&
184+ ! res . RequestMessage ! . RequestUri ! . ToString ( ) . Contains ( "notfound" ) )
157185 {
158186 buttons . WithButton (
159- style : ButtonStyle . Link ,
160- label : "MCPEDL" ,
161- url : $ "https://mcpedl.com/{ mod . Slug } "
162- ) ;
187+ style : ButtonStyle . Link ,
188+ label : "MCPEDL" ,
189+ url : $ "https://mcpedl.com/{ mod . Slug } "
190+ ) ;
163191 }
164192 }
165193
166194 await RespondAsync ( $ "Project `{ projectId } ` is: **[{ mod . Name } ](https://cflookup.com/{ projectId } )**\n " +
167- $ "{ summaryText } ",
195+ $ "{ summaryText } ",
168196 embeds : new [ ] { projectEmbed . Build ( ) } ,
169197 components : buttons . Build ( )
170198 ) ;
171199 }
172200 }
173- }
201+ }
0 commit comments