Better error handling
This commit is contained in:
parent
26e931f44f
commit
0130ec538c
1 changed files with 13 additions and 23 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue