|
|
@ -581,7 +581,7 @@ func main() {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"schedule": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error {
|
|
|
|
"schedule": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error {
|
|
|
|
// get schedule from now to 4 mondays into the future
|
|
|
|
// get schedule from now to 4 mondays into the future
|
|
|
|
sched, err := store.GetSchedule(ctx, themis.NextMonday(), themis.NextMonday().Add(4*7*24*time.Hour))
|
|
|
|
sched, err := store.GetSchedule(ctx, themis.NextWednesday(), themis.NextWednesday().Add(4*7*24*time.Hour))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
|
|
if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
|
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
|
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
|
@ -643,7 +643,7 @@ func main() {
|
|
|
|
"absent": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error {
|
|
|
|
"absent": func(ctx context.Context, s *discordgo.Session, i *discordgo.InteractionCreate) error {
|
|
|
|
var rawDate string
|
|
|
|
var rawDate string
|
|
|
|
if len(i.ApplicationCommandData().Options) == 0 {
|
|
|
|
if len(i.ApplicationCommandData().Options) == 0 {
|
|
|
|
rawDate = themis.NextMonday().Format(time.DateOnly)
|
|
|
|
rawDate = themis.NextWednesday().Format(time.DateOnly)
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
rawDate = i.ApplicationCommandData().Options[0].StringValue()
|
|
|
|
rawDate = i.ApplicationCommandData().Options[0].StringValue()
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -739,7 +739,7 @@ func main() {
|
|
|
|
defer span.End()
|
|
|
|
defer span.End()
|
|
|
|
|
|
|
|
|
|
|
|
log.Info().Msg("sending weekly reminder")
|
|
|
|
log.Info().Msg("sending weekly reminder")
|
|
|
|
absentees, err := store.GetAbsentees(ctx, themis.NextMonday())
|
|
|
|
absentees, err := store.GetAbsentees(ctx, themis.NextWednesday())
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Error().Err(err).Msg("failed to get absentees for next session")
|
|
|
|
log.Error().Err(err).Msg("failed to get absentees for next session")
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -884,7 +884,7 @@ func registerHandlers(sess *discordgo.Session, handlers map[string]Handler) {
|
|
|
|
userId := i.Member.User.ID
|
|
|
|
userId := i.Member.User.ID
|
|
|
|
log.Info().Ctx(ctx).Str("message_component", "schedule-response").Str("userid", userId).Msg("handling message component interaction")
|
|
|
|
log.Info().Ctx(ctx).Str("message_component", "schedule-response").Str("userid", userId).Msg("handling message component interaction")
|
|
|
|
|
|
|
|
|
|
|
|
if err := store.AddAbsence(ctx, themis.NextMonday(), userId); err != nil {
|
|
|
|
if err := store.AddAbsence(ctx, themis.NextWednesday(), userId); err != nil {
|
|
|
|
if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
|
|
if err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
|
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
|
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
|
|
Data: &discordgo.InteractionResponseData{
|
|
|
|
Data: &discordgo.InteractionResponseData{
|
|
|
|