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

Commit

Permalink
remove avatar update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
keshon committed Aug 30, 2024
1 parent c309cc7 commit f15b7bc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 37 deletions.
2 changes: 1 addition & 1 deletion internal/manager/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (gm *GuildManager) removeBotInstance(guildID string) {

func (gm *GuildManager) splitCommandFromParameter(content, commandPrefix string) (string, string, error) {
if !strings.HasPrefix(content, commandPrefix) {
return "", "", fmt.Errorf("command prefix not found")
return "", "", nil
}

prefixLowercase := strings.ToLower(commandPrefix)
Expand Down
36 changes: 0 additions & 36 deletions mods/about/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/bwmarrin/discordgo"
"github.com/gookit/slog"
"github.com/keshon/melodix-player/internal/config"
"github.com/keshon/melodix-player/mods/about/utils"
)

type Discord struct {
Expand Down Expand Up @@ -45,7 +44,6 @@ func (d *Discord) Start(guildID string, commandPrefix string) {
d.Session.AddHandler(d.Commands)
d.GuildID = guildID
d.CommandPrefix = commandPrefix
d.setupAvatar(d.Session)
}

func (d *Discord) Stop() {
Expand Down Expand Up @@ -111,24 +109,6 @@ func getCanonicalCommand(command string, commandAliases [][]string) string {
return ""
}

func (d *Discord) setupAvatar(s *discordgo.Session) {
if time.Since(d.LastChangeAvatarTime) < d.RateLimitDuration {
return
}

avatar, err := utils.ReadFileToBase64("./assets/avatars/0.png")
if err != nil {
slog.Error("Error reading file to base64:", err)
return
}

_, err = s.UserUpdate("", avatar)
if err != nil {
slog.Error("Error updating user avatar:", err)
return
}
}

func (d *Discord) sendMessageEmbed(embedStr string) *discordgo.Message {
s := d.Session
m := d.Message
Expand All @@ -145,22 +125,6 @@ func (d *Discord) sendMessageEmbed(embedStr string) *discordgo.Message {
return msg
}

func (d *Discord) editMessageEmbed(embedStr string, messageID string) *discordgo.Message {
s := d.Session
m := d.Message

embedBody := embed.NewEmbed().
SetDescription(embedStr).
SetColor(0x9f00d4).MessageEmbed

msg, err := s.ChannelMessageEditEmbed(m.Message.ChannelID, messageID, embedBody)
if err != nil {
slog.Error("Error sending 'stopped playback' message", err)
}

return msg
}

func (d *Discord) SetCommandPrefix(prefix string) {
d.CommandPrefix = prefix
}

0 comments on commit f15b7bc

Please sign in to comment.