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

Commit

Permalink
feat custom command (todo)
Browse files Browse the repository at this point in the history
  • Loading branch information
keshon committed May 23, 2024
1 parent 2ebeab5 commit a2ca1bb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
6 changes: 6 additions & 0 deletions internal/manager/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down Expand Up @@ -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
Expand Down
29 changes: 19 additions & 10 deletions mods/music/sources/youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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`, "&")

Expand All @@ -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
}

0 comments on commit a2ca1bb

Please sign in to comment.