Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
fix: update banner images
Browse files Browse the repository at this point in the history
  • Loading branch information
keshon committed Mar 2, 2024
1 parent 80b9093 commit 67245cc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![# Header](https://github.com/keshon/melodix-discord-player/blob/master/assets/banner.jpg)
![# Header](https://github.com/keshon/melodix-discord-player/blob/master/assets/banner-readme.png)


# Melodix Discord Player
Expand Down
Binary file added assets/banner-about.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/banner-readme.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/banner.jpg
Binary file not shown.
39 changes: 19 additions & 20 deletions mod-about/discord/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import (
"fmt"
"log"
"os"
"time"
"path/filepath"

embed "github.com/Clinet/discordgo-embed"
"github.com/bwmarrin/discordgo"
"github.com/gookit/slog"

"github.com/keshon/melodix-discord-player/internal/config"
"github.com/keshon/melodix-discord-player/internal/version"
"github.com/keshon/melodix-discord-player/mod-helloworld/utils"
)

// handleAboutCommand is a function to handle the about command in Discord.
Expand All @@ -21,21 +19,6 @@ import (
func (d *Discord) handleAboutCommand(s *discordgo.Session, m *discordgo.MessageCreate) {
d.changeAvatar(s)

cfg, err := config.NewConfig()
if err != nil {
slog.Fatalf("Error loading config: %v", err)
}

var host string
if os.Getenv("HOST") == "" {
host = cfg.RestHostname
} else {
host = os.Getenv("HOST") // from docker environment
}

avatarURL := utils.InferProtocolByPort(host, 443) + host + "/avatar/random?" + fmt.Sprint(time.Now().UnixNano())
slog.Info(avatarURL)

title := fmt.Sprintf("ℹ️ %v — About", version.AppName)
content := fmt.Sprintf("**%v**\n\n%v", version.AppFullName, version.AppDescription)

Expand All @@ -49,16 +32,32 @@ func (d *Discord) handleAboutCommand(s *discordgo.Session, m *discordgo.MessageC
goVer = version.GoVersion
}

imagePath := "assets/banner-about.png"
imageBytes, err := os.Open(imagePath)
if err != nil {
slog.Error("Error opening image file:", err)
}

embedMsg := embed.NewEmbed().
SetDescription(fmt.Sprintf("**%v**\n\n%v", title, content)).
AddField("```"+buildDate+"```", "Build date").
AddField("```"+goVer+"```", "Go version").
AddField("```Created by Innokentiy Sokolov```", "[Linkedin](https://www.linkedin.com/in/keshon), [GitHub](https://github.com/keshon), [Homepage](https://keshon.ru)").
InlineAllFields().
SetImage(avatarURL).
SetImage("attachment://" + filepath.Base(imagePath)).
SetColor(0x9f00d4).SetFooter(version.AppFullName).MessageEmbed

_, err = s.ChannelMessageSendEmbed(m.ChannelID, embedMsg)
_, err = s.ChannelMessageSendComplex(m.ChannelID, &discordgo.MessageSend{
Content: "Check out this image!",
Embed: embedMsg,
Files: []*discordgo.File{
{
Name: filepath.Base(imagePath),
Reader: imageBytes,
},
},
})

if err != nil {
log.Fatal("Error sending embed message", err)
}
Expand Down

0 comments on commit 67245cc

Please sign in to comment.