Fixed cache issue
This commit is contained in:
parent
7350c4f0d0
commit
db5c9a2845
1 changed files with 38 additions and 6 deletions
44
main.go
44
main.go
|
@ -131,13 +131,24 @@ func (h *handler) cmdPing(ctx context.Context, data cmdroute.CommandData) *api.I
|
||||||
|
|
||||||
func (h *handler) cmdAsk(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
|
func (h *handler) cmdAsk(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
|
||||||
// Cooldown Logic
|
// Cooldown Logic
|
||||||
cachedVal := lib.GetCache(data.Event.User.ID.String() + ":" + "ask")
|
member := data.Event.Member
|
||||||
|
user := data.Event.User
|
||||||
|
|
||||||
|
var idToSend string
|
||||||
|
|
||||||
|
if member != nil {
|
||||||
|
idToSend = member.User.ID.String()
|
||||||
|
} else {
|
||||||
|
idToSend = user.ID.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
cachedVal := lib.GetCache(idToSend + ":" + "ask")
|
||||||
if cachedVal != "nil" {
|
if cachedVal != "nil" {
|
||||||
return &api.InteractionResponseData{
|
return &api.InteractionResponseData{
|
||||||
Content: option.NewNullableString("Please wait for the cooldown!"),
|
Content: option.NewNullableString("Please wait for the cooldown!"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lib.SetCache(data.Event.User.ID.String()+":"+"ask", data.Event.User.ID.String()+":"+"ask", 1)
|
lib.SetCache(idToSend+":"+"ask", idToSend+":"+"ask", 1)
|
||||||
|
|
||||||
// Command Logic
|
// Command Logic
|
||||||
var options struct {
|
var options struct {
|
||||||
|
@ -179,13 +190,24 @@ func (h *handler) cmdAsk(ctx context.Context, data cmdroute.CommandData) *api.In
|
||||||
|
|
||||||
func (h *handler) cmdPic(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
|
func (h *handler) cmdPic(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
|
||||||
// Cooldown Logic
|
// Cooldown Logic
|
||||||
cachedVal := lib.GetCache(data.Event.User.ID.String() + ":" + "pic")
|
member := data.Event.Member
|
||||||
|
user := data.Event.User
|
||||||
|
|
||||||
|
var idToSend string
|
||||||
|
|
||||||
|
if member != nil {
|
||||||
|
idToSend = member.User.ID.String()
|
||||||
|
} else {
|
||||||
|
idToSend = user.ID.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
cachedVal := lib.GetCache(idToSend + ":" + "pic")
|
||||||
if cachedVal != "nil" {
|
if cachedVal != "nil" {
|
||||||
return &api.InteractionResponseData{
|
return &api.InteractionResponseData{
|
||||||
Content: option.NewNullableString("Please wait for the cooldown!"),
|
Content: option.NewNullableString("Please wait for the cooldown!"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lib.SetCache(data.Event.User.ID.String()+":"+"pic", data.Event.User.ID.String()+":"+"pic", 1)
|
lib.SetCache(idToSend+":"+"pic", idToSend+":"+"pic", 1)
|
||||||
|
|
||||||
// Command Logic
|
// Command Logic
|
||||||
var options struct {
|
var options struct {
|
||||||
|
@ -257,13 +279,23 @@ func (h *handler) cmdPic(ctx context.Context, data cmdroute.CommandData) *api.In
|
||||||
|
|
||||||
func (h *handler) cmdHDPic(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
|
func (h *handler) cmdHDPic(ctx context.Context, data cmdroute.CommandData) *api.InteractionResponseData {
|
||||||
// Cooldown Logic
|
// Cooldown Logic
|
||||||
cachedVal := lib.GetCache(data.Event.User.ID.String() + ":" + "hdpic")
|
member := data.Event.Member
|
||||||
|
user := data.Event.User
|
||||||
|
|
||||||
|
var idToSend string
|
||||||
|
|
||||||
|
if member != nil {
|
||||||
|
idToSend = member.User.ID.String()
|
||||||
|
} else {
|
||||||
|
idToSend = user.ID.String()
|
||||||
|
}
|
||||||
|
cachedVal := lib.GetCache(idToSend + ":" + "hdpic")
|
||||||
if cachedVal != "nil" {
|
if cachedVal != "nil" {
|
||||||
return &api.InteractionResponseData{
|
return &api.InteractionResponseData{
|
||||||
Content: option.NewNullableString("Please wait for the cooldown!"),
|
Content: option.NewNullableString("Please wait for the cooldown!"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lib.SetCache(data.Event.User.ID.String()+":"+"hdpic", data.Event.User.ID.String()+":"+"hdpic", 10)
|
lib.SetCache(idToSend+":"+"hdpic", idToSend+":"+"hdpic", 10)
|
||||||
|
|
||||||
// Command Logic
|
// Command Logic
|
||||||
var options struct {
|
var options struct {
|
||||||
|
|
Loading…
Add table
Reference in a new issue