himbot/command/hs.go

26 lines
626 B
Go
Raw Normal View History

package command
import (
2024-10-21 23:50:17 -06:00
"fmt"
2024-10-22 12:24:02 -06:00
"himbot/lib"
2024-10-21 23:50:17 -06:00
"github.com/bwmarrin/discordgo"
)
2024-10-22 17:07:53 -06:00
func HsCommand(s *discordgo.Session, i *discordgo.InteractionCreate) (string, error) {
options := i.ApplicationCommandData().Options
if len(options) == 0 || options[0].Type != discordgo.ApplicationCommandOptionString {
return "", fmt.Errorf("please provide a nickname")
}
nickname := options[0].StringValue()
2024-10-22 12:24:02 -06:00
2024-10-22 17:07:53 -06:00
user, err := lib.GetUser(i)
if err != nil {
return "", fmt.Errorf("error processing command: %w", err)
}
2024-10-22 12:24:02 -06:00
2024-10-22 17:07:53 -06:00
response := fmt.Sprintf("%s was %s's nickname in high school!", nickname, user.Username)
2024-10-22 12:24:02 -06:00
2024-10-22 17:07:53 -06:00
return response, nil
}