From 32978784212d45d96926fec70b75c5bb6c2f3bd7 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Sat, 23 Jul 2022 00:37:00 -0400 Subject: [PATCH] cowboy: fix overlay capture bug --- plugins/cowboy/cowboy.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/cowboy/cowboy.go b/plugins/cowboy/cowboy.go index 3685448..c1dfaa5 100644 --- a/plugins/cowboy/cowboy.go +++ b/plugins/cowboy/cowboy.go @@ -112,6 +112,7 @@ func (p *Cowboy) registerCmds(d *discord.Discord) { } overlays := p.c.GetMap("cowboy.overlays", defaultOverlays) hat := overlays["hat"] + log.Debug().Msgf("Overlay: %s", hat) if err := d.RegisterSlashCmd(cmd, p.mkOverlayCB(hat)); err != nil { log.Error().Err(err).Msg("could not register cowboy command") } @@ -145,8 +146,6 @@ func (p *Cowboy) registerCmds(d *discord.Discord) { func (p *Cowboy) mkOverlayCB(overlay string) func(s *discordgo.Session, i *discordgo.InteractionCreate) { return func(s *discordgo.Session, i *discordgo.InteractionCreate) { - log.Debug().Msg("got a cowboy command") - lastEmojy := p.c.Get("cowboy.lastEmojy", "rust") emojyPlugin := emojy.NewAPI(p.b) @@ -156,6 +155,9 @@ func (p *Cowboy) mkOverlayCB(overlay string) func(s *discordgo.Session, i *disco name = i.ApplicationCommandData().Options[1].StringValue() } msg := fmt.Sprintf("You asked for %s overlaid by %s", name, overlay) + log.Debug().Msgf("got a cowboy command for %s overlaid by %s replacing %s", + name, overlay, lastEmojy) + prefix := overlay newEmojy, err := cowboy(p.emojyPath, p.baseEmojyURL, overlay, name) if err != nil { @@ -169,11 +171,10 @@ func (p *Cowboy) mkOverlayCB(overlay string) func(s *discordgo.Session, i *disco goto resp } - // Look, I don't love it as a workaround either if overlay == "hat" { - overlay = "cowboy" + prefix = "cowboy" } - name = emojy.SanitizeName(overlay + "_" + name) + name = emojy.SanitizeName(prefix + "_" + name) err = emojyPlugin.UploadEmojyImage(p.b.DefaultConnector(), name, newEmojy) if err != nil { msg = err.Error()