Skip to content

Commit

Permalink
(v1.4) General improvements & lyrics cmd
Browse files Browse the repository at this point in the history
+ Merged volume buttons under the now playing embeds to a single adjust button, allowing the user to input a specific value within an modal menu (#18).
+ New lyrics command implemented (#19).
+ Fixed an issue allowing the user to use the clear queue and shuffle queue buttons even though no songs are queued. This will now return an ephemeral error reply.
+ Altered song search flow. Specifically, when the search embed is returned and once the user selects a song through the menu, the original search embed will be edited to the "added to queue" embed, rather than posting separately and leaving the previous search embed as "spam" in the chat.
+ Re-implemented playlist support for Plex commands (was temporarily removed previously due to Plex search overhaul).
+ Fixed issues with Spotify songs sometimes not playing without an error, as well as YT Music playlists specifically not working (#8 & #9).
+ Fixed bug with previous song button not working (#12).
+ Fixed an occurrence of an 0 username tag.
  • Loading branch information
ThatGuyJacobee committed Oct 2, 2023
1 parent 317292a commit 4c9a9e2
Show file tree
Hide file tree
Showing 9 changed files with 214 additions and 128 deletions.
2 changes: 1 addition & 1 deletion commands/music/back.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
.setThumbnail(interaction.guild.iconURL({dynamic: true}))
.setColor(client.config.embedColour)
.setTitle(`Playing previous song ⏮️`)
.setDescription(`Returning next to the previous song ${previousTracks[0].title} ${previousTracks[0].queryType != 'arbitrary' ? `([Link](${previousTracks[0].url}))` : ''}!`)
.setDescription(`Returning next to the previous song: ${previousTracks[0].title} ${previousTracks[0].queryType != 'arbitrary' ? `([Link](${previousTracks[0].url}))` : ''}!`)
.setTimestamp()
.setFooter({ text: `Requested by: ${interaction.user.discriminator != 0 ? interaction.user.tag : interaction.user.username}` })

Expand Down
55 changes: 55 additions & 0 deletions commands/music/lyrics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require("dotenv").config();
const { SlashCommandBuilder } = require("@discordjs/builders");
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder } = require("discord.js");
const { Player } = require('discord-player');
const { lyricsExtractor } = require("@discord-player/extractor");

module.exports = {
data: new SlashCommandBuilder()
.setName("lyrics")
.setDescription("Get the lyrics for a song!")
.addStringOption((option) => option
.setName("query")
.setDescription("Enter the name of the song.")
.setRequired(true)
),
async execute(interaction) {
if (client.config.enableDjMode) {
if (!interaction.member.roles.cache.has(client.config.djRole)) return interaction.reply({ content: `❌ | DJ Mode is active! You must have the DJ role <@&${client.config.djRole}> to use any music commands!`, ephemeral: true });
}

var query = interaction.options.getString("query");
const extractor = lyricsExtractor();

var findLyrics = await extractor.search(query)
.catch(err => {})

if (!findLyrics) return interaction.reply({ content: `❌ | No lyrics were found for the requested query!`, ephemeral: true });
let splicedLyrics = findLyrics.lyrics.slice(0, 4000)

const lyricsembed = new EmbedBuilder()
.setAuthor({ name: interaction.client.user.tag, iconURL: interaction.client.user.displayAvatarURL() })
//.setThumbnail(interaction.guild.iconURL({dynamic: true}))
.setColor(client.config.embedColour)
.setTitle(`Lyrics for ${findLyrics.title} by ${findLyrics.artist.name} 🎶`)
.setDescription(findLyrics.lyrics.length > 4000 ? splicedLyrics + '\nAnd more...' : findLyrics.lyrics)
.setTimestamp()
.setFooter({ text: `Requested by: ${interaction.user.discriminator != 0 ? interaction.user.tag : interaction.user.username}` })

var actionbuttons = new ActionRowBuilder()
.addComponents(
new ButtonBuilder()
.setCustomId("np-delete")
.setStyle(4)
.setLabel("🗑️"),
//.addOptions(options)
new ButtonBuilder()
.setURL(findLyrics.url)
.setStyle(5) //Link
.setLabel("🎶 Full Lyrics"),
//.addOptions(options)
)

interaction.reply({ embeds: [lyricsembed], components: [actionbuttons] })
}
}
8 changes: 2 additions & 6 deletions commands/music/nowplaying.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,9 @@ module.exports = {
),
actionbutton2 = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setCustomId("np-volumedown")
.setCustomId("np-volumeadjust")
.setStyle(1)
.setLabel("🔈 Volume Down"),
new ButtonBuilder()
.setCustomId("np-volumeup")
.setStyle(1)
.setLabel("🔊 Volume Up"),
.setLabel("🔊 Adjust Volume"),
new ButtonBuilder()
.setCustomId("np-loop")
.setStyle(1)
Expand Down
16 changes: 6 additions & 10 deletions commands/music/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ client.on('interactionCreate', async (interaction) => {
return interaction.reply({ content: `❌ | Ooops... something went wrong, couldn't find the song.`, ephemeral: true })
}

//Otherwise it has found so defer reply
await interaction.deferReply();
//Defer update from menu interaction
await interaction.deferUpdate();

try {
if (!queue.connection) await queue.connect(interaction.member.voice.channel);
Expand Down Expand Up @@ -273,8 +273,7 @@ client.on('interactionCreate', async (interaction) => {
.setFooter({ text: `Requested by: ${interaction.user.discriminator != 0 ? interaction.user.tag : interaction.user.username}` })

var sourceMessage = interaction.message
sourceMessage.edit({embeds: sourceMessage.embeds, components: []})
interaction.followUp({ embeds: [playlistembed] })
sourceMessage.edit({ embeds: [playlistembed], components: [] })
}

else {
Expand All @@ -288,8 +287,7 @@ client.on('interactionCreate', async (interaction) => {
.setFooter({ text: `Requested by: ${interaction.user.discriminator != 0 ? interaction.user.tag : interaction.user.username}` })

var sourceMessage = interaction.message
sourceMessage.edit({embeds: sourceMessage.embeds, components: []})
interaction.followUp({ embeds: [playsongembed] })
sourceMessage.edit({ embeds: [playsongembed], components: [] })
}
}

Expand All @@ -305,8 +303,7 @@ client.on('interactionCreate', async (interaction) => {
.setFooter({ text: `Requested by: ${interaction.user.discriminator != 0 ? interaction.user.tag : interaction.user.username}` })

var sourceMessage = interaction.message
sourceMessage.edit({embeds: sourceMessage.embeds, components: []})
interaction.followUp({ embeds: [queueplaylistembed] })
sourceMessage.edit({ embeds: [queueplaylistembed], components: [] })
}

else {
Expand All @@ -320,8 +317,7 @@ client.on('interactionCreate', async (interaction) => {
.setFooter({ text: `Requested by: ${interaction.user.discriminator != 0 ? interaction.user.tag : interaction.user.username}` })

var sourceMessage = interaction.message
sourceMessage.edit({embeds: sourceMessage.embeds, components: []})
interaction.followUp({ embeds: [queuesongembed] })
sourceMessage.edit({ embeds: [queuesongembed], components: [] })
}
}
}
Expand Down

0 comments on commit 4c9a9e2

Please sign in to comment.