Commit f1f1938da5

f1f1938da5955ca165dcd905468f02a2909b8cc6

parent: d4c9b2a492

Unsigned

Vedant Deshmukh <73630434+Vedant9500@users.noreply.github.com> · 2024-12-18 15:53 UTC

The FormatTime function has been updated to use minutes if episode length is less than one hour

Layout: unified · split

internal/discord.go +6 −4
@@ -28,12 +28,10 @@ func DiscordPresence(clientId string, anime Anime, IsPaused bool) error {
28 err = client.SetActivity(client.Activity{ 28 err = client.SetActivity(client.Activity{
29 Details: fmt.Sprintf("%s", GetAnimeName(anime)), // Large text 29 Details: fmt.Sprintf("%s", GetAnimeName(anime)), // Large text
30 LargeImage: anime.CoverImage, 30 LargeImage: anime.CoverImage,
31 LargeText: GetAnimeName(anime), // Displays while hovering over the large image 31 LargeText: GetAnimeName(anime), // Would display while hovering over the large image
32 State: state, 32 State: state,
33
34 //SmallImage: anime.SmallCoverImage, // Image for the bottom left corner 33 //SmallImage: anime.SmallCoverImage, // Image for the bottom left corner
35 //SmallText: fmt.Sprintf("Episode: %s", anime.Ep.Title.English), // Text when hovering over the small image 34 //SmallText: fmt.Sprintf("Episode: %s", anime.Ep.Title.English), // Text when hovering over the small image
36
37 Buttons: []*client.Button{ 35 Buttons: []*client.Button{
38 &client.Button{ 36 &client.Button{
39 Label: "View on AniList", // Button label 37 Label: "View on AniList", // Button label
@@ -55,5 +53,9 @@ func FormatTime(seconds int) string {
55 hours := seconds / 3600 53 hours := seconds / 3600
56 minutes := (seconds % 3600) / 60 54 minutes := (seconds % 3600) / 60
57 remainingSeconds := seconds % 60 55 remainingSeconds := seconds % 60
58 return fmt.Sprintf("%d:%02d:%02d", hours, minutes, remainingSeconds) 56
57 if hours > 0 {
58 return fmt.Sprintf("%d:%02d:%02d", hours, minutes, remainingSeconds)
59 }
60 return fmt.Sprintf("%d:%02d", minutes, remainingSeconds)
59} 61}