Skip to content

Commit f40c07c

Browse files
add meeting create
1 parent d530feb commit f40c07c

File tree

5 files changed

+62
-13
lines changed

5 files changed

+62
-13
lines changed

internal/pkg/brokers/discordBroker/discordBroker.go

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func CreateMeeting(ctx context.Context, startDate string, endDate string) (models.DiscordResponses, error) {
14-
startDateTime, err := time.Parse("2006-01-02", startDate)
14+
startDateTime, err := time.Parse("2006-01-02", startDate) //YYYY-MM-DD
1515
if err != nil {
1616
return models.DiscordResponses{}, fmt.Errorf("failed converting startDate: %v", err)
1717
}
@@ -24,26 +24,72 @@ func CreateMeeting(ctx context.Context, startDate string, endDate string) (model
2424
days := endDateTime.Sub(startDateTime).Hours() / 24
2525
daysInt := int(math.Round(days))
2626
var responseMessages []discordgo.Message
27+
initialMessage := discordgo.Message{
28+
Content: "Please react with your availability during the following days. Try to react with as many emojis as possible.",
29+
}
30+
responseMessages = append(responseMessages, initialMessage)
2731
for i := 0; i < daysInt; i++ {
2832
displayDateTime := startDateTime.AddDate(0, 0, i)
2933
dayName := displayDateTime.Weekday()
30-
fmt.Println(dayName)
3134

35+
formattedDisplayDate := displayDateTime.Format("2006-01-02")
36+
37+
firstReactions := createFirstHalfReactionsList()
3238
messageReturnFirstHalf := discordgo.Message{
33-
Content: "Please fill in your available time slots for first half of" + dayName.String() + ", date: " + displayDateTime.String(),
39+
Content: "First half of " + dayName.String() + "\ndate(YYYY-MM-DD): " + formattedDisplayDate + "\nAll times are in GMT",
3440
// TODO: start from here
35-
//Reactions: &[]discordgo.MessageReaction{},
41+
Reactions: firstReactions,
3642
}
43+
44+
secondReactions := createSecondHalfReactionsList()
3745
messageReturnSecondHalf := discordgo.Message{
38-
Content: "Please fill in your available time slots for second half of" + dayName.String() + ", date: " + displayDateTime.String(),
46+
Content: "Second half of " + dayName.String() + "\ndate(YYYY-MM-DD): " + formattedDisplayDate + "\nAll times are in GMT",
47+
Reactions: secondReactions,
3948
}
4049

41-
responseMessages[2*i] = messageReturnFirstHalf
42-
secondIndex := (2 * i) + 1
43-
responseMessages[secondIndex] = messageReturnSecondHalf
50+
responseMessages = append(responseMessages, messageReturnFirstHalf)
51+
responseMessages = append(responseMessages, messageReturnSecondHalf)
4452
}
4553
response := models.DiscordResponses{
4654
Responses: responseMessages,
4755
}
4856
return response, nil
4957
}
58+
59+
func createFirstHalfReactionsList() []*discordgo.MessageReactions {
60+
emojiList := []string{":12to1am:1001391717376860211", ":1to2am:1001391662674739271", ":2to3am:1001391667061989376", ":3to4am:1001391671914811422", ":4to5am:1001391676180414644", ":5to6am:1001391680747995246",
61+
":6to7am:1001391686104133633", ":7to8am:1001391690822729739", "8to9am:1001391696279502859", ":9to10am:1001391700972929034",
62+
":10to11am:1001391706522009611", ":11to12noon:1001391714826735686"}
63+
var response []*discordgo.MessageReactions
64+
for _, emojiName := range emojiList {
65+
discordEmoji := discordgo.Emoji{
66+
Name: emojiName,
67+
}
68+
69+
discordReaction := discordgo.MessageReactions{
70+
Emoji: &discordEmoji,
71+
}
72+
73+
response = append(response, &discordReaction)
74+
}
75+
return response
76+
}
77+
78+
func createSecondHalfReactionsList() []*discordgo.MessageReactions {
79+
emojiList := []string{":1to2pm:1001391664805462046", ":2to3pm:1001391669574373386", ":3to4pm:1001391673982599189",
80+
":4to5pm:1001391678688600144", ":5to6pm:1001391683054862386", ":6to7pm:1001391688641675364", ":7to8pm:1001391693322530847",
81+
":8to9pm:1001391698594762774", ":9to10pm:1001391703632125952", ":10to11pm:1001391709130862694", ":11to12mid:1001391712108822549"}
82+
var response []*discordgo.MessageReactions
83+
for _, emojiName := range emojiList {
84+
discordEmoji := discordgo.Emoji{
85+
Name: emojiName,
86+
}
87+
88+
discordReaction := discordgo.MessageReactions{
89+
Emoji: &discordEmoji,
90+
}
91+
92+
response = append(response, &discordReaction)
93+
}
94+
return response
95+
}

internal/pkg/commandHandlers/commandHandlers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ func CommandTranslation(command string, brokerContext context.Context) (models.D
7575

7676
func splitString(command string) []string {
7777
lowerCaseCommand := strings.ToLower(command)
78+
7879
words := strings.Fields(lowerCaseCommand)
80+
7981
return words
8082
}

internal/pkg/discordCommandInterface/dci.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ func messageRead(s *discordgo.Session, m *discordgo.MessageCreate) {
7474
sentMessage, _ := s.ChannelMessageSend(m.ChannelID, resp.Content)
7575
if len(resp.Reactions) > 0 {
7676
for _, reaction := range resp.Reactions {
77-
err = s.MessageReactionAdd(m.ChannelID, sentMessage.ID, reaction.Emoji.ID)
77+
fmt.Print(reaction.Emoji.Name)
78+
err = s.MessageReactionAdd(m.ChannelID, sentMessage.ID, reaction.Emoji.Name)
7879
if err != nil {
7980
log.Fatal(err)
8081
}

internal/pkg/models/models.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ type DiscordResponses struct {
99
type DiscordReactions struct {
1010
Reactions []discordgo.MessageReaction
1111
}
12+
13+
type DiscordEmojis struct {
14+
Emojis []discordgo.Emoji
15+
}

internal/pkg/utils/utils.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package utils
22

33
import (
44
"context"
5-
"log"
65

76
"github.com/rog-golang-buddies/dev-buddy/internal/pkg/config"
87
"github.com/rog-golang-buddies/dev-buddy/internal/pkg/constants"
@@ -19,9 +18,6 @@ func SetContext() (context.Context, error) {
1918
return ctx, err
2019
}
2120

22-
log.Print(configValues.GithubPAT)
23-
log.Print(configValues.DiscordToken)
24-
2521
// setting the discord token value to context
2622
ctx = context.WithValue(ctx, constants.BotTokenHeader, configValues.DiscordToken)
2723

0 commit comments

Comments
 (0)