Better error handling
This commit is contained in:
@ -51,23 +51,13 @@ func CheckAndApplyCooldown(s *discordgo.Session, i *discordgo.InteractionCreate,
|
|||||||
cooldownManager := GetCooldownManager()
|
cooldownManager := GetCooldownManager()
|
||||||
user, err := GetUser(i)
|
user, err := GetUser(i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
RespondWithError(s, i, "Error processing command: "+err.Error())
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Error processing command: " + err.Error(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
canUse, remaining := cooldownManager.CheckCooldown(user.ID, commandName)
|
canUse, remaining := cooldownManager.CheckCooldown(user.ID, commandName)
|
||||||
if !canUse {
|
if !canUse {
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
RespondWithError(s, i, fmt.Sprintf("You can use this command again in %v", remaining.Round(time.Second)))
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: fmt.Sprintf("You can use this command again in %v", remaining.Round(time.Second)),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user