himbot/command/ping.go

32 lines
778 B
Go
Raw Normal View History

package command
2024-10-22 12:24:02 -06:00
import (
"fmt"
"himbot/lib"
"time"
"github.com/bwmarrin/discordgo"
)
2024-10-21 23:50:17 -06:00
func PingCommand(s *discordgo.Session, i *discordgo.InteractionCreate) {
2024-10-22 12:24:02 -06:00
if !lib.CheckAndApplyCooldown(s, i, "ping", 5*time.Second) {
return
}
// Customize the response based on whether it's a guild or DM
responseContent := "Pong!"
err := s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
2024-10-21 23:50:17 -06:00
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
2024-10-22 12:24:02 -06:00
Content: responseContent,
2024-10-21 23:50:17 -06:00
},
})
2024-10-22 12:24:02 -06:00
if err != nil {
fmt.Println("Error responding to interaction:", err)
// Optionally, you could try to send an error message to the user
lib.RespondWithError(s, i, "An error occurred while processing the command")
}
}