Re-write the libs with discordgo

This commit is contained in:
2024-10-22 12:24:02 -06:00
parent 7328a0139e
commit 26e931f44f
9 changed files with 215 additions and 238 deletions

View File

@ -1,12 +1,31 @@
package command
import "github.com/bwmarrin/discordgo"
import (
"fmt"
"himbot/lib"
"time"
"github.com/bwmarrin/discordgo"
)
func PingCommand(s *discordgo.Session, i *discordgo.InteractionCreate) {
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
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{
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "Pong!",
Content: responseContent,
},
})
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")
}
}