From f15b7bcf0a46a5c1714e8a6822f68e9ca84b6c99 Mon Sep 17 00:00:00 2001 From: Innokentiy Sokolov Date: Fri, 30 Aug 2024 08:51:17 +0300 Subject: [PATCH] remove avatar update logic --- internal/manager/discord.go | 2 +- mods/about/discord/discord.go | 36 ----------------------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/internal/manager/discord.go b/internal/manager/discord.go index 4f34451..e602d60 100644 --- a/internal/manager/discord.go +++ b/internal/manager/discord.go @@ -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) diff --git a/mods/about/discord/discord.go b/mods/about/discord/discord.go index 97794c5..db97707 100644 --- a/mods/about/discord/discord.go +++ b/mods/about/discord/discord.go @@ -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 { @@ -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() { @@ -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 @@ -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 }