mirror of
https://github.com/Xevion/banner.git
synced 2025-12-08 22:06:32 -06:00
Remove course index from embed, use switch for optional option handling
This commit is contained in:
14
commands.go
14
commands.go
@@ -49,9 +49,13 @@ func SearchCommandHandler(session *discordgo.Session, interaction *discordgo.Int
|
|||||||
data := interaction.ApplicationCommandData()
|
data := interaction.ApplicationCommandData()
|
||||||
query := NewQuery().Credits(3, 6)
|
query := NewQuery().Credits(3, 6)
|
||||||
|
|
||||||
countOption := data.Options[2]
|
for _, option := range data.Options {
|
||||||
if countOption.Value != nil {
|
switch option.Name {
|
||||||
query.MaxResults(int(countOption.IntValue()))
|
case "name":
|
||||||
|
case "code":
|
||||||
|
case "max":
|
||||||
|
query.MaxResults(int(option.IntValue()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
courses, err := Search(query, "", false)
|
courses, err := Search(query, "", false)
|
||||||
@@ -68,10 +72,10 @@ func SearchCommandHandler(session *discordgo.Session, interaction *discordgo.Int
|
|||||||
fetch_time := time.Now()
|
fetch_time := time.Now()
|
||||||
fields := []*discordgo.MessageEmbedField{}
|
fields := []*discordgo.MessageEmbedField{}
|
||||||
|
|
||||||
for i, course := range courses.Data {
|
for _, course := range courses.Data {
|
||||||
fields = append(fields, &discordgo.MessageEmbedField{
|
fields = append(fields, &discordgo.MessageEmbedField{
|
||||||
Name: "Name",
|
Name: "Name",
|
||||||
Value: fmt.Sprintf("%s %d", course.CourseTitle, i),
|
Value: course.CourseTitle,
|
||||||
Inline: true,
|
Inline: true,
|
||||||
}, &discordgo.MessageEmbedField{
|
}, &discordgo.MessageEmbedField{
|
||||||
Name: "CRN",
|
Name: "CRN",
|
||||||
|
|||||||
Reference in New Issue
Block a user