mirror of
https://github.com/Xevion/banner.git
synced 2025-12-07 18:06:22 -06:00
Add class duration to time command output
This commit is contained in:
@@ -75,6 +75,9 @@ func TimeCommandHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
duration := courseMeetingTime.timeEnd.Sub(courseMeetingTime.timeStart)
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||||
Data: &discordgo.InteractionResponseData{
|
Data: &discordgo.InteractionResponseData{
|
||||||
@@ -95,7 +98,7 @@ func TimeCommandHandler(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Start/End Time",
|
Name: "Start/End Time",
|
||||||
Value: fmt.Sprintf("%s - %s", courseMeetingTime.timeStart.String(), courseMeetingTime.timeEnd.String()),
|
Value: fmt.Sprintf("%s - %s (%d min)", courseMeetingTime.timeStart.String(), courseMeetingTime.timeEnd.String(), int64(duration.Minutes())),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Days of Week",
|
Name: "Days of Week",
|
||||||
|
|||||||
@@ -162,6 +162,10 @@ type NaiveTime struct {
|
|||||||
Minutes uint
|
Minutes uint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nt NaiveTime) Sub(other NaiveTime) time.Duration {
|
||||||
|
return time.Hour*time.Duration(nt.Hours-other.Hours) + time.Minute*time.Duration(nt.Minutes-other.Minutes)
|
||||||
|
}
|
||||||
|
|
||||||
func ParseNaiveTime(integer uint64) NaiveTime {
|
func ParseNaiveTime(integer uint64) NaiveTime {
|
||||||
minutes := uint(integer % 100)
|
minutes := uint(integer % 100)
|
||||||
hours := uint(integer / 100)
|
hours := uint(integer / 100)
|
||||||
|
|||||||
Reference in New Issue
Block a user