Commit 719b6dd0ac
Unsigned
Layout: unified · split
internal/discord.go +12 −12
| @@ -10,29 +10,26 @@ func DiscordPresence(clientId string, anime Anime, IsPaused bool) error { | ||
| 10 | 10 | if err != nil { |
| 11 | 11 | return err |
| 12 | 12 | } |
| 13 | ||
| 13 | 14 | var state string |
| 14 | 15 | if IsPaused { |
| 15 | state = fmt.Sprintf("\nEpisode %d - %d:%02d (Paused)", | |
| 16 | state = fmt.Sprintf("\nEpisode %d - %s (Paused)", | |
| 16 | 17 | anime.Ep.Number, |
| 17 | ConvertSecondsToMinutes(anime.Ep.Player.PlaybackTime), | |
| 18 | anime.Ep.Player.PlaybackTime % 60, | |
| 18 | FormatTime(anime.Ep.Player.PlaybackTime), | |
| 19 | 19 | ) |
| 20 | 20 | } else { |
| 21 | state = fmt.Sprintf("\nEpisode %d - %d:%02d / %d:%02d", | |
| 21 | state = fmt.Sprintf("\nEpisode %d - %s / %s", | |
| 22 | 22 | anime.Ep.Number, |
| 23 | ConvertSecondsToMinutes(anime.Ep.Player.PlaybackTime), | |
| 24 | anime.Ep.Player.PlaybackTime % 60, | |
| 25 | ConvertSecondsToMinutes(anime.Ep.Duration), | |
| 26 | anime.Ep.Duration % 60, | |
| 23 | FormatTime(anime.Ep.Player.PlaybackTime), | |
| 24 | FormatTime(anime.Ep.Duration), | |
| 27 | 25 | ) |
| 28 | 26 | } |
| 27 | ||
| 29 | 28 | err = client.SetActivity(client.Activity{ |
| 30 | 29 | Details: fmt.Sprintf("%s", GetAnimeName(anime)), // Large text |
| 31 | 30 | LargeImage: anime.CoverImage, |
| 32 | 31 | LargeText: GetAnimeName(anime), // Would display while hovering over the large image |
| 33 | 32 | State: state, |
| 34 | // SmallImage: anime.CoverImage, // Image would appear in the bottom left corner | |
| 35 | // SmallText: fmt.Sprintf("%s", anime.Ep.Title.English), // Would display while hovering over the small image | |
| 36 | 33 | Buttons: []*client.Button{ |
| 37 | 34 | &client.Button{ |
| 38 | 35 | Label: "View on AniList", // Button label |
| @@ -50,6 +47,9 @@ func DiscordPresence(clientId string, anime Anime, IsPaused bool) error { | ||
| 50 | 47 | return nil |
| 51 | 48 | } |
| 52 | 49 | |
| 53 | func ConvertSecondsToMinutes(seconds int) int { | |
| 54 | return seconds / 60 | |
| 50 | func FormatTime(seconds int) string { | |
| 51 | hours := seconds / 3600 | |
| 52 | minutes := (seconds % 3600) / 60 | |
| 53 | remainingSeconds := seconds % 60 | |
| 54 | return fmt.Sprintf("%d:%02d:%02d", hours, minutes, remainingSeconds) | |
| 55 | 55 | } |