Skip to content

Commit

Permalink
fix: possible nil pointer, better interaction generator
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTipo01 committed Oct 26, 2023
1 parent 38ed350 commit 6ff0b37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions api/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,39 @@ func (a *Api) interactionGenerator(u *discordgo.User, song string, playlist bool
User: u,
},
Data: discordgo.ApplicationCommandInteractionData{
Name: "play",
CommandType: discordgo.ChatApplicationCommand,
Options: []*discordgo.ApplicationCommandInteractionDataOption{
{
Name: "link",
Value: song,
Type: discordgo.ApplicationCommandOptionString,
},
{
Name: "playlist",
Value: playlist,
Type: discordgo.ApplicationCommandOptionBoolean,
},
{
Name: "shuffle",
Value: shuffle,
Type: discordgo.ApplicationCommandOptionBoolean,
},
{
Name: "loop",
Value: loop,
Type: discordgo.ApplicationCommandOptionBoolean,
},
{
Name: "priority",
Value: priority,
Type: discordgo.ApplicationCommandOptionBoolean,
},
},
},
ChannelID: a.userInfo[u.ID].TextChannel,
GuildID: guild,
Version: 1,
},
}
}
7 changes: 6 additions & 1 deletion manager/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import (
// And if it doesn't contain an ID for the video, it returns an error.
func filterPlaylist(link string) (string, error) {
if com, be := strings.Contains(link, "youtube.com"), strings.Contains(link, "youtu.be"); com || be {
u, _ := url.Parse(link)
u, err := url.Parse(link)
if err != nil {
lit.Error("filterPlaylist failed: %s", err)
return "", err
}

q := u.Query()
q.Del("list")
q.Del("index")
Expand Down

0 comments on commit 6ff0b37

Please sign in to comment.