2024-01-21 00:27:52 -07:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
2024-10-21 23:50:17 -06:00
|
|
|
"fmt"
|
2024-10-22 12:24:02 -06:00
|
|
|
"himbot/lib"
|
|
|
|
"time"
|
2024-01-21 00:27:52 -07:00
|
|
|
|
2024-10-21 23:50:17 -06:00
|
|
|
"github.com/bwmarrin/discordgo"
|
2024-01-21 00:27:52 -07:00
|
|
|
)
|
|
|
|
|
2024-10-21 23:50:17 -06:00
|
|
|
func HsCommand(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
2024-10-22 12:24:02 -06:00
|
|
|
if !lib.CheckAndApplyCooldown(s, i, "hs", 10*time.Second) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
options := i.ApplicationCommandData().Options
|
|
|
|
if len(options) == 0 || options[0].Type != discordgo.ApplicationCommandOptionString {
|
|
|
|
lib.RespondWithError(s, i, "Please provide a nickname.")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
nickname := options[0].StringValue()
|
|
|
|
|
|
|
|
user, err := lib.GetUser(i)
|
|
|
|
if err != nil {
|
|
|
|
lib.RespondWithError(s, i, "Error processing command: "+err.Error())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
response := fmt.Sprintf("%s was %s's nickname in high school!", nickname, user.Username)
|
|
|
|
|
|
|
|
err = s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
|
|
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
|
|
Data: &discordgo.InteractionResponseData{
|
|
|
|
Content: response,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Error responding to interaction:", err)
|
|
|
|
lib.RespondWithError(s, i, "An error occurred while processing the command")
|
|
|
|
}
|
2024-01-21 00:27:52 -07:00
|
|
|
}
|