diff --git a/internal/manager/discord.go b/internal/manager/discord.go index c32e3f0..31d3270 100644 --- a/internal/manager/discord.go +++ b/internal/manager/discord.go @@ -105,6 +105,8 @@ func (gm *GuildManager) Commands(s *discordgo.Session, m *discordgo.MessageCreat gm.handleUnregisterCommand() case "whoami": gm.handleWhoamiCommand() + case "set-melodix-custom-prefix": + gm.handleCustomPrefixCommand() } } @@ -167,6 +169,10 @@ func (gm *GuildManager) handleWhoamiCommand() { gm.Session.ChannelMessageSend(gm.Message.ChannelID, "User info for **"+gm.Message.Author.Username+"** was sent to terminal") } +func (gm *GuildManager) handleCustomPrefixCommand() { + // TODO +} + func (gm *GuildManager) setupBotInstance(guildID string) { id := guildID session := gm.Session diff --git a/mods/music/sources/youtube.go b/mods/music/sources/youtube.go index 1f83f76..0f70135 100644 --- a/mods/music/sources/youtube.go +++ b/mods/music/sources/youtube.go @@ -74,22 +74,19 @@ func (y *Youtube) parseSongOrPlaylistInfo(url string) ([]*player.Song, error) { return nil, err } - slog.Warn(tracks) + // slog.Warn(tracks) + + tracks = y.removeDuplicateStr(tracks) playlistVideos = &kkdai_youtube.Playlist{ - ID: "your_playlist_id", - Title: "Your Playlist Title", - Description: "Your Playlist Description", - Author: "Your Author", - Videos: make([]*kkdai_youtube.PlaylistEntry, len(tracks)), + + Videos: make([]*kkdai_youtube.PlaylistEntry, len(tracks)), } // Populate the Videos field for i, track := range tracks { playlistVideos.Videos[i] = &kkdai_youtube.PlaylistEntry{ - ID: track, - Title: "", - Author: "", + ID: track, } } } else { @@ -296,7 +293,7 @@ func (y *Youtube) getVideoURLsFromYoutubeMixPlaylist(url string) ([]string, erro return nil, err } - slog.Error(body) + //slog.Error(body) bodyString := strings.ReplaceAll(string(body), `\u0026`, "&") @@ -316,3 +313,15 @@ func (y *Youtube) getVideoURLsFromYoutubeMixPlaylist(url string) ([]string, erro return videoURLs, nil } + +func (y *Youtube) removeDuplicateStr(strSlice []string) []string { + allKeys := make(map[string]bool) + list := []string{} + for _, item := range strSlice { + if _, value := allKeys[item]; !value { + allKeys[item] = true + list = append(list, item) + } + } + return list +}