11using Discord . Interactions ;
22using Octokit ;
3+ using Release = ForgejoApiClient . Api . Release ;
34
45namespace RyuBot . Commands . Interactions . Modules ;
56
@@ -28,32 +29,32 @@ public Task<RuntimeResult> LatestReleaseAsync(
2829 private async Task < RuntimeResult > LatestRyubingReleaseAsync ( string rc )
2930 {
3031 var latest = rc . EqualsIgnoreCase ( "Canary" )
31- ? await GitLab . GetLatestCanaryAsync ( )
32+ ? await ForgejoService . GetLatestCanaryAsync ( )
3233 : rc . EqualsIgnoreCase ( "Stable" )
33- ? await GitLab . GetLatestStableAsync ( )
34+ ? await ForgejoService . GetLatestStableAsync ( )
3435 : null ;
3536
3637 if ( latest is null )
3738 return BadRequest (
3839 $ "Unknown release channel { rc } . Please wait for the autocomplete suggestions to fill in if you aren't sure what to put!") ;
3940
40- var windowsX64 = latest . Assets . Links
41- . FirstOrDefault ( x => x . AssetName . ContainsIgnoreCase ( "win_x64" ) ) ;
42- var windowsArm64 = latest . Assets . Links
43- . FirstOrDefault ( x => x . AssetName . ContainsIgnoreCase ( "win_arm64" ) ) ;
44- var linuxX64 = latest . Assets . Links
45- . FirstOrDefault ( x => x . AssetName . ContainsIgnoreCase ( "linux_x64" ) ) ;
46- var linuxX64AppImage = latest . Assets . Links
47- . FirstOrDefault ( x => x . AssetName . EndsWithIgnoreCase ( "x64.AppImage" ) ) ;
48- var macOs = latest . Assets . Links
49- . FirstOrDefault ( x => x . AssetName . ContainsIgnoreCase ( "macos_universal" ) ) ;
50- var linuxArm64 = latest . Assets . Links
51- . FirstOrDefault ( x => x . AssetName . ContainsIgnoreCase ( "linux_arm64" ) ) ;
52- var linuxArm64AppImage = latest . Assets . Links
53- . FirstOrDefault ( x => x . AssetName . EndsWithIgnoreCase ( "arm64.AppImage" ) ) ;
41+ var windowsX64 = latest . assets ?
42+ . FirstOrDefault ( x => x . name . ContainsIgnoreCase ( "win_x64" ) ) ;
43+ var windowsArm64 = latest . assets ?
44+ . FirstOrDefault ( x => x . name . ContainsIgnoreCase ( "win_arm64" ) ) ;
45+ var linuxX64 = latest . assets ?
46+ . FirstOrDefault ( x => x . name . ContainsIgnoreCase ( "linux_x64" ) ) ;
47+ var linuxX64AppImage = latest . assets ?
48+ . FirstOrDefault ( x => x . name . EndsWithIgnoreCase ( "x64.AppImage" ) ) ;
49+ var macOs = latest . assets ?
50+ . FirstOrDefault ( x => x . name . ContainsIgnoreCase ( "macos_universal" ) ) ;
51+ var linuxArm64 = latest . assets ?
52+ . FirstOrDefault ( x => x . name . ContainsIgnoreCase ( "linux_arm64" ) ) ;
53+ var linuxArm64AppImage = latest . assets ?
54+ . FirstOrDefault ( x => x . name . EndsWithIgnoreCase ( "arm64.AppImage" ) ) ;
5455
5556 StringBuilder releaseBody = new ( ) ;
56- releaseBody . AppendLine ( DiscordHelper . Zws ) . AppendLine ( "### Downloads " ) ;
57+ releaseBody . Append ( $ "Total downloads: { latest . assets ? . Sum ( x => x . download_count ?? 0 ) ?? 0 } " ) . AppendLine ( DiscordHelper . Zws ) . AppendLine ( "### Links " ) ;
5758
5859 applyArtifact ( windowsX64 , "Windows x64" ) ;
5960 applyArtifacts ( ( linuxX64 , linuxX64AppImage ) , "Linux x64" ) ;
@@ -64,32 +65,32 @@ private async Task<RuntimeResult> LatestRyubingReleaseAsync(string rc)
6465 return Ok ( CreateReplyBuilder ( )
6566 . WithEmbed ( embed =>
6667 {
67- embed . WithTitle ( $ "Ryujinx { latest . Name } ". Trim ( ) ) . WithUrl ( latest . Links . Self ) ;
68- embed . WithAuthor ( latest . Author . Name , latest . Author . AvatarUrl ) ;
68+ embed . WithTitle ( $ "Ryujinx { latest . name } ". Trim ( ) ) . WithUrl ( latest . html_url ) ;
69+ embed . WithAuthor ( latest . author ! . login_name , latest . author . avatar_url ) ;
6970 embed . WithDescription ( releaseBody ) ;
70- embed . WithTimestamp ( latest . CreatedAt ) ;
71+ embed . WithTimestamp ( latest . created_at ?? DateTimeOffset . Now ) ;
7172 } ) ) ;
7273
73- void applyArtifact ( GitLabReleaseJsonResponse . AssetLink asset , string friendlyName )
74+ void applyArtifact ( ForgejoApiClient . Api . Attachment asset , string friendlyName )
7475 {
7576 if ( asset is null )
7677 return ;
7778
78- releaseBody . AppendLine ( $ "{ Format . Url ( friendlyName , asset . Url ) } ") ;
79+ releaseBody . AppendLine ( $ "{ Format . Url ( friendlyName , asset . browser_download_url ) } ") ;
7980 }
8081
8182 void applyArtifacts (
82- ( GitLabReleaseJsonResponse . AssetLink Normal , GitLabReleaseJsonResponse . AssetLink AppImage ) asset ,
83+ ( ForgejoApiClient . Api . Attachment Normal , ForgejoApiClient . Api . Attachment AppImage ) asset ,
8384 string friendlyName )
8485 {
8586 if ( asset . Normal != null )
8687 {
87- releaseBody . Append ( $ "{ Format . Url ( friendlyName , asset . Normal . Url ) } ") ;
88+ releaseBody . Append ( $ "{ Format . Url ( friendlyName , asset . Normal . browser_download_url ) } ") ;
8889 }
8990
9091 if ( asset . AppImage != null )
9192 {
92- releaseBody . AppendLine ( $ "({ Format . Url ( "AppImage" , asset . AppImage . Url ) } )") ;
93+ releaseBody . AppendLine ( $ "({ Format . Url ( "AppImage" , asset . AppImage . browser_download_url ) } )") ;
9394 }
9495 else if ( asset . Normal != null )
9596 releaseBody . AppendLine ( ) ;
0 commit comments