Spending lots of time on useless discord bots makes to make the pain go away
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package lib
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
@ -11,21 +10,15 @@ type CommandFunc func(s *discordgo.Session, i *discordgo.InteractionCreate) (str
|
||||
|
||||
func HandleCommand(commandName string, cooldownDuration time.Duration, handler CommandFunc) func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
return func(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
// Get user information first
|
||||
user, userErr := GetUser(i)
|
||||
if userErr != nil {
|
||||
RespondWithError(s, i, "Error processing command: "+userErr.Error())
|
||||
if !CheckAndApplyCooldown(s, i, commandName, cooldownDuration) {
|
||||
return
|
||||
}
|
||||
|
||||
// Store user in database
|
||||
dbErr := StoreUser(user.ID, user.Username)
|
||||
if dbErr != nil {
|
||||
// Log the error but don't stop command execution
|
||||
log.Printf("Error storing user: %v", dbErr)
|
||||
}
|
||||
// Get or create user and guild profile
|
||||
_, createUserError := GetOrCreateUserWithGuild(i.Member.User.ID, i.Member.User.Username, i.GuildID)
|
||||
|
||||
if !CheckAndApplyCooldown(s, i, commandName, cooldownDuration) {
|
||||
if createUserError != nil {
|
||||
RespondWithError(s, i, "Error creating user profile: "+createUserError.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user