diff --git a/go.mod b/go.mod index ea56fcc..7e010e9 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,6 @@ require ( github.com/mediocregopher/radix/v4 v4.1.4 github.com/redis/go-redis/v9 v9.3.1 github.com/replicate/replicate-go v0.14.2 - github.com/sashabaranov/go-openai v1.17.9 + github.com/sashabaranov/go-openai v1.17.10 golang.org/x/time v0.5.0 // indirect ) diff --git a/go.sum b/go.sum index 650fe0e..b829e77 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/replicate/replicate-go v0.14.2 h1:XgK+REvYrWs7qDeyugxHA93h31qBhEFk/3p github.com/replicate/replicate-go v0.14.2/go.mod h1:otIrl1vDmyjNhTzmVmp/mQU3Wt1+3387gFNEsAZq0ig= github.com/sashabaranov/go-openai v1.17.9 h1:QEoBiGKWW68W79YIfXWEFZ7l5cEgZBV4/Ow3uy+5hNY= github.com/sashabaranov/go-openai v1.17.9/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= +github.com/sashabaranov/go-openai v1.17.10 h1:ybvWN+d/rgEK/64U6dsjnOQ9AUya2wBoJKj3Wuaonqo= +github.com/sashabaranov/go-openai v1.17.10/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/tilinna/clock v1.0.2 h1:6BO2tyAC9JbPExKH/z9zl44FLu1lImh3nDNKA0kgrkI= github.com/tilinna/clock v1.0.2/go.mod h1:ZsP7BcY7sEEz7ktc0IVy8Us6boDrK8VradlKRUGfOao= diff --git a/lib/helpers.go b/lib/helpers.go index 09d8e28..ef702b2 100644 --- a/lib/helpers.go +++ b/lib/helpers.go @@ -64,7 +64,7 @@ func GetUserObject(event discord.InteractionEvent) Userish { } } -func CooldownHandler(event discord.InteractionEvent) bool { +func CooldownHandler(event discord.InteractionEvent, command string, cooldownMinutes int64) bool { user := GetUserObject(event) allowList := strings.Split(os.Getenv("COOLDOWN_ALLOW_LIST"), ",") diff --git a/main.go b/main.go index e426ca2..34533af 100644 --- a/main.go +++ b/main.go @@ -132,7 +132,7 @@ 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 - allowed := lib.CooldownHandler(*data.Event) + allowed := lib.CooldownHandler(*data.Event, "ask", 1) if !allowed { return errorResponse(errors.New("please wait for the cooldown")) @@ -194,7 +194,7 @@ 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 - allowed := lib.CooldownHandler(*data.Event) + allowed := lib.CooldownHandler(*data.Event, "pic", 1) if !allowed { return errorResponse(errors.New("please wait for the cooldown")) @@ -270,7 +270,7 @@ 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 - allowed := lib.CooldownHandler(*data.Event) + allowed := lib.CooldownHandler(*data.Event, "hdPic", 1) if !allowed { return errorResponse(errors.New("please wait for the cooldown"))