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

19
main.go
View File

@ -132,13 +132,11 @@ func (h *handler) cmdPing(ctx context.Context, data cmdroute.CommandData) *api.I
func (h *handler) cmdAsk(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
// Cooldown Logic
user := lib.GetUserObject(*data.Event)
allowed := lib.CooldownHandler(*data.Event)
cachedVal := lib.GetCache(user.ID().String() + ":" + "ask")
if cachedVal != "nil" {
if !allowed {
return errorResponse(errors.New("please wait for the cooldown"))
}
lib.SetCache(user.ID().String()+":"+"ask", user.ID().String()+":"+"ask", 1)
// Command Logic
var options struct {
@ -180,14 +178,11 @@ func (h *handler) cmdAsk(ctx context.Context, data cmdroute.CommandData) *api.In
func (h *handler) cmdPic(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
// Cooldown Logic
user := lib.GetUserObject(*data.Event)
allowed := lib.CooldownHandler(*data.Event)
cachedVal := lib.GetCache(user.ID().String() + ":" + "pic")
if cachedVal != "nil" {
if !allowed {
return errorResponse(errors.New("please wait for the cooldown"))
}
lib.SetCache(user.ID().String()+":"+"pic", user.ID().String()+":"+"pic", 1)
// Command Logic
var options struct {
@ -259,13 +254,11 @@ func (h *handler) cmdPic(ctx context.Context, data cmdroute.CommandData) *api.In
func (h *handler) cmdHDPic(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
// Cooldown Logic
user := lib.GetUserObject(*data.Event)
allowed := lib.CooldownHandler(*data.Event)
cachedVal := lib.GetCache(user.ID().String() + ":" + "hdpic")
if cachedVal != "nil" {
if !allowed {
return errorResponse(errors.New("please wait for the cooldown"))
}
lib.SetCache(user.ID().String()+":"+"hdpic", user.ID().String()+":"+"hdpic", 10)
// Command Logic
var options struct {