Added allowlist

This commit is contained in:
2023-12-29 01:31:36 -07:00
parent 27a400a720
commit aa10576330
3 changed files with 31 additions and 14 deletions

View File

@ -1,6 +1,9 @@
package lib
import (
"os"
"strings"
"github.com/diamondburned/arikawa/v3/discord"
)
@ -60,3 +63,22 @@ func GetUserObject(event discord.InteractionEvent) Userish {
return directUser{event.User}
}
}
func CooldownHandler(event discord.InteractionEvent) bool {
user := GetUserObject(event)
allowList := strings.Split(os.Getenv("COOLDOWN_ALLOW_LIST"), ",")
// Check if the user ID is in the allowList
for _, id := range allowList {
if id == user.ID().String() {
return true
}
}
cachedVal := GetCache(user.ID().String() + ":" + "hdpic")
if cachedVal != "nil" {
return false
}
SetCache(user.ID().String()+":"+"hdpic", user.ID().String()+":"+"hdpic", 10)
return true
}